Xfce Forum

Sub domains
 

You are not logged in.

#1 2023-12-12 00:33:22

expoodo
Member
Registered: 2023-12-12
Posts: 5

Custom keybinds dont work with custom rofi toggle script [SOLVED]

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

#2 2023-12-12 02:58:17

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: Custom keybinds dont work with custom rofi toggle script [SOLVED]

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

#3 2023-12-12 03:23:07

expoodo
Member
Registered: 2023-12-12
Posts: 5

Re: Custom keybinds dont work with custom rofi toggle script [SOLVED]

I tried adding

sh -c "rofi-toggle" 

as the command for the keybind, however that did not work

Offline

#4 2023-12-12 03:45:39

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: Custom keybinds dont work with custom rofi toggle script [SOLVED]

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

#5 2023-12-12 03:59:19

expoodo
Member
Registered: 2023-12-12
Posts: 5

Re: Custom keybinds dont work with custom rofi toggle script [SOLVED]

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

#6 2023-12-12 05:04:27

expoodo
Member
Registered: 2023-12-12
Posts: 5

Re: Custom keybinds dont work with custom rofi toggle script [SOLVED]

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

#7 2023-12-12 20:58:12

expoodo
Member
Registered: 2023-12-12
Posts: 5

Re: Custom keybinds dont work with custom rofi toggle script [SOLVED]

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

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.013 seconds, 7 queries executed - Memory usage: 540.8 KiB (Peak: 542.08 KiB) ]