Her*_*mer 5 wallpaper workspaces background mate
我知道之前已经回答过这个问题,但该解决方案在 Ubuntu MATE 上不起作用。无论如何要在 MATE 上实现这一目标?
的输出wmctrl -d:
$ wmctrl -d
0 * DG: 1366x768 VP: 0,0 WA: 0,25 1366x719 Workspace 1
1 - DG: 1366x768 VP: N/A WA: 0,25 1366x719 Workspace 2
2 - DG: 1366x768 VP: N/A WA: 0,25 1366x719 Workspace 3
3 - DG: 1366x768 VP: N/A WA: 0,25 1366x719 Workspace 4
Run Code Online (Sandbox Code Playgroud)
$ 的输出echo $DESKTOP_SESSION:
$ echo $DESKTOP_SESSION
mate
Run Code Online (Sandbox Code Playgroud)
我尝试过但对我不起作用的原始解决方案:
是否可以为每个工作区设置不同的背景?
虽然我无法测试它,但由于我没有可用的 Mate atm,查看 的输出wmctrl -d,并且考虑到 Mate 上的壁纸显然是使用相同的gsettings命令设置的,我看不出为什么它应该不行。
下面的脚本是该脚本的编辑版本,是我推送到 Launchpad 的脚本的摘录。事实上,该方法不适用于 Mate,因为我在该方法中为 Unity 或 Budgie 添加了会话检查。
如果您可以确认下面的脚本适用于 Mate,我可能会编辑 ppa 版本以包含 Mate。
#!/usr/bin/env python3
import subprocess
import os
import time
try:
os.mkdir(os.path.join(os.environ["HOME"], ".config/wswitcher"))
except FileExistsError:
pass
workspace_data = os.environ["HOME"]+"/.config/wswitcher/wallpaper_data_"
key = [
"gsettings get ",
"gsettings set ",
"org.gnome.desktop.background picture-uri",
]
def getwall():
return subprocess.check_output(
["/bin/bash", "-c", key[0]+key[2]]
).decode("utf-8").strip()
def get_res():
# get resolution
xr = subprocess.check_output(["xrandr"]).decode("utf-8").split()
pos = xr.index("current")
return [int(xr[pos+1]), int(xr[pos+3].replace(",", "") )]
def current_ws():
# get the current workspace
wsdata = subprocess.check_output(["wmctrl", "-d"]).decode("utf-8").splitlines()
return [l.split()[0] for l in wsdata if "*" in l][0]
def wswitcher(curr_ws1, currwall1):
while True:
time.sleep(1)
currwall2 = getwall()
curr_ws2 = current_ws()
datafile = workspace_data+curr_ws2
if curr_ws2 == curr_ws1:
if currwall2 != currwall1:
open(datafile, "wt").write(currwall2)
else:
if not os.path.exists(datafile):
open(datafile, "wt").write(currwall2)
else:
curr_set = open(datafile).read()
command = key[1]+key[2]+' "'+str(curr_set)+'"'
subprocess.Popen(["/bin/bash", "-c", command])
curr_ws1 = curr_ws2
currwall1 = getwall()
curr_ws1 = current_ws(); currwall1 = getwall()
wswitcher(curr_ws1, currwall1)
Run Code Online (Sandbox Code Playgroud)
wallswitcher.py测试-通过命令运行它:
python3 /path/to/wallswitcher.py
Run Code Online (Sandbox Code Playgroud)如果一切正常,请将其添加到启动应用程序:
/bin/bash -c "sleep 10 && /path/to/wallswitcher.py
Run Code Online (Sandbox Code Playgroud)