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..c74bbd5a7 100644 --- a/guake/guake_app.py +++ b/guake/guake_app.py @@ -599,6 +599,11 @@ def show_hide(self, *args): log.debug("Hiding the terminal") self.hide() + def get_visibility(self): + if self.hidden: + return 0 + return 1 + def show_focus(self, *args): self.win_prepare() self.show() diff --git a/guake/main.py b/guake/main.py index 3d909ecb6..ed23fcdad 100644 --- a/guake/main.py +++ b/guake/main.py @@ -122,6 +122,14 @@ def main(): help=_("Toggles the visibility of the terminal window"), ) + parser.add_option( + "--is-visible", + dest="is_visible", + action="store_true", + default=False, + help=_("Return 1 if Guake is visible, 0 otherwise"), + ) + parser.add_option( "--show", dest="show", @@ -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 diff --git a/releasenotes/notes/feature_isvisible_option-6f15b5f7d3341e7e.yaml b/releasenotes/notes/feature_isvisible_option-6f15b5f7d3341e7e.yaml new file mode 100644 index 000000000..b478c44d7 --- /dev/null +++ b/releasenotes/notes/feature_isvisible_option-6f15b5f7d3341e7e.yaml @@ -0,0 +1,5 @@ + +features: + + - --is-visible option returns 1 when visible, and 0 when not #1926 +