Fix Ctrl+Return keybinding in rofi script mode
Rofi requires use-hot-keys to be explicitly enabled for kb-custom-N keybindings to work in script mode.
This commit is contained in:
parent
82159b7e32
commit
8df2281f60
@ -44,17 +44,9 @@ class RofiSelector:
|
||||
self.__write_result(rofi_info, fields[0])
|
||||
return None
|
||||
|
||||
# kb-accept-custom → second field
|
||||
if rofi_retv == 2 and len(fields) > 1:
|
||||
rofi_info = os.environ.get("ROFI_INFO", "")
|
||||
if not rofi_info:
|
||||
return None
|
||||
self.__write_result(rofi_info, fields[1])
|
||||
return None
|
||||
|
||||
# kb-custom-N: ROFI_RETV 10 + (N-1) → fields[N+1]
|
||||
# kb-custom-N: ROFI_RETV 10 + (N-1) → fields[N]
|
||||
custom_index = rofi_retv - 10
|
||||
field_index = custom_index + 2
|
||||
field_index = custom_index + 1
|
||||
if 0 <= field_index < len(fields):
|
||||
rofi_info = os.environ.get("ROFI_INFO", "")
|
||||
if not rofi_info:
|
||||
@ -99,11 +91,8 @@ class RofiSelector:
|
||||
"-kb-accept-entry",
|
||||
keys[0],
|
||||
]
|
||||
if len(keys) > 1:
|
||||
cmd.extend(["-kb-accept-custom", keys[1]])
|
||||
else:
|
||||
cmd.extend(["-kb-accept-custom", ""])
|
||||
for i, key in enumerate(keys[2:], start=1):
|
||||
cmd.extend(["-kb-accept-custom", ""])
|
||||
for i, key in enumerate(keys[1:], start=1):
|
||||
cmd.extend([f"-kb-custom-{i}", key])
|
||||
|
||||
subprocess.run(cmd)
|
||||
@ -113,6 +102,7 @@ class RofiSelector:
|
||||
|
||||
print("\0prompt\x1fSelect item")
|
||||
print("\0no-custom\x1ftrue")
|
||||
print("\0use-hot-keys\x1ftrue")
|
||||
|
||||
hints = []
|
||||
for key, field in keybindings.items():
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user