Skip to content

Instantly share code, notes, and snippets.

@nitincodery
Created May 3, 2021 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitincodery/e63b89978ed40889a3f6a35d94452c9a to your computer and use it in GitHub Desktop.
Save nitincodery/e63b89978ed40889a3f6a35d94452c9a to your computer and use it in GitHub Desktop.
Resize 3 Windows Side-by-Side Linux
#!/bin/bash
# assign keyboard shortcut to bash thirds.sh
# run shortcut on the window to resize
# it auto cycles to the position (0)left, (1)middle, (2)right
# create a counter file to store positions
counter="thirds-counter.txt"
if [[ -f $counter ]]; then
count=$(<$counter)
else
echo "0" > $counter
fi
# determine size of the desktop
get_screen_geometry()
{
xwininfo -root | awk -F ':' '/Width/{printf "%d",$2/3}/Height/{print $2}'
}
# unmaximize the window
xdotool key 'Ctrl+Super+Down'
sleep 1
# set size of the window to one third of total to the position 0,1,2
xdotool getactivewindow windowsize $(get_screen_geometry)
xdotool getactivewindow windowmove $(get_screen_geometry | awk -v POS=$count '{printf "%d", POS*$count}') 0
# store next position to the file
count=$(((($count+1))%3))
echo "$count" > $counter
@nitincodery
Copy link
Author

Link to detailed answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment