I am running Xubuntu 11.10 with a dual monitor setup. I am looking to create a keystroke (maybe CTRL + ALT + SPACE which will allow me send a selected window to the next monitor.

In GNOME there is a package called swapmonitor which is capable of sending the window to the other monitor. Calling this program with a keystroke achieves the same effect.

How is this done in XFCE/Xubuntu?

  • Do you not have access to swapmonitor under Xubuntu? Or are you asking how to set a keyboard shortcut for it? Sep 17, 2012 at 21:02
  • It doesnt seem to work on XFCE. Although I would like to know what options are out there.
    – boffin
    Sep 17, 2012 at 22:55
  • How do you have the multiple monitors set up? As a large virtual screen, or separate X displays? Are you using nvidia twinview?
    – Keith
    Sep 18, 2012 at 2:46
  • It is TwinView. I have an old Nvidia GeForce card with 2 Dell 19" monitors
    – boffin
    Sep 18, 2012 at 2:54

4 Answers 4


This was posted a while ago and I am sure you have gotten your answer already, but for those who haven't.

Run these commands

sudo apt-get install xdotool
sudo apt-get install wmctrl

Then download the bash script from the following link (credit to jc00ke) https://github.com/jc00ke/move-to-next-monitor

Personally, I have a directory in my root where I store all my personal scripts. However, where you download it is really up to you. Change it to have permissions so you can execute. For example, save the scripts as move-to-next-monitor.sh and then execute the following

chmod 755 move-to-next-monitor.sh
  1. settings manager -> keyboard -> application shortcuts
  2. Click Add
  3. Click Open and direct it to your script
  4. Assign a keyboard shortcut to it and voilà!

You now have a keyboard shortcut to switch a window from 1 screen to another. I am not sure how it works with more than 2 screens.

  • The linked script had this issue for me: github.com/jc00ke/bin/issues/1 Jun 17, 2016 at 23:27
  • 1
    Working okay for me so far with Mint 17.3 and xfce 4.12, ati chipset video card and three monitors . Not seeing thejoshwolfe's maximize issue on my system. Thanks for the tips!
    – ether_joe
    Aug 12, 2016 at 18:34
  • 1
    @thejoshwolfe I have added my version of the script that solves the maximize issue for me.
    – jbrock
    Nov 13, 2016 at 3:16
  • 1
    @ether_joe I have added my version of the script that may benefit you given you have three monitors.
    – jbrock
    Nov 13, 2016 at 3:17
  • I am in xfce, and this thing is evil. It will only move the window form the left monitor to the right, and it put my desktop in a really weird state once.
    – Sava B.
    Aug 6, 2018 at 4:48

I have made some changes to the above script mentioned, originally authored by jc00ke.

  • Mine is set up for three monitors.
  • It maintains whether the window was maximized or not.
  • It is used to move the window left or right with the usage script-name -l and script-name -r respectively.
  • If you have two monitors you would use script-name -a.
  • I added a fix where Chromium apps when minimized are very small and would not maximize again on the new monitor.
    I corresponded with jc00ke. While this works great on Xfce he said he had issues with his script in Unity. Of course other desktop environments such as Unity would not need this script because such options are built in to the window manager.
    To use the script make it executable chmod +x script-name and install the following two programs, sudo apt install xdotool wmctrl.
# Move the current window to the next monitor.
# Also works only on one X screen (which is the most common case).
# Props to
# http://icyrock.com/blog/2012/05/xubuntu-moving-windows-between-monitors/
# Unfortunately, both "xdotool getwindowgeometry --shell $window_id" and
# checking "-geometry" of "xwininfo -id $window_id" are not sufficient, as
# the first command does not respect panel/decoration offsets and the second
# will sometimes give a "-0-0" geometry. This is why we resort to "xwininfo".

screen_width=$(xdpyinfo | awk -F" |x" '/dimensions:/ { print $7 }')
screen_height=$(xdpyinfo | awk -F" |x" '/dimensions:/ { print $8 }')
window_id=$(xdotool getactivewindow)

case $1 in
    -l )
        display_width=$((screen_width / 3 * 2))
    -r )
        display_width=$((screen_width / 3))
    -a )
        display_width=$((screen_width / 2))

