[i3] rename.sh that can rename back to empty

This commit is contained in:
M1dgard 2018-09-15 18:07:57 +02:00
parent 7e207c402e
commit ed61ea966a
Signed by untrusted user who does not match committer: midgard
GPG key ID: 511C112F1331BBB4
2 changed files with 28 additions and 3 deletions

View file

@ -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
View 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