davatorium/rofi

[BUG] Empty keybind arguments appear to be skipped

lonkaars opened this issue · 9 comments

Rofi version (rofi -v)

Version: 1.7.5

Configuration

https://gist.github.com/lonkaars/b3bed963fd102a0ff76af67cf892d37d#file-rofi-dump-config

Theme

https://gist.github.com/lonkaars/b3bed963fd102a0ff76af67cf892d37d#file-rofi-dump-theme

Timing report

No response

Launch command

rofi -no-config -kb-mode-previous '' -kb-mode-next '' -show run

Step to reproduce

Run:

rofi -no-config -kb-mode-previous '' -kb-mode-next '' -show run

Expected behavior

I expected rofi to parse the empty arguments as empty keysims, effectively un-binding the keys

Actual behavior

rofi appears to skip the empty arguments entirely, which results in the following error:
image

Additional information

Substituting the empty strings for comma's seems to mitigate the issue:

rofi -no-config -kb-mode-previous ',' -kb-mode-next ',' -show run

My guess is that rofi parses a single comma as a list of two empty keysims, and does not skip the arguments because they are no longer empty. Man rofi-keys(5) does describe the usage of the comma to specify multiple keybinds for the same action, but unbinding a key only seems to be documented in the online manpage.

Using wayland display server protocol

  • No, I don't use the wayland display server protocol

I've checked if the issue exists in the latest stable release

  • Yes, I have checked the problem exists in the latest stable version

I cannot reproduce:

rofi -no-config -kb-mode-previous '' -kb-mode-next '' -show keys

works.

rofi-2024-02-27-2334-00000

Tested, works with latest and 1.7.5.

I can reproduce your error:

rofi -no-config -kb-mode-previous  -kb-mode-next -show keys

are you sure you shell/launcher passes empty arguments?

If I substitute rofi for printf -- '"%s"\n':

$ printf -- '"%s"\n' -no-config -kb-mode-previous '' -kb-mode-next '' -show keys
"-no-config"
"-kb-mode-previous"
""
"-kb-mode-next"
""
"-show"
"keys"

So I guess it works as intended?

Edit: tested with ZSH 5.9, Bash 5.2.26 and Dash 0.5.12. All show the above output

What shell do you use, because from your error message, those empty ones are not there.
It tries to interper '-show' as the value of '-kb-mode-next'.

For me with bash, your example works fine (see screenshot).

also tested zsh 5.9, works fine.

This does not feel like a rofi issue because rofi code does not skip 'empty' arguments (it gets an array passed), but I am unsure why for you the shell does not pass those .

Calling rofi from python does seem to work on my system (os.exec does not run in a shell):

#!/bin/python3
import os
os.execv('/bin/rofi', [ 'rofi', # argv[0] needs to be passed again
  '-no-config',
  '-kb-mode-previous', '',
  '-kb-mode-next', '',
  '-show', 'keys'
])

I am unsure why this works, while the shell does not

Ok, that confirms it aint rofi's fault, but I wonder why your shell is behaving differently for you then me.

This is incredibly embarassing, I had a wrapper around rofi in my home directoy that set some environment variables which did not properly forward the arguments. Thanks for helping out though!

Happy the problem is resolved .

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.