Last active
December 10, 2022 20:43
-
-
Save LatinSuD/da71e5821dfa248213e6c91129228b1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Force a delay between mouse touches screen border and when panel (eg: taskbar) pops up | |
# This is a little hackish. It will detect mouse position, and move the panel out of the screen | |
# Currently only works for a bar on the left | |
# Requires: xdotool | |
INTERVAL=0.3 | |
# Desktop Height | |
DHEIGHT=768 | |
# How much to move left the bar | |
OFFSET=200 | |
# Detect ID of the panel | |
BARRA="$( | |
for i in `xdotool search --classname Plasma`; do | |
xwininfo -id $i | | |
egrep -q -- "-geometry [12]?[0-9]{2}x$DHEIGHT\+(0|-$OFFSET)\+0" && | |
echo $i | |
done | | |
egrep '^[0-9]+' | | |
head -n 1 | |
)" | |
# Alternatively detect | |
# BARRA=$(xdotool selectwindow) | |
# Handle quit gracefully | |
trap 'xdotool windowmove "$BARRA" 0 0; exit' SIGINT SIGTERM | |
# echo "Panel window id = $BARRA" | |
# Start by hiding | |
xdotool windowmove "$BARRA" -$OFFSET 0 | |
A1=-1 | |
A2=-1 | |
A3=-1 | |
S=0 | |
# Main loop | |
while true; do | |
A3=$A2 | |
A2=$A1 | |
A1=$(xmousepos | cut -f1 -d" ") | |
# If the mouse has been on the left for a while, restore panel | |
if [[ $A1 == 0 && $A2 == 0 && $S == 0 ]]; then | |
S=1 | |
xdotool windowmove "$BARRA" 0 0 | |
fi | |
# If the mouse is on the right, hide panel | |
if [[ $A1 -gt $OFFSET && $S == 1 ]]; then | |
S=0 | |
xdotool windowmove "$BARRA" -$OFFSET 0 | |
fi | |
sleep $INTERVAL | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment