每次我把我的三个外部显示器从我的笔记本上断开,或者当我把它们插回电脑时,所有的分辨率和扩展的桌面设置都会变得一团糟。我将不得不改变设置,以使它再次正确。
我在Ubuntu 16.04上使用gnome 3.18.5。我有英特尔高清图形530和英伟达960米与英伟达驱动375.39版。我还安装了gnome shell扩展,名为“fix监视器”,它确实解决了一些问题,比如windows只在三个监视器中的两个之间移动以及窗口移动快捷键。
无论如何,我想要做的是让设置在插入所有三个监视器时保存,这样我就可以运行一个脚本或设置,这样它就可以立即加载我想要的设置,甚至可能在检测到三种显示器时自动发生这种情况。我应该补充一点,我总是以同样的方式插入显示器。
同样困扰我的是,我启用了这张壁纸,它可以覆盖所有三台显示器,但当它们断开时,壁纸就会变成笔记本电脑显示器上的一条细线,而剩下的屏幕则变成黑色。在这种情况下,我只想看到墙纸的中间部分,或者当外部显示器断开时,可能会有另一个壁纸自动加载。我希望有人能帮助我,或以正确的方式指导我,使之成为更好的体验。
我确实找到了一个名为disper的命令行工具,我已经阅读了手册页,并尝试了许多命令,但我认为它不能做我想做的事情。
我的壁纸之路是:
/home/olm/Pictures/Wallpapers/3monitorwallpaper.jpg /home/olm/Pictures/Wallpapers/1monitorwallpaper.jpg
发布于 2017-03-20 18:45:35
如果连接了四个屏幕,
)
下面的脚本是这一个的编辑版本。
它每5秒检查一次连接屏幕的数量。如果数字发生变化,连接屏幕的总数为4,则运行我们在注释(S)中找到的xrandr
命令。
four_screens.py
#!/usr/bin/env python3
import subprocess
import time
#--- set both commands (connect / disconnect) below
connect_command = "xrandr --output DP-2 --pos 0x0 --mode 1920x1200 "\
"&& xrandr --output HDMI-0 --pos 1920x0 --mode 1920x1200 "\
"&& xrandr --output DP-3 --pos 3840x0 --mode 1920x1200 "\
"&& xrandr --output eDP-1-1 --off"
disconnect_command = ""
#---
while True:
time.sleep(5)
try:
subprocess.Popen(["xrandr"])
except:
pass
else:
break
# function to get the output of xrandr
def get(cmd): return subprocess.check_output(cmd).decode("utf-8")
# - to count the occurrenc of " connected "
def count_screens(xr): return xr.count(" connected ")
# - to run the connect / disconnect command(s)
def run_command(cmd): subprocess.Popen(["/bin/bash", "-c", cmd])
# first count
xr1 = None
while True:
time.sleep(5)
# second count
xr2 = count_screens(get(["xrandr"]))
# check if there is a change in the screen state
if xr2 != xr1:
if xr2 == 4:
# command to run if connected (two screens)
run_command(connect_command)
elif xr2 == 1:
# command to run if disconnected (one screen)
# uncomment run_command(disconnect_command) to enable, then also comment out pass
pass
# run_command(disconnect_command)
# set the second count as initial state for the next loop
xr1 = xr2
如果出于任何原因,您不愿意运行后台脚本,则可以通过键盘快捷方式运行相同的命令:
选择:系统设置>“键盘”>“快捷方式”>“自定义快捷方式”。单击"+“并添加命令:
/bin/bash -c "xrandr --output DP-2 --pos 0x0 --mode 1920x1200 && xrandr --output HDMI-0 --pos 1920x0 --mode 1920x1200 && xrandr --output DP-3 --pos 3840x0 --mode 1920x1200 && xrandr --output eDP-1-1 --off"
发布于 2017-03-22 20:17:20
同时,我还找到了这个方便的命令来更改gnome中的壁纸。
gsettings set org.gnome.desktop.background picture-uri file:///path/to/wallpaper.jpg
所以,现在我用它和脚本中的Xrandr命令一起安装我的桌面,每次我把显示器连接到笔记本电脑上。
https://askubuntu.com/questions/894109
复制相似问题