Col*_*lin 5 scripts multiple-monitors unity workspaces launcher
我有两个显示器。我有多个工作区。我希望我的启动器(设置 > 显示中的“启动器放置”)出现在一个工作区的两台显示器上,但在另一个工作区中只有一个启动器(在主显示器上)。这是因为我想在两个显示器上拉伸 Tweetdeck,而启动器会妨碍它。这可能吗?
工作区 1(好):

工作区 2(不好):

工作区 2(好):

启动器的位置由以下几项定义:
中设置的值/org/compiz/profiles/unity/plugins/unityshell/num-launchers。您可以通过以下命令读取它:
dconf read /org/compiz/profiles/unity/plugins/unityshell/num-launchers
Run Code Online (Sandbox Code Playgroud)
它将输出1(一个屏幕上的0启动器)或(所有屏幕上的启动器)。
要设置启动程序显示在所有屏幕可以通过命令来完成:
dconf write /org/compiz/profiles/unity/plugins/unityshell/num-launchers 0
Run Code Online (Sandbox Code Playgroud)如果值为1(仅在一个屏幕上可见),我们可以通过将目标屏幕设置为主屏幕,使用以下xrandr命令来设置启动器出现在哪个屏幕上:
xrandr --output <screen_name> --primary
Run Code Online (Sandbox Code Playgroud)这些正是下面脚本使用的命令。
根据您运行脚本的参数,它要么使用以下命令将启动器设置为在所有屏幕上显示:
dconf write /org/compiz/profiles/unity/plugins/unityshell/num-launchers 0
Run Code Online (Sandbox Code Playgroud)
或者只有一个:
dconf write /org/compiz/profiles/unity/plugins/unityshell/num-launchers 1
Run Code Online (Sandbox Code Playgroud)
在后一种情况下,它还将左侧屏幕设置为主要屏幕。
dconf read /org/compiz/profiles/unity/plugins/unityshell/num-launchers
Run Code Online (Sandbox Code Playgroud)
launcher_pos.py使用两个命令(从终端窗口)测试脚本:
python3 /path/to/launcher_pos.py left
Run Code Online (Sandbox Code Playgroud)
和
python3 /path/to/launcher_pos.py all
Run Code Online (Sandbox Code Playgroud)如果一切正常,将命令添加到两个快捷键组合中:选择:系统设置>“键盘”>“快捷方式”>“自定义快捷方式”。单击“+”并将这两个命令添加到可用的快捷方式。
下面的脚本会自动跟踪哪个是当前工作区(无论您有多少工作区以及采用何种配置)。
此脚本与工作区一起运行,您希望启动器仅位于左侧,作为参数。一个例子:
如果您使用以下命令运行脚本:
python3 /path/to/launcher_pos.py 2 3
Run Code Online (Sandbox Code Playgroud)
结果是:
dconf write /org/compiz/profiles/unity/plugins/unityshell/num-launchers 0
Run Code Online (Sandbox Code Playgroud)
脚本需要 wmctrl
sudo apt-get install wmctrl
Run Code Online (Sandbox Code Playgroud)将脚本复制到一个空文件中,另存为 launcher_pos.py
通过以下命令测试运行它:
python3 /path/to/launcher_pos.py 1 3
Run Code Online (Sandbox Code Playgroud)
在工作区 1 和 3 上,启动器现在应该只出现在左侧
如果一切正常,请将其添加到您的启动应用程序:Dash > 启动应用程序 > 添加。添加命令:
/bin/bash -c "sleep 15 && python3 /path/to/launcher_pos.py 1 3"
Run Code Online (Sandbox Code Playgroud)
(如果工作区 1 和 3 是您只需要左侧的启动器的工作区)
| 归档时间: |
|
| 查看次数: |
2885 次 |
| 最近记录: |