From 481bb2c26f2d9aa52e5c8dec8dfc64af7bbff049 Mon Sep 17 00:00:00 2001 From: Urbain Vaes Date: Thu, 7 Sep 2017 12:28:43 +0100 Subject: [i3] Add script to move workspace --- bin/bin/move_workspace | 21 +++++++++++++++++++++ i3/.config/i3/config | 6 ++++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100755 bin/bin/move_workspace diff --git a/bin/bin/move_workspace b/bin/bin/move_workspace new file mode 100755 index 0000000..d7944de --- /dev/null +++ b/bin/bin/move_workspace @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +wkspces=$(i3-msg -t get_workspaces | grep -Po '"name":.*?[^\\]"' | sed 's/"name":"\([^"]\+\)"/\1/g') +focused=$(i3-msg -t get_workspaces | grep -Po '{[^}]*"focused":true[^}]*}' | sed 's/.*"name":"\([^"]*\)".*$/\1/g') + +focused_number=${focused%%:*} +focused_name=${focused#*:} + +[[ $1 = 'n' ]] && new_number=$((focused_number + 1)) +[[ $1 = 'p' ]] && new_number=$((focused_number - 1)) + +next=$(echo "${wkspces}" | grep "^${new_number}") + +i3-msg rename workspace to ${new_number}:${focused_name} + +if [[ ! -z "${next// }" ]]; then + name_next=${next#*:} + i3-msg workspace "${next}" + i3-msg rename workspace to ${focused_number}:${name_next} + i3-msg workspace "${new_number}:${focused_name}" +fi diff --git a/i3/.config/i3/config b/i3/.config/i3/config index 76c5cba..7efcc97 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -160,6 +160,10 @@ bindsym $mod+m bar mode toggle bindsym $mod+Tab workspace back_and_forth bindsym $mod+comma workspace prev bindsym $mod+period workspace next +bindsym $mod+Shift+comma exec $HOME/bin/move_workspace p +bindsym $mod+Shift+period exec $HOME/bin/move_workspace n +bindsym $mod+n exec $HOME/bin/workspace n +bindsym $mod+Shift+n exec $HOME/bin/workspace m # Programs shortcuts bindsym $mod+b exec --no-startup-id qutebrowser @@ -180,8 +184,6 @@ bindsym F11 exec --no-startup-id feh --bg-fill --randomize /usr/share/background # Custom scripts bindsym XF86AudioPlay exec $HOME/bin/touchpad -bindsym $mod+n exec $HOME/bin/workspace n -bindsym $mod+Shift+n exec $HOME/bin/workspace m bindsym $mod+semicolon exec --no-startup-id $HOME/bin/run bindsym $mod+e exec --no-startup-id $HOME/bin/tmux_attach bindsym $mod+o exec --no-startup-id $HOME/bin/references -- cgit v1.2.3