From ed61ea966a19800726b33dd8694a99fe38176c60 Mon Sep 17 00:00:00 2001 From: M1dgard Date: Sat, 15 Sep 2018 18:07:57 +0200 Subject: [PATCH] [i3] rename.sh that can rename back to empty --- i3/config | 4 +--- i3/rename.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100755 i3/rename.sh 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