Answers:
今天,我对此问题表示赞同,所以我发布了我一直使用了一年多的解决方案,对此感到非常满意。
步骤1:制作bash脚本(例如,将其写入~/swap.sh
并使其可执行)以将焦点设置到另一个显示中间的窗口:
#!/bin/bash
getwindowat() {
# move mouse to coordinates provided, get window id beneath it, move mouse back
eval `xdotool mousemove $1 $2 getmouselocation --shell mousemove restore`
echo $WINDOW
}
# get active app
active=`xdotool getactivewindow`
# get coordinates of an active app
eval `xdotool getwindowgeometry --shell $active`
# if left border of an app is less than display width
# (e.g. one display is 1920px wide, app has x = 200 - means it's 200px to the right from the left border of left monitor
# if it has x = 1920 or more, it's on the right window), it's on screen 0, and we need to focus to screen 1, otherwise to screen 0
(( $X >= $WIDTH )) && focustoscreen=0 || focustoscreen=1;
# get coordinates of the middle of the screen we want to switch
searchx=$[ ($WIDTH / 2) + $focustoscreen * $WIDTH ]
searchy=$[ $HEIGHT / 2 ]
# get window in that position
window=`getwindowat $searchx $searchy`
# activate it
xdotool windowactivate $window
第2步:添加键盘快捷方式来调用此脚本,我将 Super-Tab
步骤3:使用快捷方式像老板一样切换显示
mousemove restore
从eval中删除来实现这一点,因此它是“ eval`xdotool mousemove $ 1 $ 2 getmouselocation --shell`”
sh swap.sh
,但出现错误消息:swap.sh:17:swap.sh:288:找不到swap.sh:20:swap.sh:语法错误:“(”意外,创建了文本带有=作为标题的文件,什么都没有,谢谢!
bash swap.sh
xrandr --rotate
),但xdotool不使用旋转,并且我不知道如何检测。如果焦点在旋转的显示器中,则我需要使用两次击键而不是一次。
该存储库可能会帮助您
https://github.com/Eitol/screen_focus_changer
您将focus_changer.py左脚本放置在固定位置(例如,/ opt),然后在设置中添加快捷键/快捷键/热键
python3 /opt/focus_changer.py left#焦点向左
python3 /opt/focus_changer.py right#向右聚焦