Work gave me a new monitor - which is a 21:9 screen, so I would like to be able to put 3 windows side by side, but ctrl + alt + keypad shortcuts can only be used to place 2, and with this monitor those windows are almost too wide.

  • 1
    I've drafted a small script that asks for selecting 3 windows out of a list of all open windows, and will arrange them side by side. This script is still in development , very rough, but I'd like to know what you think of this so far. Script source is here Keep in mind, you need to have xdotool installed in order for this to work Jun 22, 2016 at 5:06
  • @serg That kinda works, but what I really want is just a shortcut to take up 1/3 of the screen, and I will need to move windows too often to type commands.
    – tomjen
    Jun 22, 2016 at 6:51
  • Seems like I overthought this :) So Ctrl + Super + Right moves currently focused window right , we know that . What you want is something like Ctrl + Super + 1 to position window 1/3 left , ctrl + Super + 2 to position 1/3 in the middle, and Ctrl + super + 3 to position 1/3 to the right. Is that correct ? Jun 22, 2016 at 7:15
  • How's this ? gist.github.com/SergKolo/b4ca47e820614ea4f6b3e1a4295fa152 This can be made into a 3 different shortcuts Jun 22, 2016 at 7:30
  • Is there some where to set a shortcut in bash? Anyway you should post that link as a reply and I will accept the answer.
    – tomjen
    Jun 22, 2016 at 8:34

2 Answers 2



The script below serves to resize windows to 1/3 of the screen width, and place them to either left, center, or right position.There are numeric options, 0 for left, 1 for center, and 2 for right.

The script relies on xdotool so make sure to install that with sudo apt-get install xdotool.

In Unity, the script must operate on unmaximized windows. The reason for that is because Unity locks windows in place when they are maximized, making them not respond to whatever command xdotool issues.

Note: This script will be updated and refined over time. I will likely add it to my personal github repository but as of right now it exists as a gist

Setting Shortcut

Go to System Settings -> Keyboard -> Shortcuts -> Custom and click on the + button in the lower left corner to create new entry. Provide a custom name and full path to script ( or bash /path/to/script ARG ) as in my example .

enter image description here

Save it, and click on the right field . You will be prompted to press keys that you want to correspond to this shortcut. I've set it to Ctrl Super 1.

enter image description here

You now have a shortcut for placing window to the left. Repeat the same steps for center and right shortcut.

Script Source

# run script like so:  bash thirds.sh NUMBER
# where NUMBER is 0,1 or 2
# 0 is left, 1 is center, 2 is right
   # determine size of the desktop
   xwininfo -root | \
   awk  -F ':' '/Width/{printf "%d",$2/3}/Height/{print $2}' 
xdotool getactivewindow windowsize $(get_screen_geometry )

xdotool getactivewindow windowmove \
$(get_screen_geometry | awk -v POS=$1  '{ printf "%d ", POS*$1  }'  ) 0
  • 1
    Worked like a charm! Thank you <3
    – Miladiouss
    Nov 18, 2020 at 2:25
  • I was looking for that solution for two years. Thank you! Jan 9, 2021 at 22:53
  • This didn't work for me until I replaced the command with sh -c "sh ~/thirds.sh 0"
    – aviator
    Jun 6, 2022 at 17:05

The script below is modified version of answer by Sergiy Kolodyazhnyy to resize windows to 1/3 of the screen width, and place them to either left, middle or right position with single shortcut and works on maximized windows as well.

The script relies on xdotool so make sure to install that with sudo apt-get install xdotool.

Add Keyboard Shortcut to the command bash thirds.sh (with no arguements).

Here's the gist of it too.

# 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
if [[ -f $counter ]]; then
  echo "0" > $counter

# determine size of the desktop
   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
echo "$count" > $counter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.