You are not logged in.
Hopefully I'm posting in the right place, but I have a script that allows me to toggle Rofi on and off, and I have assigned it to a keybind using Keyboard > Application Shortucts. However when the I press the keybind it opens rofi, but if I press it again, it does nothing instead of closing rofi. If I run something like rofi-toggle ; sleep 1 ; rofi-toggle in the terminal, everything works fine for some reason.
OS: arch linux
XFCE 4.18
rofi-toggle:
#!/bin/bash
if [ -n "$(xdotool search --onlyvisible --class rofi getwindowname)" ];then
killall rofi
else
rofi -show drun -show-icons
fi
Last edited by expoodo (2023-12-12 20:58:49)
Offline
Hello and welcome.
Try running the keyboard shortcut within a subshell:
sh -c "rofi-toggle ; sleep 1 ; rofi-toggle"
The internal interpreter doesn't handle special characters well.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
I tried adding
sh -c "rofi-toggle"
as the command for the keybind, however that did not work
Offline
It would appear that rofi is grabbing the keyboard when its open so the keyboard shortcut never makes it to Xfce to execute. From "man rofi":
Some tools (such as import or xdotool) might be unable to run upon a
KeyPress event, because the keyboard/pointer is still grabbed. For
these situations, the --release flag can be used, as it will execute
the command after the keys have been released.
I can't get the "--release" flag to work (I'm not at all familiar with rofi) but I do notice that I can close the window with an Esc or focus change.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
I can't get the "--release" flag to work
Looking at the documentation, I believe the "--release" flag is used for the i3 wm, and not as a flag for rofi.
I do notice that I can close the window with an Esc or focus change.
I have noticed that, but I just want to see if I can toggle rofi using one keybind if thats possible.
Offline
After looking more into it, this issue seems to be a problem with rofi grabbing the keyboard instead of being an Xfce issue. Not sure if I should mark this thread solved?
Offline
Managed to fix this issue by adding " -kb-cancel 'Super_L' " as a flag for rofi and just calling rofi directly with the keybind
ex.
rofi -kb-cancel 'Super_L' -show drun -show-icons
Offline
[ Generated in 0.013 seconds, 7 queries executed - Memory usage: 540.8 KiB (Peak: 542.08 KiB) ]