Xfce Forum

Sub domains
 

You are not logged in.

#1 2015-08-12 12:13:50

ohayden
Member
Registered: 2015-08-12
Posts: 2

[Solved] Wrap mouse at end of screens

I'm using Debian 8.1 with XFCE 4.10. I have 4 monitors on two NVIDIA cards. The only way I could get it to work is with two X screens. I wanted a single X screen, but oh well.

My main issue is that when I'm on X screen 0 monitor 0 and I move my mouse to the left it doesn't wrap the mouse to X screen 1 monitor 3. Basically I simply want to be able to wrap the mouse around on the desktop between X screen 0 and 1. Moving right from X screen 0 to 1 works fine. It just between the extreme left of X screen 0 and the extreme right of X screen 1.

Any ideas?

Offline

#2 2015-08-12 14:33:06

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,481

Re: [Solved] Wrap mouse at end of screens

Hello and welcome.

The best you can do with built-in Xfce functionality is to enable workspace wrapping with the mouse (Settings Manager >> Window Manager >> Wrap workspaces when reaching the screen edge >> "with the mouse pointer" (enabled). This will actually wrap the mouse from the far right of the 4th monitor to the far left of the first monitor on the next workspace.

Otherwise, you'll need to use a third-party app like synergy or taralli (note: I have used neither and do not know if they will work for you. By the description, they seem possible solutions).

A third option is to write a script of your own that monitors mouse position and when it reaches a certain edge it is programmatically moved to the desired edge. Something like (requires xdotool):

#!/bin/bash

while true 
do
    #get mouse position
    mdata=`xdotool getmouselocation`

    #extract x/y coordinates
    mx=`echo "$mdata"|cut -f1 -d' '|cut -d: -f2`
    my=`echo "$mdata"|cut -f2 -d' '|cut -d: -f2`

    #check for position and if at either left or right edge, move the mouse
    if [ $mx == 2964 ]; then
        xdotool mousemove 1 $my 
    elif [ $mx == 0 ]; then
        xdotool mousemove 2963 $my
    fi

done

..you'll need to change the 2963/2964 values to match your screen edges.

Also keep in mind that I tested this on my multimonitor setup with only one screen, so you'll probably need to adjust this to account for the multiple screen setups (hint: "getmouselocation" provides a source screen value and "mousemove" allows you to specify a destination screen value)


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2015-08-12 15:48:47

ohayden
Member
Registered: 2015-08-12
Posts: 2

Re: [Solved] Wrap mouse at end of screens

Thank you very much! The xdotool solution is brilliant and simple! I tweaked the script slightly so that it should work for most people regardless of the number of screens. Here it is just in case someone else wants to use this solution:

#!/bin/bash

#calculate total width of all screens
let "totalWidth = -1"
let "numOfScreens = -1"
for size in $(xrandr | grep -w connected  | awk -F'[ +]' '{print $3}' | cut -d x -f 1)
do
  let "totalWidth += $size"
  let "numOfScreens += 1"
done

while true 
do
    #get mouse position
    mdata=`xdotool getmouselocation`

    #extract x/y coordinates
    mx=`echo "$mdata"|cut -f1 -d' '|cut -d: -f2`
    my=`echo "$mdata"|cut -f2 -d' '|cut -d: -f2`

    #check for position and if at either left or right edge, move the mouse
    if [ $mx == $totalWidth ]; then
        xdotool mousemove 1 $my 
    elif [ $mx == 0 ]; then
	xdotool mousemove --screen $numOfScreens $totalWidth $my
    fi
done

Offline

#4 2015-08-12 16:07:54

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,481

Re: [Solved] Wrap mouse at end of screens

Thank you for sharing your final solution.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.006 seconds, 7 queries executed - Memory usage: 535.3 KiB (Peak: 536.15 KiB) ]