所以,我们有 Tabs Outliner 扩展
https://chrome.google.com/webstore/detail/tabs-outliner/eggkanocgddhmamlbiijnphhppkpkmkl
这是一个非常好的 Chromium 垂直选项卡管理器。问题是它占据了太多的屏幕,而我没有宽屏显示器。因此,它是一个始终可见的新镀铬窗口,占据屏幕的左侧。
问题是:如何让它在您将鼠标移开并双击其列出的选项卡之一后自动隐藏?
答案1
好的,我设法为此编写了一个脚本,您可能会发现它对于为其他情况提供类似的功能很有用。如果你这样做,我也想知道:)
另外,如果有更好的方法,我也想知道:)
起始变量是你的选择
#!/bin/bash -i
waitStart=5
delayRaiseTabOutliner=0.1
screenLeftMarginOpen=10
screenLeftMarginClose=200
bUseScreenLeftMarginClose=false
bGoToChromiumWhenTablinkIsDoubleClicked=true
function FUNCparent() {
xwininfo -tree -id $1 |grep "Parent window id"
}
function FUNCparentest() {
local check=`printf %d $1`
local parent=-1
local parentest=-1
#echo "Child is: $check" >&2
while ! FUNCparent $check |grep -q "(the root window)"; do
#echo "a $check" >&2 #DEBUG info
xwininfo -id $check |grep "Window id" >&2 #report
parent=`FUNCparent $check |egrep -o "0x[^ ]* "`
parent=`printf %d $parent`
check=$parent
sleep 1
done
if((parent!=-1));then
parentest=$parent
fi
if((parentest!=-1));then
echo $parentest
#echo "Parentest is: $check" >&2
else
echo $1
#echo "Child has no parent." >&2
fi
}
while true; do
list=(`xdotool search Chromium 2>/dev/null`)
chromiumWindowId=""
for windowId in `echo ${list[*]}`; do
if xwininfo -id $windowId |grep "Window id" |egrep -oq " - Chromium\"$"; then
chromiumWindowId=$windowId
xwininfo -id $chromiumWindowId |grep "Window id" #report
break;
fi
done
if [[ -z "$chromiumWindowId" ]]; then
sleep $waitStart
continue;
fi
list=(`xdotool search "Tabs Outliner" 2>/dev/null`)
tabsOutlinerWindowId=""
for windowId in `echo ${list[*]}`; do
if xwininfo -id $windowId |grep "Window id" |egrep -oq "\"Tabs Outliner\"$"; then
tabsOutlinerWindowId=`FUNCparentest $windowId`
xwininfo -id $tabsOutlinerWindowId |grep "Window id" #report
break;
fi
done
if [[ -z "$tabsOutlinerWindowId" ]]; then
sleep $waitStart
continue;
fi
previousWindowId=-1
previousChromeTabName=""
while true; do
# check if chromium is still running
if ! xdotool getwindowname $chromiumWindowId 2>&1 >/dev/null; then
break;
fi
if ! xdotool getwindowname $tabsOutlinerWindowId 2>&1 >/dev/null; then
break;
fi
# info about window below mouse (even if have not focus)
eval `xdotool getmouselocation --shell 2>/dev/null`
windowId=$WINDOW
mouseX=$X
mouseY=$Y
# not working yet...
# must work only if over chromium application windows
#activeWindow=`xdotool getactivewindow`
#activeWindow=`FUNCparentest $activeWindow`
#echo "windowId=$windowId, chromiumWindowId=$chromiumWindowId, tabsOutlinerWindowId=$tabsOutlinerWindowId, previousWindowId=$previousWindowId, activeWindow=$activeWindow" #DEBUG info
# not working yet...
# only allowed to work if chromium windows has focus
# if((activeWindow!=chromiumWindowId && activeWindow!=tabsOutlinerWindowId));then
# sleep $delayRaiseTabOutliner
# continue
# fi
#echo "Chromium app is active."
# from chromium to tabs outliner!
if((windowId==chromiumWindowId));then
if((mouseX<screenLeftMarginOpen));then
xdotool windowactivate $tabsOutlinerWindowId
echo "activate TabOutliner (`date`)"
fi
fi
# from tabs outliner to chromium
bActivatedChromium=false
# when a tabs outliner tab is double clicked, it changes chromium window current tab!
if $bGoToChromiumWhenTablinkIsDoubleClicked; then
if((windowId==tabsOutlinerWindowId));then
currentChromeTabName=`xprop -id $chromiumWindowId |grep "^WM_NAME(STRING) = \""`
if [[ -z "$previousChromeTabName" ]]; then
previousChromeTabName="$currentChromeTabName"
fi
if [[ "$currentChromeTabName" != "$previousChromeTabName" ]]; then
xdotool windowactivate $chromiumWindowId
bActivatedChromium=true
fi
previousChromeTabName="$currentChromeTabName"
fi
fi
if $bUseScreenLeftMarginClose;then
if((windowId==tabsOutlinerWindowId));then
if((mouseX>screenLeftMarginClose));then
xdotool windowactivate $chromiumWindowId
bActivatedChromium=true
fi
fi
else
if((previousWindowId==tabsOutlinerWindowId));then
if((windowId==chromiumWindowId));then
xdotool windowactivate $chromiumWindowId
bActivatedChromium=true
fi
fi
fi
if $bActivatedChromium; then
echo "activate Chromium (`date`)"
fi
previousWindowId=$windowId
sleep $delayRaiseTabOutliner
done
done