# Remember if it was maximized.
window_state=$(xprop -id $window_id _NET_WM_STATE | awk '{ print $3 }')

# Un-maximize current window so that we can move it
wmctrl -ir $window_id -b remove,maximized_vert,maximized_horz

# Read window position
x=$(xwininfo -id $window_id | awk '/Absolute upper-left X:/ { print $4 }')
y=$(xwininfo -id $window_id | awk '/Absolute upper-left Y:/ { print $4 }')

# Subtract any offsets caused by window decorations and panels
x_offset=$(xwininfo -id $window_id | awk '/Relative upper-left X:/ { print $4 }')
y_offset=$(xwininfo -id $window_id | awk '/Relative upper-left Y:/ { print $4 }')
x=$((x - x_offset))
y=$((y - y_offset))

# Fix Chromium app view issue of small un-maximized size
width=$(xdotool getwindowgeometry $window_id | awk -F" |x" '/Geometry:/ { print $4 }')
if [ "$width" -lt "150" ]; then
  display_width=$((display_width + 150))

# Compute new X position
new_x=$((x + display_width))
# Compute new Y position
new_y=$((y + screen_height))

# If we would move off the right-most monitor, we set it to the left one.
# We also respect the window's width here: moving a window off more than half its width won't happen.
if [ $((new_x + width / 2)) -gt $screen_width ]; then
  new_x=$((new_x - screen_width))

height=$(xdotool getwindowgeometry $window_id | awk -F" |x" '/Geometry:/ { print $5 }')
if [ $((new_y + height / 2)) -gt $screen_height ]; then
  new_y=$((new_y - screen_height))

# Don't move off the left side.
if [ $new_x -lt 0 ]; then

# Don't move off the bottom
if [ $new_y -lt 0 ]; then

# Move the window
xdotool windowmove $window_id $new_x $new_y

# Maintain if window was maximized or not
if [[ "${window_state}" == _NET_WM_STATE_MAXIMIZED* ]]; then
    wmctrl -ir $window_id -b add,maximized_vert,maximized_horz
  • does this work with full-screen aplications like games?
    – brett
    Feb 2, 2020 at 16:51
  • I do not game, but I just put YouTube in full-screen and then xfce4-terminal. Neither worked. However, it seems the Python script by calandoa listed here works with full-screen. Also, wmctrl has a remove full-screen option that could be added to my script above.
    – jbrock
    Feb 3, 2020 at 14:34
  • This one doesn't maintain the same relative position on the screen - I have two 1080p monitors
    – kennyB
    Oct 21, 2020 at 2:34
  • 1
    @kennyB Thank you for bringing this to my attention. I had updated this recently with something that did not work, and I did not realize it. I just logged into Xfce, and I disabled my third monitor. Now script-name -a is working just fine for me (two 1080p monitors). If the window is maximized it is preserved and the same if it is not maximized. Please let me know if it still does not work on your end. Thanks!
    – jbrock
    Oct 22, 2020 at 19:38

I also created my own python script to move windows across monitors.



movescreen.py <up|down|left|right>

Interesting features:

  • handle the 4 directions
  • handle some special cases like windows overlapping on several monitors
  • restore independently fullscreen, maximized horizontally and vertically states
  • debugging or adding new features easy with python.

An other alternative which does not rely on any "binary" dependency (like xdotool or wmctrl): https://github.com/AlexisBRENON/ewmh_m2m

  • You can install it with pip (no need to copy it manually, make it executable, etc.)
  • It handle multiple screens with different layouts (horizontal, vertical, mixed)
  • Keep window/screen ratio when moving between screens of different sizes
  • Restore maximized states (horizontal, vertical)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .