aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Langridge <sil@kryogenix.org>2019-06-10 00:37:10 +0100
committerStuart Langridge <sil@kryogenix.org>2019-06-10 00:37:10 +0100
commit7afb1130f0bbe2279ce20bafe8572b7bb5a18433 (patch)
tree5b69b11f19f4f87b6712e3be47a644babde87922
parentBind both super-alt-equals and super-alt-plus as zoom-in keys (diff)
downloadmagnus-7afb1130f0bbe2279ce20bafe8572b7bb5a18433.tar.gz
magnus-7afb1130f0bbe2279ce20bafe8572b7bb5a18433.tar.bz2
magnus-7afb1130f0bbe2279ce20bafe8572b7bb5a18433.zip
Unset GSettings screen-magnifier-enabled on explicit close
If magnus is started with the global desktop magnifier keypress, it will invoke the Exec line from the autostart desktop file. This Exec line passes the extra command parameter --started-by-keypress. If that command parameter is set, and the app is explicitly closed with the close icon or Alt-F4 or similar, then explicitly set the GSettings key back to false (as discussed in #4) so that they stay in sync.
-rwxr-xr-xmagnus25
1 files changed, 25 insertions, 0 deletions
diff --git a/magnus b/magnus
index 5975a12..e2f492c 100755
--- a/magnus
+++ b/magnus
@@ -22,6 +22,7 @@ class Main(object):
"org.kryogenix.magnus",
Gio.ApplicationFlags.HANDLES_COMMAND_LINE)
self.app.connect("command-line", self.handle_commandline)
+ self.app.connect("shutdown", self.handle_shutdown)
self.resize_timeout = None
self.window_metrics = None
self.window_metrics_restored = False
@@ -30,6 +31,14 @@ class Main(object):
self.last_x = -1
self.last_y = -1
self.refresh_interval = 250
+ self.started_by_keypress = False
+
+ def handle_shutdown(self, app):
+ if self.started_by_keypress:
+ settings = Gio.Settings.new("org.gnome.desktop.a11y.applications")
+ val = settings.get_boolean("screen-magnifier-enabled")
+ if val:
+ settings.set_boolean("screen-magnifier-enabled", False)
def handle_commandline(self, app, cmdline):
args = cmdline.get_arguments()
@@ -57,6 +66,22 @@ class Main(object):
self.refresh_interval = rival
except ValueError:
pass
+ if arg == "--started-by-keypress":
+ self.started_by_keypress = True
+ # This is here so that the autostart desktop file can specify it.
+ # The idea is that Gnome-ish desktops have an explicit keybinding
+ # to run the system magnifier; what this keybinding actually does,
+ # via the {desktop}-settings-daemon, is toggle the gsettings key
+ # org.gnome.desktop.a11y.applications screen-magnifier-enabled
+ # Magnus provides a desktop file to go in /etc/xdg/autostart which
+ # contains an AutostartCondition of
+ # GSettings org.gnome.desktop.a11y.applications screen-magnifier-enabled
+ # and then the {desktop}-session daemon takes care of starting the
+ # app when that key goes true, and closing the app if that
+ # key goes false. However, the user may also explicitly quit Magnus
+ # with the close icon or alt-f4 or similar. If they do so, then
+ # we explicitly set the key back to false, so that the global
+ # keybinding to run the magnifier stays in sync.
# First time startup
self.start_everything_first_time()
bgstack15