我知道,Always on visible workspace但是我希望所有窗口在打开时都将其作为默认设置,只有少数例外。
我正在寻找的工作流程与它的工作原理几乎相反。显示所有工作区上的所有内容,但有一些(手动)例外。
是否可以?如果需要一些脚本,我可能不会介意。
我正在用Ubuntu运行Ubuntu 17.04,但afaik在统一和大多数桌面环境中都存在此功能。
有趣的情况。
这个概念是不复杂:简单地将所有Windows粘,但是:
wmctrl -l
还显示了一些窗口类型,例如DOCK和DESKTOP,通常不应编辑其中的属性。在下面的脚本中:
使用以下命令运行一个为时两秒的循环,以将窗口列表与上一个列表进行比较:
wmctrl -l
然后从每行提取窗口ID
随后,脚本运行
xprop -id <window_id>
我们可以在其中找到有关_NET_WM_WINDOW_TYPE
和的信息WM_CLASS
由于该脚本仅作用于新创建的窗口,因此不会给您的系统增加任何明显的负担。
#!/usr/bin/env python3
import subprocess
import time
# excluded applications
apps = ["gedit", "chromium", "monkey"]
# ignored window types
ignore = [
"= _NET_WM_WINDOW_TYPE_DOCK",
"= _NET_WM_WINDOW_TYPE_DESKTOP",
]
# just a helper
def get(cmd):
try:
return subprocess.check_output(cmd).decode("utf-8").strip()
except (subprocess.CalledProcessError, TypeError):
pass
# initiate windowlist
wins1 = []
while True:
# cycle time
time.sleep(2)
# initiate new list
new_wins = []
# get the most recent window list
windata = get(["wmctrl", "-l"])
if windata:
# extract window -ids
wins2 = [w.split()[0] for w in windata.splitlines()]
new = [w for w in wins2 if w not in wins1]
# check for excluded classes and window types
for w in new:
testdata = get(["xprop", "-id", w])
if all([
not any([ig in testdata for ig in ignore]),
not any([app in testdata for app in apps]),
]):
# set the passed windows to sticky
subprocess.Popen(
["wmctrl", "-i", "-r", w, "-b", "add,sticky"]
)
# refresh the window list for next cycle
wins1 = wins2
确保wmctrl
已安装:
sudo apt install wmctrl
set_sticky.py
WM_CLASS
-ses设置为排除(您可能想删除猴子,这是出于测试目的:))使用以下命令进行测试:
python3 /path/to/set_sticky.py
如果一切正常,您可以将其添加到“启动应用程序”,但请确保添加一个小中断以防止脚本在尚未就绪的桌面上中断:
/bin/bash -c "sleep 10 && python3 /path/to/set_sticky.py"
玩得开心 :)
我在Ubuntu Budgie(杂音)上测试了25分钟,没有任何问题。它在任何窗口管理器上都应该可以正常运行,但是如果遇到问题,只需提一下。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句