Joh*_*ohn 3 scripts unity compiz window fullscreen
我在左上角有一个热角,显示所有窗口,在右下角显示工作区。当这些在玩游戏时不断激活时,这很烦人。无论如何,当有全屏窗口时,是否可以将 Compiz 设置为忽略热角?
以下两个选项;如果您的活动窗口最大化,一个脚本可以禁用所有热角(临时),一个脚本仅禁用您在问题中提到的特定热角和操作。
这两个脚本都非常轻量级,不会给您的系统增加任何明显的负担。
如果(并且只要)活动窗口最大化(全屏),下面的背景补丁将禁用所有热角。
#!/usr/bin/env python3
import subprocess
import time
import ast
import os
edgedata = os.path.join(os.environ["HOME"], ".stored_edges")
key = "/org/compiz/profiles/unity/plugins/"
corners = [
"|TopRight", "|TopLeft", "|BottomLeft", "|Right",
"|Left", "|Top", "|Bottom", "|BottomRight",
]
def get(cmd):
# just a helper function
try:
return subprocess.check_output(cmd).decode("utf-8").strip()
except subprocess.CalledProcessError:
pass
def setval(cmd):
# just another helper function
subprocess.Popen(cmd)
def check_win():
# see if the active window is maximized
# get the active window, convert the id to wmctrl format
windata = get(["wmctrl", "-lG"])
if windata:
w = hex(int(get(["xdotool", "getactivewindow"])))
front = w[:2]+((10-len(w))*"0")+w[2:]
# look up the window size
match = [l for l in windata.splitlines() if front in l][0].split()[4:6]
# and compare them, if equal -> window is maximized
return match == res
def get_res():
# look up screen resolution
scrdata = get("xrandr").split(); resindex = scrdata.index("connected")+2
return [n for n in scrdata[resindex].split("+")[0].split("x")]
def get_edges():
# get data from dump, remember
data = get(["dconf", "dump", key]).split()
for s in data:
if s.startswith("["):
k = s.replace("[", "").replace("]", "/")
elif any([[c in s][0] for c in corners]):
currval = s.split("=")
stored = ["dconf", "write", key+k+currval[0], currval[1]]
tempval = ["dconf", "write", key+k+currval[0], "''"]
open(edgedata, "a+").write(str(stored)+"\n")
setval(tempval)
def set_stored():
# set the stored values
try:
prev = open(edgedata).readlines()
except FileNotFoundError:
pass
else:
for l in [l.strip() for l in open(edgedata).readlines()]:
toset = ast.literal_eval(l)
setval(toset)
os.remove(edgedata)
res = get_res()
state1 = None
while True:
time.sleep(1)
state2 = check_win()
if state2 != None:
if state2 != state1:
get_edges() if state2 else set_stored()
state1 = state2
Run Code Online (Sandbox Code Playgroud)
该脚本需要xdotool
和wmctrl
:
sudo apt-get install wmctrl xdotool
Run Code Online (Sandbox Code Playgroud)disable_corners.py
使用以下命令从终端测试运行脚本:
python3 /path/to/disable_corners.py
Run Code Online (Sandbox Code Playgroud)如果一切正常,请将其添加到启动应用程序:Dash > 启动应用程序 > 添加。添加命令:
/bin/bash -c "sleep 10 && python3 /path/to/disable_corners.py"
Run Code Online (Sandbox Code Playgroud)如果活动窗口最大化,下面的(后台)脚本将禁用您提到的两个角操作。
sudo apt-get install wmctrl xdotool
Run Code Online (Sandbox Code Playgroud)
用法和设置与选项 1 完全相同。
如果情况发生变化(最大化/未最大化),脚本会使用以下命令设置/取消设置您设置的热角:
dconf write /org/compiz/profiles/unity/plugins/expo/expo-edge "''"
dconf write /org/compiz/profiles/unity/plugins/scale/initiate-edge "''"
Run Code Online (Sandbox Code Playgroud)
禁用,或
dconf write /org/compiz/profiles/unity/plugins "'|BottomRight'"
dconf write /org/compiz/profiles/unity/plugins "'|TopLeft'"
Run Code Online (Sandbox Code Playgroud)
启用。