Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable show/hide of kupfer without keybinder #157

Closed
seltzered opened this issue Jul 20, 2021 · 7 comments
Closed

Enable show/hide of kupfer without keybinder #157

seltzered opened this issue Jul 20, 2021 · 7 comments

Comments

@seltzered
Copy link

seltzered commented Jul 20, 2021

Hi, I'm as mentioned in #62 (comment) I'm trying to make kupfer show (and more important to this issue hide itself) when one is invoking kupfer without keybinder (i.e. invoking the kupfer-run script). After looking into it the following ways to implement it come to mind:

1. Assume show/hide as a default behavior for kupfer-run

I've tried this route and it could be done seemingly by just replacing the line invoking PresentOnDisplay with a ShowHide message, i.e.:
from
test $KUPFER_HAS_OPTIONS != 0 && dbus-send --type=method_call --print-reply \ --dest=$SERVICE $OBJ $IFACE.PresentOnDisplay string:"$DISPLAY" \ "string:$DESKTOP_STARTUP_ID" >/dev/null 2>&1
to
test $KUPFER_HAS_OPTIONS != 0 && dbus-send --type=method_call --print-reply \ --dest=$SERVICE $OBJ $IFACE.ShowHide >/dev/null 2>&1

2. Create a command-line option to pass into kupfer

This would mean creating something like a --toggle option to pass into kupfer.py to then be handled.

Is there a preference on how this should be implemented?

Environment

Ubuntu 21.04 (uses wayland)

Actual Behaviour

Hitting ctrl+space (or whatever one uses to invoke kupfer (the kupfer-run.sh script)) when kupfer window is already open doesn't hide the window.

Expected Behaviour

Hitting ctrl+space (or whatever one uses to invoke kupfer (the kupfer-run.sh script)) when kupfer window is already open hides the window, either as a default or by setting a --toggle option

@bluss
Copy link
Member

bluss commented Jul 20, 2021

Should be a new toggle IMO. You can see that the dbus change as written regresses by not sending all info- display* and timestamp, and these are important in some configurations. The nature of the many desktop environments means that whatever looks like it "works for you" could be buggy other places.

*It's doubtful if display is useful anymore, don't think it is in current gtk3. Timestamp/startup id would be, if it's for the default action when running kupfer.

@KarolBedkowski
Copy link
Contributor

This can be handled by simple shell script.
dbus-send --type=method_call --dest=se.kaizer.kupfer /interface se.kaizer.kupfer.Listener.ShowHide

@seltzered
Copy link
Author

seltzered commented Dec 16, 2023

Thank you! To ensure this will also launch kupfer if it isn't running, and send the show/hide toggle if it is, I ended up with the following script:

#!/usr/bin/bash

# detect if kupfer is running by checking if dbus service is listed
if dbus-send --print-reply --dest=org.freedesktop.DBus  /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep io.github.kupferlauncher > /dev/null
then # kupfer running, send showHide signal
  dbus-send --type=method_call --dest=io.github.kupferlauncher /io/github/kupferlauncher io.github.kupferlauncher.Listener.ShowHide
else # kupfer not running, launch kupfer
  kupfer
fi

One can then just setup a keyboard shortcut to this script to their desktop environment's settings, such as in gnome:
image

@bluss
Copy link
Member

bluss commented Dec 17, 2023

The se.kaizer.kupfer and so on dbus names are long deprecated, you should use the kupferlauncher names

SERVICE="io.github.kupferlauncher"
OBJ="/io/github/kupferlauncher"
IFACE="io.github.kupferlauncher.Listener"

@seltzered
Copy link
Author

seltzered commented Dec 17, 2023

Huh, I just tested on v323 and while I can get:

dbus-send --type=method_call --dest=se.kaizer.kupfer /interface se.kaizer.kupfer.Listener.ShowHide

to work, the suggested dbus name change to:

dbus-send --type=method_call --dest=io.github.kupferlauncher /interface io.github.kupferlauncher.Listener.ShowHide

does not work. I did run listNames to check the service is running and see both string "io.github.kupferlauncher" and string "se.kaizer.kupfer"

@KarolBedkowski
Copy link
Contributor

dbus-send --type=method_call --dest=io.github.kupferlauncher /io/github/kupferlauncher io.github.kupferlauncher.Listener.ShowHide

@seltzered
Copy link
Author

Thanks! Will update my script in #157 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants