Commit 393d2bf9 authored by Maxime Bombar's avatar Maxime Bombar
Browse files

Improve swapping of workspaces

parent ef49afd5
#!/bin/sh
# Slide current workspace to the left on i3-bar
# Slide current workspace to the right on i3-bar
name=$(i3-msg -t get_outputs | jq | grep 'current_workspace' | awk '{split($0,a,": "); print a[2]}' | cut -d : -f 2 | cut -d \" -f 1 | head -n 1)
number=$(i3-msg -t get_outputs | jq | grep 'current_workspace' | awk '{split($0,a,": "); print a[2]}' | cut -d : -f 1 | cut -d \" -f 2 | head -n 1)
curworkspace=$(i3-msg -t get_outputs | jq | grep 'current_workspace' | awk '{split($0,a,": "); print a[2]}' | head -n 1)
prevworkspace=$(i3-msg -t get_workspaces | jq | grep name | grep $curworkspace -C 1 | cut -d , -f 1 | awk '{split($0,a,": "); print a[2]}' | head -n 1)
if [-z $number]; then number=-1; fi
# current workspace
curnumber=$(echo $curworkspace | cut -d : -f 1 | cut -d \" -f 2);
curname=$(echo $curworkspace | cut -d : -f 2 | cut -d \" -f 1);
i3-msg rename workspace to "$(expr $number - 1):$name"
# prev workspace
prevnumber=$(echo $prevworkspace | cut -d : -f 1 | cut -d \" -f 2);
prevname=$(echo $prevworkspace | cut -d : -f 2 | cut -d \" -f 1);
# swap workspaces
i3-msg rename workspace $prevworkspace to $curnumber:$prevname;
i3-msg rename workspace $curworkspace to $prevnumber:$curname;
......@@ -3,9 +3,17 @@
# Slide current workspace to the right on i3-bar
name=$(i3-msg -t get_outputs | jq | grep 'current_workspace' | awk '{split($0,a,": "); print a[2]}' | cut -d : -f 2 | cut -d \" -f 1 | head -n 1)
number=$(i3-msg -t get_outputs | jq | grep 'current_workspace' | awk '{split($0,a,": "); print a[2]}' | cut -d : -f 1 | cut -d \" -f 2 | head -n 1)
curworkspace=$(i3-msg -t get_outputs | jq | grep 'current_workspace' | awk '{split($0,a,": "); print a[2]}' | head -n 1)
nextworkspace=$(i3-msg -t get_workspaces | jq | grep name | grep $curworkspace -C 1 | cut -d , -f 1 | awk '{split($0,a,": "); print a[2]}' | tail -n 1)
if [-z $number]; then number=-1; fi
# current workspace
curnumber=$(echo $curworkspace | cut -d : -f 1 | cut -d \" -f 2);
curname=$(echo $curworkspace | cut -d : -f 2 | cut -d \" -f 1);
i3-msg rename workspace to "$(expr $number + 1):$name"
# next workspace
nextnumber=$(echo $nextworkspace | cut -d : -f 1 | cut -d \" -f 2);
nextname=$(echo $nextworkspace | cut -d : -f 2 | cut -d \" -f 1);
# swap workspaces
i3-msg rename workspace $nextworkspace to $curnumber:$nextname;
i3-msg rename workspace $curworkspace to $nextnumber:$curname;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment