Bug*_*man 6 unity workspaces launcher viewports
我只想在主工作区中保持启动器处于活动状态。例如,我喜欢在没有启动器的情况下将 Citrix 窗口保持在全显示模式(在工作区 II 中)。
像许多事情一样,据我所知,它并不存在,但是,它可以通过一点创造力和正确的工具来完成。
假设您使用的是 14.04(使用 python3),您可以使用脚本在后台运行,跟踪当前视口并将启动器设置为自动隐藏或不自动隐藏,具体取决于当前视口。
您首先需要做的是安装wmctrl
:
sudo apt-get install wmctrl
Run Code Online (Sandbox Code Playgroud)
我们需要wmctrl
获取有关所有视口的总大小的信息,并能够读取有关我们所在的当前部分的信息。
完成后,将下面的脚本复制到一个空文件中并将其autohide_launcher.py
保存为(保持名称不变)并使其可执行(!)。
在行中hide_launcher
,决定要自动隐藏启动器的视口(设置“True”),并使用与您的视口数量相对应的正确条目数。该列表从左到右读取每个视口行。
sudo apt-get install wmctrl
Run Code Online (Sandbox Code Playgroud)
您可以通过以下命令启动脚本:
/path/to/autohide_launcher.py
Run Code Online (Sandbox Code Playgroud)但是,使用下面的脚本可以更方便地使用一个命令来打开/关闭脚本。
将下面的脚本复制到一个空文件中,并将其另存为start_stop.py
,与脚本相同的文件夹中autohide_launcher.py
。让它也可执行(!)。现在您可以使用以下命令切换自动隐藏功能
/path/to/start_stop.py
Run Code Online (Sandbox Code Playgroud)
启动/停止脚本:
#!/usr/bin/env python3
import subprocess
import time
# set the hide-launcher values for your viewports; in rows/columns
hide_launcher = (False, True, True, True)
# don't change anything below (or it must be the time.sleep(2) interval)
key = " org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ "
pr_get = "gsettings get "; pr_set = "gsettings set "
check = pr_get+key+"launcher-hide-mode"
hide = pr_set+key+"launcher-hide-mode 1"
show = pr_set+key+"launcher-hide-mode 0"
def get_value(command):
return subprocess.check_output(
["/bin/bash", "-c", command]).decode('utf-8').strip()
# get screen resolution
output = get_value("xrandr").split(); idf = output.index("current")
screen_res = (int(output[idf+1]), int(output[idf+3].replace(",", "")))
while True:
# get total span size all viewports, position data
wsp_info = get_value("wmctrl -d").strip()
scr_data = [item.split("x") for item in wsp_info.split(" ") if "x" in item][0]
# get current position (viewport coordinates)
VP = eval(wsp_info[wsp_info.find("VP: "):].split(" ")[1])
# calculated viewports rows / columns
VP_hor = int(scr_data[0])/int(screen_res[0])
VP_vert = int(scr_data[1])/int(screen_res[1])
# calculated viewport positions
range_hor = [i*screen_res[0] for i in range(int(VP_hor))]
range_vert = [i*screen_res[1] for i in range(int(VP_vert))]
viewports = [(h, range_vert[i])for i in range(len(range_vert)) for h in range_hor]
current_viewport = viewports.index(VP); a_hide = get_value(check)
if (hide_launcher[current_viewport], a_hide == "0") == (True, True):
subprocess.Popen(["/bin/bash", "-c", hide])
elif (hide_launcher[current_viewport], a_hide == "0") == (False, False):
subprocess.Popen(["/bin/bash", "-c", show])
else:
pass
time.sleep(1)
Run Code Online (Sandbox Code Playgroud)
还有其他几种方法可以方便地切换脚本:
将脚本添加到您的启动应用程序
如果您永久想在后台运行脚本:
添加命令:
/path/to/autohide_launcher.py
Run Code Online (Sandbox Code Playgroud)给它一个你喜欢的名字
设置键盘快捷键以切换脚本
使用以下命令创建您选择的新快捷方式:
/path/to/start_stop.py
Run Code Online (Sandbox Code Playgroud)
现在您可以使用组合键切换每个视口的自动隐藏。
发表在gist.gisthub
归档时间: |
|
查看次数: |
767 次 |
最近记录: |