[英]Changing default focused screen on awesome wm
I have a bit of a hacky setup on my laptop where I use optimus-manager
to configure my screen layout at X startup based on whether an external monitor is connected or not.我的笔记本电脑上有一些 hacky 设置,我使用
optimus-manager
在 X 启动时根据是否连接外部显示器来配置我的屏幕布局。 If it is, I only want to use the external monitor and not the laptop monitor, but because of a limitation of NVIDIA drivers, I need to leave my laptop monitor on, and just lower the backlight brightness .如果是的话,我只想用外接显示器而不是笔记本显示器,但由于NVIDIA驱动的限制,我需要让笔记本显示器保持开启状态,只是降低背光亮度。 See my
/etc/optimus-manager/xsetup-hybrid.sh
for how this works ( eDP-1
is my laptop screen, and HDMI-1-0
is my external monitor):请参阅我的
/etc/optimus-manager/xsetup-hybrid.sh
了解其工作原理( eDP-1
是我的笔记本电脑屏幕, HDMI-1-0
是我的外接显示器):
#!/bin/sh
# Everything you write here will be executed by the display manager when setting up the login screen in "hybrid" mode.
xrandr --output eDP-1 --mode 1920x1080 --pos 3000x0 --output HDMI-1-0 --primary --mode 2560x1080 --pos 0x0
if [ "$?" -ne "0" ]; then
echo "Not connected to display, don't dim internal monitor"
exit 0
fi
echo 0 | tee /sys/class/backlight/intel_backlight/brightness
Notice that eDP-1
(laptop monitor) is positioned at 3000x0
.请注意,
eDP-1
(笔记本电脑显示器)位于3000x0
。 I've done this to keep the screens far enough apart so that my mouse can't accidentally stray from my external monitor's screen into my laptop monitor's screen.我这样做是为了使屏幕保持足够远的距离,这样我的鼠标就不会意外地从外接显示器的屏幕偏离到笔记本电脑显示器的屏幕上。
This works pretty well, but for some reason every time I log into awesome (or anytime I change the screen layout with xrandr
for that matter), awesome focuses the laptop monitor screen by default, even though xrandr
is specifying the external monitor screen as --primary
.这工作得很好,但出于某种原因,每次我登录到 awesome (或者任何时候我用
xrandr
更改屏幕布局时),即使xrandr
将外部监视器屏幕指定为--primary
的。
How can I change this behaviour so that my external monitor screen is focused by default if that monitor is connected, falling back to my laptop screen if it isn't?如果连接了该显示器,我如何更改此行为,以便我的外部显示器屏幕默认聚焦,如果没有,则退回到我的笔记本电脑屏幕?
You could warp the mouse cursor to the primary screen in your config:您可以将鼠标 cursor 扭曲到配置中的主屏幕:
mouse.screen = screen.primary
The above can also be tested in an already running awesome session via awesome-client
: awesome-client 'mouse.screen = screen.primary'
.以上也可以通过
awesome-client
: awesome-client 'mouse.screen = screen.primary'
在已经运行的很棒的 session 中进行测试。
If you want to decide the pointer coordinates more precisely (the above uses the upper left corner of the screen), there is mouse.coords({ x = 42, y = 21 })
.如果你想更精确地确定指针坐标(上面使用屏幕的左上角),有
mouse.coords({ x = 42, y = 21 })
。
It's likely apps are being displayed where the mouse currently resides.很可能应用程序正在鼠标当前所在的位置显示。 You could use xdotool to ensure mouse is on desired display to begin with.
您可以使用xdotool来确保鼠标位于所需的显示器上。
#!/bin/sh
## executed by display manager during login
if [ "$?" -eq "0" ] ; then
xrandr --output eDP-1 --mode 1920x1080 --pos 3000x0 --output HDMI-1-0 --primary --mode 2560x1080 --pos 0x0
echo 0 | tee /sys/class/backlight/intel_backlight/brightness
## sudo apt install xdotool
## x, y coordinates: half of 2560x1080, so middle of main screen
xdotool mousemove 1280 540
else
## external display not plugged in
xrandr --output eDP-1 --mode 1920x1080 --primary --pos 0x0
fi
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.