From 1303e21f431bc49bba6dc275053d516da0392e54 Mon Sep 17 00:00:00 2001 From: Urbain Vaes Date: Sat, 19 Dec 2015 16:55:46 +0000 Subject: Fix script for i3 workspaces --- bin/helper_workspace | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 bin/helper_workspace (limited to 'bin/helper_workspace') 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 -- cgit v1.2.3