Created
May 3, 2021 09:14
-
-
Save nitincodery/e63b89978ed40889a3f6a35d94452c9a to your computer and use it in GitHub Desktop.
Resize 3 Windows Side-by-Side Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Link to detailed answer.