20

I use a multi display workspace, I would like to have keyboard shortcut for moving an active window to another display (I don't mean workspaces). How can I achieve this in XFCE? In Unity, I was using Compiz with predefined keyboard shortcuts.

my workspace

3 Answers 3

13

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

The script is used as:

movescreen.py [-r] <up|down|left|right|prev|next|fit> [active|a] [mouse|m] [win_id]
  • 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
    

    where <your_username> is, well, your username.

  • 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 to your needs.

1
  • the tool is not perfect (if only a few pixels of a window overlap to another monitor, neither left nor right will work). but it's enough until my distro supports 4.17.2 ;) Sep 5 at 14:29
7

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
    
1
  • 1
    This is a very good & simple solution. If I may add something, there's no need to specify a windowsize XX XX parameter in the xdotool command. That way, you can use it with arbitrary windows without changing their size.
    – xgrau
    Jul 15, 2021 at 8:18
3

Since Xfce4 4.17.2 (2022 Dec) there's a proper way to do it: Window Manager -> Keyboard tab:

enter image description here

0

You must log in to answer this question.

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