Achieving -filter behavior in rofi-script #2156
Replies: 2 comments 1 reply
-
To give more context to those interested, I've developed custom solution for virtual i3 workspace groups. Basically I'm mapping workspaces 1-10 to first group, 11-20 to second etc.. (currently 10 groups is supported so workspaces from 1 to 100). Group ID's are multiple of 10, which is convenient for manipulating workspaces indices (e.g. when I render in polybar workspace number, I reduce group ID so workspace 13 becomes 3 while group is active). Alongside hotkeys for switching, I've utilized rofi for this task. I present user with list of groups which can be selected to focus on. #!/usr/bin/env bash
INI_FILE="$HOME/.cache/i3/groups.ini"
SWITCH_SCRIPT="$HOME/.i3/scripts/switch_group.sh"
# Parse group list from INI
read_groups() {
awk -F' *= *' '
/^\[groups\]/ { reading = 1; next }
/^\[/ { reading = 0 }
reading && /^[0-9]+ *=/ {
printf "%s:%s\n", $1, $2
}
' "$INI_FILE"
}
# Read mode from stdin args
case "$ROFI_RETV" in
0) # Initial mode call, list entries
while IFS=: read -r id name; do
echo "$name ($id)"
done < <(read_groups)
;;
1) # An entry was selected
selected="$1"
group_id=$(echo "$selected" | grep -oP '\(\K[0-9]+(?=\))')
if [[ -n "$group_id" ]]; then
"$SWITCH_SCRIPT" "$group_id" && pkill -u $USER rofi
fi
;;
*) # Other modes not needed
exit 1
;;
esac So now I would like to add a hotkey for renaming group (names are stored in INI file) and I'll also add one for deleting all windows in group (basically clearing a group). Ideally I'd type e.g. Ctrl + R when group is highlighted which would move to next prompt for renaming selected group name INI File: [groups]
0 = [default]
10 = [project 1]
20 = [project 2]
30 = [project 3]
40 = [project 4]
50 = [project 5]
60 = [project 6]
70 = [project 7]
80 = [project 8]
90 = [project 9] |
Beta Was this translation helpful? Give feedback.
-
If I understand it right, you want an option to override the input box from rofi-script mode? This is currently not possible (if I remember right), I need to look to see how easy/hard it is to add. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm writing a custom script using rofi-script.
I'm trying to achieve same behavior like running rofi with
-filter
flag which fills input bar with preselected entry.To give more context, script will be used for renaming value entry from INI file.
Currently I'm launching two rofi consecutively where in first run an entry is selected and then in next run input bar is filled with selected entry using
-filter
flag. I'd like to avoid calling rofi twice and I've been looking at rofi-script.Is something like this possible?
Beta Was this translation helpful? Give feedback.
All reactions