Skip to content

Instantly share code, notes, and snippets.

@mantono
Last active October 16, 2017 14:06
Show Gist options
  • Save mantono/fc1eb2f52a26e2e87975ee45de97a612 to your computer and use it in GitHub Desktop.
Save mantono/fc1eb2f52a26e2e87975ee45de97a612 to your computer and use it in GitHub Desktop.
Move all i3 workspaces to connected monitor
#!/bin/bash
MONITORS=$(xrandr|grep -c " connected")
if [[ "$MONITORS" == 1 ]]
then
xrandr --output eDP-1 --primary
for i in {1..10}
do
i3-msg workspace $i
i3-msg move workspace to output $(xrandr|grep connected|grep -v disconnected|cut -d " " -f 1)
done
elif [[ "$MONITORS" == 2 ]]
then
xrandr --output DP-1 --primary
for i in {1..9}
do
i3-msg workspace $i
i3-msg move workspace to output $(xrandr|grep connected|grep -v disconnected|cut -d " " -f 1|tail -n 1)
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment