如何通过向左移动光标从屏幕1移动到屏幕3,反之亦然?

如果我必须将鼠标从左侧屏幕一直移动到右侧屏幕,则距离非常大。

有没有办法虚拟连接屏幕的两侧,就像它们被安排在一个圆圈? 然后,只需将光标向左移动,我就可以从左侧屏幕移动到右侧屏幕。

用于连接屏幕的脚本“循环”

下面的脚本将按照您的描述进行; 如果鼠标触摸右侧(最近)屏幕的右边缘,则鼠标将重新出现在左侧(最近)屏幕上。 如果它触摸左侧屏幕的左侧,它将重新出现在右侧屏幕的右侧。

内置预防措施

该脚本假设屏幕以非重叠配置排列,x,但如果屏幕不是顶部对齐,或者具有不同的y分辨率,则它具有内置校正。 虽然在大多数情况下你不会遇到问题,但在下面的情况下你会这样做,除非脚本考虑到屏幕的y分辨率和/或(非)对齐的可能差异:

在此处输入图像描述

如果左侧屏幕的顶部位于右侧屏幕的顶部下方,则光标将从右上角移动到左侧屏幕的顶部。 可能不一致的底层同意

剧本

#!/usr/bin/env python3 import subprocess import time def get_screendata(): data = [s.split("+") for s in subprocess.check_output(["xrandr"]).decode("utf-8").split() \ if s.count("+") == 2] # calculate total x-size of spanning screens x_span = sum([int(item[0].split("x")[0]) for item in data]) # sort screens to find first/last screen (also for 2+ screens) data.sort(key=lambda x: x[1]) # find (possible) screen offset of first/last screen and vertical area scr_first = data[0]; shiftl = int(scr_first[2]) areal = [shiftl, shiftl+int(scr_first[0].split("x")[1])] scr_last = data[-1]; shiftr = int(scr_last[2]) arear = [shiftr, shiftr+int(scr_last[0].split("x")[1])] return (x_span, areal, arear) screendata = get_screendata() x_span = screendata[0]; areal = screendata[1]; arear = screendata[2] new_coords = [] while True: time.sleep(0.5) new_coords = [] # read the current mouse position pos = [int(s.split(":")[-1]) for s in \ subprocess.check_output(["xdotool", "getmouselocation"]).decode("utf-8").split()\ if any(["x" in s, "y" in s])] # if the mouse is on the left of the first screen if pos[0] == 0: new_coords.append(x_span-2) if pos[1] <= arear[0]: new_coords.append(arear[0]+2) elif pos[1] >= arear[1]: new_coords.append(arear[1]-2) else: new_coords.append(pos[1]) # if the mouse is on the right of the last screen elif pos[0] > x_span-2: new_coords.append(2) if pos[1] <= areal[0]: new_coords.append(areal[0]+2) elif pos[1] >= areal[1]: new_coords.append(areal[1]-2) else: new_coords.append(pos[1]) # move the mouse if new_coords: subprocess.Popen(["xdotool", "mousemove", str(new_coords[0]), str(new_coords[1])]) 

如何使用

  1. 该脚本需要xdotool

     sudo apt-get install xdotool 
  2. 将脚本复制到空文件中,将其另存为circular_mouse.py
  3. 通过在终端中运行来测试脚本:

     python3 /path/to/circular_mouse.py 

    您应该能够向右或向左移动无限鼠标,在屏幕上循环。

  4. 如果一切正常,请将其添加到启动应用程序:Dash> Startup Applications>添加命令:

     /bin/bash -c "sleep 15 && python3 /path/to/circular_mouse.py" 

你可以尝试使用Taralli 。 您需要编辑map_beef.c以用于您自己的显示器设置。

或者,@ ohayden在这里发布了一个bash脚本,可以自定义以执行您想要的操作。 要使用它,您需要通过运行来安装xdotool

 sudo apt-get install xdotool 

我只有一台显示器,所以我无法尝试这些可能的解决方案。