From f69d7c0df909dadb9c6ef859cc9ee35513e32e3d Mon Sep 17 00:00:00 2001 From: Jason Thai Date: Sat, 15 Jan 2022 01:28:47 -0800 Subject: [PATCH] Implement --is-version option --- guake/dbusiface.py | 4 ++++ guake/guake_app.py | 5 +++++ guake/main.py | 13 +++++++++++++ 3 files changed, 22 insertions(+) diff --git a/guake/dbusiface.py b/guake/dbusiface.py index 66897fe7a..904627bd6 100755 --- a/guake/dbusiface.py +++ b/guake/dbusiface.py @@ -61,6 +61,10 @@ def hide(self): def hide_from_remote(self): self.guake.hide_from_remote() + @dbus.service.method(DBUS_NAME, out_signature="i") + def get_visibility(self): + return self.guake.get_visibility() + @dbus.service.method(DBUS_NAME) def fullscreen(self): self.guake.fullscreen() diff --git a/guake/guake_app.py b/guake/guake_app.py index 501755178..5ffb1301a 100644 --- a/guake/guake_app.py +++ b/guake/guake_app.py @@ -598,6 +598,11 @@ def show_hide(self, *args): else: log.debug("Hiding the terminal") self.hide() + + def get_visibility(self): + if self.hidden == True: + return 0 + return 1 def show_focus(self, *args): self.win_prepare() diff --git a/guake/main.py b/guake/main.py index 3d909ecb6..4357de7a6 100644 --- a/guake/main.py +++ b/guake/main.py @@ -367,6 +367,14 @@ def main(): help=_("Show support information"), ) + parser.add_option( + "--is-visible", + dest="is_visible", + action="store_true", + default=False, + help=_("Return 1 if Guake is visible, 0 otherwise"), + ) + # checking mandatory dependencies missing_deps = False @@ -486,6 +494,11 @@ def main(): if options.hide: remote_object.hide_from_remote() + if options.is_visible: + visibility = remote_object.get_visibility() + sys.stdout.write(f"{visibility}\n") + only_show_hide = options.show + if options.show_preferences: remote_object.show_prefs() only_show_hide = options.show