多个工作区壁纸而不使用ccsm

有没有办法在不使用CCSM的情况下为每个工作区设置不同的背景? 我已经阅读了一些恐怖故事,如果可能的话宁愿避免它。 我正在使用Raring Ringtail(13.04)

在不使用ccsm的情况下在不同工作区上使用不同的壁纸

下面的脚本使用compiz设置管理器,但它假定:

  • python3已安装(如果没有让我知道)
  • 安装了wmctrl (用于获取工作空间上的数据)。 您可能需要安装它:sudo apt-get install wmctrl

无论工作空间的数量如何,它都可以工作; 它计算工作空间的列数和当前工作空间的行,并为该(当前)工作空间设置用户定义的壁纸。
脚本启动后,只需切换到不同的工作区并以“正常”(GUI)方式设置壁纸。 该脚本在其创建的小文件中跟踪每个工作区的壁纸。 这不应该导致性能上的任何延迟,因为只有在脚本启动时才会读取文件,或者当用户更改每个工作区的壁纸时。

在此处输入图像描述

剧本

 #!/usr/bin/env python3 import subprocess import time import os key1 = "gsettings set org.gnome.desktop.background picture-uri " key2 = "gsettings get org.gnome.desktop.background picture-uri" def write_wspaces(file, current): with open(file, "wt") as wt: wt.write(current) def read_wspaces(file): with open(file) as src: return src.read().strip() def get_info(command): return subprocess.check_output(["/bin/bash", "-c", command]).decode("utf-8") def get_currwallpaper(): return get_info(key2).replace("file://", "").strip() # get resolution output = get_info("xrandr").split(); idf = output.index("current") res = (int(output[idf+1]), int(output[idf+3].replace(",", ""))) def calculate_geometry(): # get viewport data vp = get_info("wmctrl -d").split(" ") span = vp[4].split("x"), vp[7].split(",") # calculate number of (horizontal) viewports n_vps_hor = int(int(span[0][0])/int(res[0])) n_vps_vert = int(int(span[0][2])/int(res[1])) n_wspaces = int(n_vps_hor)*int(n_vps_vert) # calculate current viewport curr_vp_hor = int((int(span[1][0])/int(res[0]))+1) curr_vp_vert = int((int(span[1][3])/int(res[1]))+1) return ((curr_vp_vert-1)*n_vps_hor)+curr_vp_hor, n_wspaces home = os.environ["HOME"] wspaces = home+"/"+".config/wall_wspaces" if not os.path.exists(wspaces): os.makedirs(wspaces) if not os.path.exists(wspaces+"/wspaces.txt"): current = get_currwallpaper().replace("'", "") writelist = []; [writelist.append(current) for i in range(calculate_geometry()[1])] write_wspaces(wspaces+"/wspaces.txt", str(writelist)) wall_list = eval(read_wspaces(wspaces+"/wspaces.txt")) while True: curr_vp1 = calculate_geometry()[0]; currwallpaper1 = get_currwallpaper() time.sleep(2) curr_vp2 = calculate_geometry()[0]; currwallpaper2 = get_currwallpaper() if curr_vp1 != curr_vp2: command = key1+"file://"+str(wall_list[curr_vp2-1]) subprocess.Popen(["/bin/bash", "-c", command]) elif currwallpaper1 != currwallpaper2: wall_list = eval(read_wspaces(wspaces+"/wspaces.txt")) wall_list[int(curr_vp2)-1] = currwallpaper2 write_wspaces(wspaces+"/wspaces.txt", str(wall_list)) else: pass 

如何使用

只需将脚本复制到空文件中,将其另存为workspace_walls.py并通过以下命令运行:

 python3 /path/to/workspace_walls.py 

如果它按您的喜好工作,请将其添加到您的启动应用程序:Dash> Startup Applications> Add


编辑:

在完全重写的脚本版本下面,到这个版本的模型。

脚本(有一些细微差别)+ GUI也可用作ppa

在此处输入图像描述

 sudo add-apt-repository ppa:vlijm/wswitcher sudo apt-get update sudo apt-get install wswitcher 
 #!/usr/bin/env python3 import subprocess import os import time workspace_data = os.environ["HOME"]+"/.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(): # get the current viewport res = get_res() vp_data = subprocess.check_output( ["wmctrl", "-d"] ).decode("utf-8").split() dt = [int(n) for n in vp_data[3].split("x")] cols = int(dt[0]/res[0]) curr_vpdata = [int(n) for n in vp_data[5].split(",")] curr_col = int(curr_vpdata[0]/res[0])+1 curr_row = int(curr_vpdata[1]/res[1]) return str(curr_col+curr_row*cols) curr_ws1 = current() currwall1 = getwall() while True: time.sleep(1) currwall2 = getwall() # print(currwall2) curr_ws2 = current() 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() 

Budgie现在支持了

2017年7月21日为Zesty添加了对Budgie的支持,当从ppa安装时(见上文)

在此处输入图像描述