How to move active window to another display in XFCE

Solution 1:

XFCE does not have a built-in command that allows you to move a window to another monitor, however there is this Python script that can do that.

The script is used as:

movescreen.py <up|down|left|right|prev|next|fit> [win_id|mouse]
  • First, make sure the script's dependencies are satisfied:

    sudo apt install python xrandr xwininfo wmctrl xdotool
    
  • Download the script and move it to the folder that you want, for example ~/scripts/ (I am assuming this as the script's folder for the next steps, you may, however, use whatever you want).

  • Give executable rights to the script:

    chmod u+x ~/scripts/movescreen.py
    
  • Open Keyboard and select the Application Shortcuts tab.

  • Click the Add button at the bottom left.

  • In the Command pop-up window enter the command to move the window, using the absolute path to the script. For example, to move the window to the monitor left, enter:

    /home/<your_username>/scripts/movescreen.py left
    
  • Press OK and assign the shortcut you want, for example Ctrl+Super+Left.

  • Repeat the steps for all other directions.

The script is not perfect, but works reasonably well. Also, being built in Python means that it is relatively easy to tweak it.

Solution 2:

Managed to do it as follows:

  1. Install xdotool using:

    apt install xdotool
    
  2. Then run:

    xdotool getactivewindow getwindowgeometry
    

    with output:

    Window 69206023
      Position: 2201,251 (screen: 0)
      Geometry: 774x568
    
  3. Moving to right command:

    xdotool getactivewindow windowmove 2201 251 windowsize 774 568
    
  4. Finally just put the following in /usr/bin/moveright script and bind it on a keyboard shortcut:

    #!/bin/bash
    xdotool getactivewindow windowmove 2201 251 windowsize 774 568