首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将鼠标(和焦点)从一个屏幕移动到另一个屏幕的统一键盘快捷方式

将鼠标(和焦点)从一个屏幕移动到另一个屏幕的统一键盘快捷方式
EN

Ask Ubuntu用户
提问于 2015-07-25 13:24:31
回答 2查看 2.4K关注 0票数 7

在家里和工作中享受多监视器设置,但不知道如何在没有鼠标的情况下在单个监视器(即“屏幕”)之间移动焦点?

键盘快捷方式是切换虚拟桌面的好方法,我在ccsm中查看了各种选项,但没有想到什么。

我还查看了其他问题,如不同X屏之间的焦点切换或指向双屏口服液开关柜的链接,但所有这些问题似乎都与每个xorg.conf的单独屏幕有关。这些天,统一“只是工作”与多显示器(通过显示端口),所以这是一个尴尬的财富。

但是,任何关于如何在单个(虚拟)统一显示中导航多个(物理)屏幕的提示都是非常受欢迎的。

EN

回答 2

Ask Ubuntu用户

回答已采纳

发布于 2015-07-25 15:23:38

在屏幕之间切换并(可选)将焦点设置在(全屏)窗口

下面的脚本将切换(和“焦点”)之间的左屏幕和右屏幕,如果两个屏幕或多或少的中心-或顶部对齐,或多或少的垂直分辨率。

我假设在几乎所有的左右屏幕设置的情况下,它都能工作。

脚本

代码语言:javascript
复制
#!/usr/bin/env python3
import subprocess
# just a helper function
get = lambda cmd: subprocess.check_output(cmd).decode("utf-8")
# get the current mouse position
current = [int(n) for n in [it.split(":")[1] for it in get(["xdotool", "getmouselocation"]).split()[:2]]]
# get the x/y size of the left screen
screendata = [(s.split("x")[0], s.split("x")[1].split("+")[0]) for s in get(["xrandr"]).split() if "+0+0" in s ][0]
xy = [int(n) for n in screendata]
# see if the mouse is on the left- or right screen
if current[0] < xy[0]:
    # if the mouse currently is on the left screen, move it to the right (from the middle of the left screen)
    command = ["xdotool", "mousemove", "--sync", str(current[0]+xy[0]), str(xy[1]/2)]
else:
    # if the mouse currently is on the left screen, move it to the right (from the middle of the left screen)
    command = ["xdotool", "mousemove", "--sync", str(current[0]-xy[0]), str(xy[1]/2)]

subprocess.Popen(command)
# optional: click after the mouse move: comment out if not needed / wanted
subprocess.Popen(["xdotool", "click", "1"])

如何使用

  1. 脚本需要安装xdotool (!)sudo apt-get install xdotool
  2. 将脚本复制到一个空文件中,保存为toggle_screenloc.py
  3. 测试-通过命令运行它: python3 /path/to/toggleticloc.py
  4. 如果一切正常,将其添加到一个快捷键:选择:系统设置>“键盘”>“快捷方式”>“自定义快捷方式”。单击"+“并添加命令: python3 /path/to/toggle_creoploc.py

它到底做了什么

如果脚本正在运行,则它:

  1. xrandr command.的输出导出(左)屏幕的大小(x/y)
  2. 它通过检查(xdotool)命令:来查看鼠标在左右屏幕上的情况。

如果鼠标指针位于左侧屏幕上:

  • 它被移动到左侧屏幕的中间(垂直),水平移动到一个位置,等于当前位置+左边屏幕的宽度。

如果鼠标指针位于右侧屏幕上:

  • 行动正好相反。

随后,鼠标单击一次,在(可能的)全屏应用程序上设置焦点(可选)。

票数 7
EN

Ask Ubuntu用户

发布于 2019-04-01 17:35:04

这个存储库可能会帮助您

https://github.com/Eitol/screen_焦点_变送器

将focus_changer.py左脚本放置在固定位置(例如/ opt ),然后在设置中添加键绑定/快捷方式/热键

python3 /opt/ Focus _changer.py左转左

python3 /opt/ Focus _changer.py右转右

票数 3
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/652621

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档