我使用 2 个显示器(其中右侧的显示器在像素和物理指标上都小于左侧的显示器),并且经常想在自动隐藏的启动器上打开右侧显示器上的某些内容。(显示设置中的粘性边缘已关闭,因此在屏幕之间移动光标感觉更自然。)这要求我将光标缓慢移动到右侧显示器的左边缘,因为如果我像平常一样快速移动它,光标会移动到左侧显示器。
我希望我可以移动光标到底部边缘来淡入启动器。但是,我找不到命令来执行此操作。
如果有命令可以让启动器淡入或以其他方式执行此操作,请告诉我。
答案1
当鼠标进入“触发”区域时显示启动器
当鼠标指针进入某个区域时,下面的脚本会激活(自动隐藏的)启动器(激活区如图所示)。
因为绘制一个完全是直线朝向目标启动器图标,启动器激活后,我在屏幕(右)左侧创建了一个 200px 的区域,您可以在其中自由移动,而无需再次隐藏启动器(移动区域)。
如何使用
该脚本用于
xdotool
获取鼠标位置:sudo apt-get install xdotool
将脚本复制到一个空文件中,另存为
trigger_launcher.py
在脚本的头部,我设置了适合您的屏幕组合和顶部对齐的值。但是,如果您要将脚本用于其他屏幕(尺寸),或者想要更改(触发器)边距,则可以在脚本的头部进行更改:
# the script assumes the two screens are top-alligned (!) #-- set the area to trigger the launcher (from left bottom of second screen) below: vert_marge = 50 hor_marge = 200 #-- set the width of the left screen below: width_screen1 = 1680 #-- set the height of the right screen below: height_screen2 = 900 #---
使用以下命令测试脚本:
python3 /path/to/trigger_launcher.py
如果一切正常,请将其添加到启动应用程序:Dash > 启动应用程序 > 添加。添加命令:
/bin/bash -c "sleep 15&&python3 /path/to/trigger_launcher.py"
剧本
#!/usr/bin/env python3
import subprocess
import time
# the script assumes the two screens are top-alligned (!)
#-- set the area to trigger the launcher (from left bottom of second screen) below:
vert_marge = 50
hor_marge = 200
#-- set the with of the left screen below:
width_screen1 = 1680
#-- set the height of the right screen below:
height_screen2 = 900
#--
vert_line = height_screen2-vert_marge
hor_line2 = width_screen1+hor_marge
k = [" org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ ",
"gsettings set ", "launcher-hide-mode 1", "launcher-hide-mode 0"]
hide = k[1]+k[0]+k[2]; show = k[1]+k[0]+k[3]
def set_launcher(command):
subprocess.Popen(["/bin/bash", "-c", command])
def get_mousepos():
curr = subprocess.check_output(["xdotool", "getmouselocation"]).decode("utf-8")
return [int(it.split(":")[1]) for it in curr.split()[:2]]
current1 = get_mousepos()
while True:
time.sleep(0.3)
current2 = get_mousepos()
if not current1 == current2:
test1 = [int(current1[1]) > vert_line, width_screen1 < int(current1[0]) < hor_line2]
test2 = [int(current2[1]) > vert_line, width_screen1 < int(current2[0]) < hor_line2]
test3 = any([int(current2[0]) > hor_line2, int(current2[0]) < width_screen1])
if (all(test1), all(test2)) == (False, True):
set_launcher(show)
elif test3 == True:
set_launcher(hide)
current1 = current2
编辑
下面是一个时间间隔为 3 秒的版本,而不是您在评论中提到的“移动区域”。
#!/usr/bin/env python3
import subprocess
import time
# the script assumes the two screens are top-alligned (!)
#-- set the area to trigger the launcher (from left bottom of second screen) below:
vert_marge = 50
hor_marge = 200
#-- set the with of the left screen below:
width_screen1 = 1680
#-- set the height of the right screen below:
height_screen2 = 900
#--
vert_line = height_screen2-vert_marge
hor_line2 = width_screen1+hor_marge
k = [" org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ ",
"gsettings set ", "launcher-hide-mode 1", "launcher-hide-mode 0"]
hide = k[1]+k[0]+k[2]; show = k[1]+k[0]+k[3]
def set_launcher(command):
subprocess.Popen(["/bin/bash", "-c", command])
def get_mousepos():
curr = subprocess.check_output(["xdotool", "getmouselocation"]).decode("utf-8")
return [int(it.split(":")[1]) for it in curr.split()[:2]]
current1 = get_mousepos()
while True:
time.sleep(0.3)
current2 = get_mousepos()
if not current1 == current2:
test1 = [int(current1[1]) > vert_line, width_screen1 < int(current1[0]) < hor_line2]
test2 = [int(current2[1]) > vert_line, width_screen1 < int(current2[0]) < hor_line2]
if (all(test1), all(test2)) == (False, True):
set_launcher(show)
time.sleep(3)
set_launcher(hide)
current1 = current2