用于切换显示优先级的脚本/快捷方式?

我希望有一个快捷方式来切换显示器(笔记本电脑+外部)的优先级(即主要,次要)。

PS:我知道有一个专用的按钮/快捷方式可以做到这一点,但至少我的,循环所有配置(即不同的分辨率)。 我想仅在两种配置之间循环。

原来我已经把它写成了这个问题的一部分。 既然这是另一个问题 ,那么就低于这个问题

#!/usr/bin/env python3 import subprocess # Look up the currently set primary screen, set it to the other one scr_data = subprocess.check_output(["xrandr"]).decode("utf-8").splitlines() scrs = [[l.split()[0], "primary" in l] for l in scr_data if " connected" in l] for screen in scrs: if not screen[1]: subprocess.Popen(["xrandr", "--output", screen[0], "--primary"]) 

它切换(在两者之间切换)主屏幕。

使用:

  • 将脚本复制到空文件中,将其另存为toggle_primary.py
  • 将其添加到快捷键:选择:系统设置>“键盘”>“快捷方式”>“自定义快捷方式”。 单击“+”并添加命令:

     python3 /path/to/toggle_primary.py