Hem*_*dav 15 unity compiz ccsm 16.04
我的意思是,每当我尝试在其上移动指针时,窗口都应该四处移动。我有一个“模拟时钟屏幕”和“文件进度对话框”,我对其进行了调整,以使用 CCSM 保持在其他窗口的“始终在顶部”,但有时它们会妨碍执行操作。
如果这是不可能的,那么有什么方法可以让我在它们上移动指针时隐藏它们,以便我可以直接单击下面的应用程序?
此外,如果这是不可能的,那么我们可以让窗户表现得好像它们不存在一样吗?我的意思是我会看到窗口,但指针不应该识别它并且应该在它下面的应用程序上正常工作。如果可能,我将更改应用程序的透明度并使其工作?
概述
我想我有一个适合您的解决方案。它是一个 bash 脚本,允许您选择一个窗口。选择窗口后,脚本会按预定义的时间间隔连续轮询窗口和光标位置。如果光标太近,窗口就会移开。
依赖关系
该脚本依赖于xdotool
. 要安装,请运行sudo apt-get install xdotool
脚本:cursophobia.sh
使用以下内容创建一个新的 bash 脚本并使其可执行。
#!/bin/bash
windowSelectionDelay=5 # How long to wait for user to select a window?
buffer=10 # How close do we need to be to border to get scared?
jump=20 # How far do we jump away from pointer when scared?
poll=.25 # How often in seconds should we poll window and mouse?
# locations. Increasing poll should lighten CPU load.
# ask user which window to make phobic
for s in $(seq 0 $((windowSelectionDelay - 1)))
do
clear
echo "Activate the window that you want to be cursophobic: $((windowSelectionDelay - s))"
sleep 1
done
wID=$(xdotool getactivewindow)
# find some boundary info and adjustments
# determine where the window is now
info=$(xdotool getwindowgeometry $wID)
base=$(grep -oP "[\d]+,[\d]+" <<< "$info")
# move the window to 0 0 and get real location
xdotool windowmove $wID 0 0
info=$(xdotool getwindowgeometry $wID)
realMins=$(grep -oP "[\d]+,[\d]+" <<< "$info")
xMin=$(cut -f1 -d, <<< "$realMins")
yMin=$(cut -f2 -d, <<< "$realMins")
# find offset values for no movement. This is necessary because moving 0,0
# relative to the current position sometimes actually moves the window
xdotool windowmove --relative $wID 0 0
info=$(xdotool getwindowgeometry $wID)
diff=$(grep -oP "[\d]+,[\d]+" <<< "$info")
xOffset=$[xMin - $(cut -f1 -d, <<< "$diff")]
yOffset=$[yMin- $(cut -f2 -d, <<< "$diff")]
# move window back to original location
x=$(cut -f1 -d, <<< "$base")
y=$(cut -f2 -d, <<< "$base")
xdotool windowmove $wID $[x + xOffset] $[y + yOffset]
dispSize=$(xdotool getdisplaygeometry)
xMax=$(cut -f1 -d ' ' <<< "$dispSize")
yMax=$(cut -f2 -d ' ' <<< "$dispSize")
clear
echo "You can minimize this window, but don't close it, or your window will overcome its cursophobia"
# start an infinite loop polling to see if we need to move the window.
while :
do
# get information about where the window is
info=$(xdotool getwindowgeometry $wID)
position=$(grep -oP "[\d]+,[\d]+" <<< "$info")
geometry=$(grep -oP "[\d]+x[\d]+" <<< "$info")
height=$(cut -f2 -dx <<< "$geometry")
width=$(cut -f1 -dx <<< "$geometry")
top=$(cut -f2 -d, <<< "$position")
left=$(cut -f1 -d, <<< "$position")
bottom=$((top + height))
right=$((left + width))
# save mouse coordinates to x & y
eval "$(xdotool getmouselocation | cut -f 1-2 -d ' ' | tr ' :' '\n=')"
# If the mouse is too close to the window, move the window
if [ $x -gt $((left - buffer)) ] && [ $x -lt $((right + buffer)) ] && [ $y -gt $((top - buffer)) ] && [ $y -lt $((bottom + buffer)) ]; then
#figure out what side we're closest to so we know which direction to move the window
t="$((y - top)):0 $((jump + (y - top)))"
l="$((x - left)):$((jump + (x - left))) 0"
b="$((bottom - y)):0 -$((jump + (bottom - y)))"
r="$((right - x)):-$((jump + (right - x))) 0"
coord="$(echo -e "$t\n$l\n$b\n$r" | sort -n | head -n 1 | cut -f2 -d:)"
# set the offset values for x and y
newX=$(cut -f1 -d ' ' <<< "$coord")
newY=$(cut -f2 -d ' ' <<< "$coord")
#check to make sure we're not out of bounds
if [ $((right + newX)) -gt $xMax ]; then
newX=$((-1 * left + xOffset))
elif [ $((left + newX)) -lt $xMin ]; then
newX=$((xMax - width))
fi
if [ $((bottom + newY)) -gt $yMax ]; then
newY=$((-1 * top + yOffset))
elif [ $((top + newY)) -lt $yMin ]; then
newY=$((yMax - height))
fi
# move the window if it has focus
[ $(xdotool getactivewindow) -eq $wID ] && xdotool windowmove --relative $wID $((newX + xOffset)) $((newY + yOffset))
fi
sleep $poll
done
Run Code Online (Sandbox Code Playgroud)
不要忘记根据您的喜好编辑最顶部的四个变量。如果此脚本正在为您的 CPU 分配任务,请尝试将poll
变量增加到更大的值。
cursophobia.sh 的实际应用
创建脚本并使其可执行后,运行它。它会要求您选择一个窗口。单击您想要恐吓的窗口,然后等待倒计时结束。倒计时结束后,您选择的窗口将变得恐惧。当您准备好帮助窗口克服对光标的恐惧时,请关闭终端窗口或使用Ctrl+从终端窗口终止脚本c
多个显示器
请注意,这将 cursophobic 窗口限制为单个显示器。我愿意进行编辑,使其能够在多个显示器上运行。
归档时间: |
|
查看次数: |
398 次 |
最近记录: |