diff --git a/i3/config b/i3/config index 2ffff52..b9676bf 100644 --- a/i3/config +++ b/i3/config @@ -396,9 +396,7 @@ mode "workspace" { bindsym $mod+s mode workspace -bindsym $mod+shift+S exec i3-input -F \ - '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')': ' +bindsym $mod+shift+S exec $HOME/.config/i3/rename.sh # Monitor stuff {{{2 diff --git a/i3/rename.sh b/i3/rename.sh new file mode 100755 index 0000000..2847a87 --- /dev/null +++ b/i3/rename.sh @@ -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