是否可以在Unity(14.04+)中循环工作区?
我配置了键盘快捷键,以便Alt +左键将我带到左侧的工作区,Alt +右键将我带到右侧的工作区,但我宁愿让一组键循环。 理想情况下,像
workspace 1 + Alt + tab ---> worskspace 2 workspace 2 + Alt + tab ---> worskspace 3 workspace 3 + Alt + tab ---> worskspace 4 workspace 4 + Alt + tab ---> worskspace 1
问题是最后一行。 我没有看到任何方法从工作空间4回到工作空间1.如何移动到右模4?
循环浏览视口
使用小脚本,可以浏览工作区(实际上是视口):
-
前进 :
(如果到达最后一个视口,脚本将移至第一个视口)
-
……或者向后 :
(如果到达第一个视口,脚本将移至最后一个视口)
剧本
#!/usr/bin/env python3 import subprocess import sys move = sys.argv[1] # get the needed info from wmctrl -d wsdata = subprocess.check_output(["wmctrl", "-d"]).decode("utf-8").split() # retrieve total size of workspace ws = [int(n) for n in wsdata[3].split("x")] # panel/launcher height/width pans = [int(n) for n in wsdata[7].split(",")] # work area wa = [int(n) for n in wsdata[8].split("x")] # x/y resolution res_h = pans[0]+wa[0]; res_v = pans[1]+wa[1] # current position in the spanning workspace VP = [int(n) for n in wsdata[5].split(",")] def last_h(): # test if we are on the last viewport horizontally return VP[0]+res_h == ws[0] def first_h(): # test if we are on the first viewport horizontally return VP[0] == 0 def last_v(): # test if we are on the last viewport vertically return VP[1]+res_v == ws[1] def first_v(): # test if we are on the first viewport vertically return VP[1] == 0 if move == "next": if last_h() == False: command = str(VP[0]+res_h)+","+str(VP[1]) elif last_v() == True: command = "0,0" else: command = "0,"+str(VP[1]+res_v) if move == "prev": if first_h() == False: command = str(VP[0]-res_h)+","+str(VP[1]) elif first_v() == True: command = str(ws[0]-res_h)+","+str(ws[1]-res_v) else: command = str(ws[0]-res_h)+","+str(VP[1]-res_v) subprocess.Popen(["wmctrl", "-o", command])
如何使用
-
该脚本需要wmctrl :
sudo apt-get install wmctrl
-
将脚本复制到空文件中,将其另存为
through_viewports.py
-
将两个命令添加到两个不同的快捷键:
python3 /path/to/through_viewports.py next
转到下一个视口,并:
python3 /path/to/through_viewports.py prev
转到上一个视口
打开系统设置>键盘>快捷方式>自定义快捷方式。 单击
+
并将两个命令添加到您喜欢的快捷方式。
就是这样脚本会检测视口的设置方式并循环显示它们。
它是如何工作的,这个概念
在Unity中,视口排列在一个大矩阵中,它们共同构成了单个工作区 ,Unity桌面存在。
使用命令:
wmctrl -d
在输出中,我们可以读取我们需要的所有信息,以找出我们目前在矩阵中的位置。
0 * DG: 5120x2400 VP: 0,0 WA: 65,24 1215x776 N/A
-
5120x2400
是所有视口的总大小(矩阵) -
0,0
是矩阵中当前视口的x / y位置(左上角,像素) - 来自
WA: 65,24 1215x776
我们可以得出屏幕的分辨率(65,24
是启动器/面板的宽度/高度,1215x776
是剩余区域)
获得正确的信息后,脚本将计算矩阵中的目标位置,并使用以下命令进行设置:
wmctrl -ox,y
在12.04我通过使用gconf-editor编辑一个键解决了这个问题,但在16.04中没有相同的键,所以这里对我有用:
sudo apt-get install compizconfig-settings-manager
然后,安装GUI高级设置实用程序
ccsm
它启动它。 然后我转到桌面墙>视口切换>允许环绕并选中该框。