summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrbain Vaes <urbain@vaes.uk>2015-12-19 16:55:46 +0000
committerUrbain Vaes <urbain@vaes.uk>2015-12-19 16:55:46 +0000
commit1303e21f431bc49bba6dc275053d516da0392e54 (patch)
tree79bc4d02a43a13828b703383404cbc1745a60aff
parent64cfb306cc543fd28d2cb3ce7adadad15a8d96e6 (diff)
Fix script for i3 workspaces
-rw-r--r--.i3/config45
-rw-r--r--.vim/vimrc1
-rwxr-xr-xbin/helper_workspace19
-rwxr-xr-xbin/move_workspace19
-rwxr-xr-xbin/workspace24
5 files changed, 78 insertions, 30 deletions
diff --git a/.i3/config b/.i3/config
index d0606ed..ea96bd9 100644
--- a/.i3/config
+++ b/.i3/config
@@ -85,28 +85,32 @@ bindsym $mod+Shift+minus move scratchpad
bindsym $mod+minus scratchpad show
# switch to workspace
-bindsym $mod+ampersand workspace 1
-bindsym $mod+bracketleft workspace 2
-bindsym $mod+braceleft workspace 3
-bindsym $mod+braceright workspace 4
-bindsym $mod+parenleft workspace 5
-bindsym $mod+equal workspace 6
-bindsym $mod+asterisk workspace 7
-bindsym $mod+parenright workspace 8
-bindsym $mod+plus workspace 9
-bindsym $mod+bracketright workspace 10
+bindsym $mod+ampersand exec workspace n 1
+bindsym $mod+bracketleft exec workspace n 2
+bindsym $mod+braceleft exec workspace n 3
+bindsym $mod+braceright exec workspace n 4
+bindsym $mod+parenleft exec workspace n 5
+bindsym $mod+equal exec workspace n 6
+bindsym $mod+asterisk exec workspace n 7
+bindsym $mod+parenright exec workspace n 8
+bindsym $mod+plus exec workspace n 9
+bindsym $mod+bracketright exec workspace n 10
# move focused container to workspace
-bindsym $mod+Shift+ampersand move container to workspace 1
-bindsym $mod+Shift+bracketleft move container to workspace 2
-bindsym $mod+Shift+braceleft move container to workspace 3
-bindsym $mod+Shift+braceright move container to workspace 4
-bindsym $mod+Shift+1 move container to workspace 5
-bindsym $mod+Shift+equal move container to workspace 6
-bindsym $mod+Shift+asterisk move container to workspace 7
-bindsym $mod+Shift+2 move container to workspace 8
-bindsym $mod+Shift+plus move container to workspace 9
-bindsym $mod+Shift+bracketright move container to workspace 10
+bindsym $mod+Shift+ampersand exec workspace m 1 m
+bindsym $mod+Shift+bracketleft exec workspace m 2
+bindsym $mod+Shift+braceleft exec workspace m 3
+bindsym $mod+Shift+braceright exec workspace m 4
+bindsym $mod+Shift+1 exec workspace m 5
+bindsym $mod+Shift+equal exec workspace m 6
+bindsym $mod+Shift+asterisk exec workspace m 7
+bindsym $mod+Shift+2 exec workspace m 8
+bindsym $mod+Shift+plus exec workspace m 9
+bindsym $mod+Shift+bracketright exec workspace m 10
+
+# Keybindings for create and move
+bindsym $mod+n exec workspace n
+bindsym $mod+m exec workspace m
# reload the configuration file
bindsym $mod+Shift+c reload
@@ -155,7 +159,6 @@ bindsym $mod+period workspace next
# Programs shortcuts
bindsym $mod+b exec uzbl-browser
bindsym $mod+at exec chromium-browser
-bindsym $mod+n exec workspace
# Configuration
# bindsym F1 exec $HOME/.xinitrc
diff --git a/.vim/vimrc b/.vim/vimrc
index 951f1b0..96aa233 100644
--- a/.vim/vimrc
+++ b/.vim/vimrc
@@ -16,6 +16,7 @@ Plug 'junegunn/vim-pseudocl'
Plug 'junegunn/vim-oblique'
Plug 'justinmk/vim-sneak'
Plug 'klen/python-mode'
+Plug 'ledger/vim-ledger'
Plug 'lervag/vimtex'
Plug 'majutsushi/tagbar'
Plug 'mileszs/ack.vim', { 'on' : 'Ack' }
diff --git a/bin/helper_workspace b/bin/helper_workspace
new file mode 100755
index 0000000..77be45d
--- /dev/null
+++ b/bin/helper_workspace
@@ -0,0 +1,19 @@
+#!/bin/zsh
+
+workspaces=$(i3-msg -t get_workspaces | grep -Po '"name":.*?[^\\]"' | sed 's/"name":"\([^"]\+\)"/\1/g')
+
+if [[ ! -z $1 ]]; then
+ target=$(echo $workspaces | grep "$1")
+ [[ -z $target ]] && target=$1
+else
+ used_numbers=$(echo $workspaces | awk 'BEGIN { FS = ":" } ; { print $1 }')
+ max_number=$(echo $used_numbers | tail -1)
+ lowest_gap=$(echo $used_numbers | awk '$1!=p+1{print p+1}{p=$1}' | head -1)
+ [[ -z $lowest_gap ]] && new_number=$(($max_number + 1)) || new_number=$lowest_gap
+
+ target=$(echo $workspaces | dmenu -i -sf green -p "Go to workspace:")
+ [[ -z $target ]] && exit
+ [[ ! $target = [0-9]* ]] && target=$new_number:$target
+fi
+
+echo $target
diff --git a/bin/move_workspace b/bin/move_workspace
new file mode 100755
index 0000000..ab926e0
--- /dev/null
+++ b/bin/move_workspace
@@ -0,0 +1,19 @@
+#!/bin/zsh
+
+workspaces=$(i3-msg -t get_workspaces | grep -Po '"name":.*?[^\\]"' | sed 's/"name":"\([^"]\+\)"/\1/g')
+
+if [[ ! -z $1 ]]; then
+ target=$(echo $workspaces | grep "$1")
+ [[ -z $target ]] && target=$1
+else
+ used_numbers=$(echo $workspaces | awk 'BEGIN { FS = ":" } ; { print $1 }')
+ max_number=$(echo $used_numbers | tail -1)
+ lowest_gap=$(echo $used_numbers | awk '$1!=p+1{print p+1}{p=$1}' | head -1)
+ [[ -z $lowest_gap ]] && new_number=$(($max_number + 1)) || new_number=$lowest_gap
+
+ target=$(echo $workspaces | dmenu -i -sf green -p "Go to workspace:")
+ [[ -z $target ]] && exit
+ [[ ! $target = [0-9]* ]] && target=$new_number:$target
+fi
+
+exec i3-msg workspace $target
diff --git a/bin/workspace b/bin/workspace
index 73a4ec4..a66e0b5 100755
--- a/bin/workspace
+++ b/bin/workspace
@@ -1,14 +1,20 @@
#!/bin/zsh
workspaces=$(i3-msg -t get_workspaces | grep -Po '"name":.*?[^\\]"' | sed 's/"name":"\([^"]\+\)"/\1/g')
-# used_numbers=$(echo $workspaces | awk 'BEGIN { FS = ":" } ; { print $1 }')
-# max_number=$(echo $used_numbers | tail -1)
-# largest_gap=$(echo $used_numbers | awk '$1!=p+1{print p+1}{p=$1}')
-# [[ -z $largest_gap ]] && new_number=$(($max_number + 1)) || new_number=$largest_gap
-# target=$(echo $workspaces | dmenu -i -sf green -p "Go to workspace:")
-# [[ -z $target ]] && exit
-# [[ ! $target = [0-9]* ]] && target=$new_number:$target
+if [[ ! -z $2 ]]; then
+ target=$(echo $workspaces | grep "$2")
+ [[ -z $target ]] && target=$2
+else
+ used_numbers=$(echo $workspaces | awk 'BEGIN { FS = ":" } ; { print $1 }')
+ max_number=$(echo $used_numbers | tail -1)
+ lowest_gap=$(echo $used_numbers | awk '$1!=p+1{print p+1}{p=$1}' | head -1)
+ [[ -z $lowest_gap ]] && new_number=$(($max_number + 1)) || new_number=$lowest_gap
-target=$(echo $workspaces | dmenu -i -sf green -p "Go to workspace:")
-exec i3-msg workspace $target
+ target=$(echo $workspaces | dmenu -i -sf green -p "Go to workspace:")
+ [[ -z $target ]] && exit
+ [[ ! $target = [0-9]* ]] && target=$new_number:$target
+fi
+
+[[ $1 = 'n' ]] && cmd="workspace" || cmd="move container to workspace"
+exec i3-msg $cmd $target