[i3] rename.sh that can rename back to empty
This commit is contained in:
parent
7e207c402e
commit
ed61ea966a
2 changed files with 28 additions and 3 deletions
|
@ -396,9 +396,7 @@ mode "workspace" {
|
||||||
|
|
||||||
bindsym $mod+s mode workspace
|
bindsym $mod+s mode workspace
|
||||||
|
|
||||||
bindsym $mod+shift+S exec i3-input -F \
|
bindsym $mod+shift+S exec $HOME/.config/i3/rename.sh
|
||||||
'rename workspace to "'$(i3-msg -t get_workspaces | jq '.[] | select(.focused==true).num')': %s"' \
|
|
||||||
-P 'Rename workspace to '$(i3-msg -t get_workspaces | jq '.[] | select(.focused==true).num')': '
|
|
||||||
|
|
||||||
|
|
||||||
# Monitor stuff {{{2
|
# Monitor stuff {{{2
|
||||||
|
|
27
i3/rename.sh
Executable file
27
i3/rename.sh
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cur_ws="$(i3-msg -t get_workspaces | jq '.[] | select(.focused==true)')"
|
||||||
|
cur_ws_number="$(echo "$cur_ws" | jq '.num')"
|
||||||
|
|
||||||
|
cur_ws_name="$(echo "$cur_ws" | jq --raw-output '.name')"
|
||||||
|
# Strip workspace number from name
|
||||||
|
if [[ $cur_ws_name == [0-9] ]]; then
|
||||||
|
cur_ws_name=""
|
||||||
|
else
|
||||||
|
cur_ws_name="${cur_ws_name#[0-9]:}"
|
||||||
|
cur_ws_name="${cur_ws_name# }"
|
||||||
|
fi
|
||||||
|
|
||||||
|
newname="$(
|
||||||
|
rofi -dmenu \
|
||||||
|
-p "rename workspace $cur_ws_number:" ||
|
||||||
|
echo "$cur_ws_name"
|
||||||
|
)"
|
||||||
|
|
||||||
|
echo "renaming to \`$newname\`"
|
||||||
|
|
||||||
|
if [[ -z $newname ]]; then
|
||||||
|
i3-msg "rename workspace to \"$cur_ws_number\""
|
||||||
|
else
|
||||||
|
i3-msg "rename workspace to \"$cur_ws_number: ${newname//"/\\"}\""
|
||||||
|
fi
|
Loading…
Reference in a new issue