diff options
Diffstat (limited to 'hotspots')
| -rwxr-xr-x | hotspots | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/hotspots b/hotspots deleted file mode 100755 index 8454bac..0000000 --- a/hotspots +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env bash -# -# Hotspots for Xorg -# - Corners: BL, BR, TL, TR -# - Edges: B, T, L, R -# - Events: onEnter, onExit -# -# Dependencies: xdotool -# -# TODO: -# - better multimonitor support - -# Hotspot size -SIZE=2 - -# Active hotspot dimensions (width, height) -B=(1100 140) -T=(700 "$SIZE") -L=(460 700) -R=(140 700) -BL=(400 400) -BR=("$SIZE" "$SIZE") -TL=(400 300) -TR=("$SIZE" "$SIZE") - -# Variables to store the timestamp when the cursor entered a zone -ENTER_TIMESTAMP=0 - -# Function to reset the timestamp -function resetTimestamp() { - ENTER_TIMESTAMP=0 -} - -# Function to handle onEnter with a delay -function onEnterWithDelay() { - local zone=$1 - local current_time=$(date +%s) - - if ((ENTER_TIMESTAMP == 0)); then - # Cursor has just entered the zone, store the timestamp - ENTER_TIMESTAMP=$current_time - elif ((current_time - ENTER_TIMESTAMP >= 2)); then - # Cursor has been in the zone for 2 seconds or more, trigger onEnter - onEnter "$zone" - resetTimestamp - fi -} - -# Function to handle onEnter event -function onEnter() { - ZONE=$1 - case "$1" in - 'T') eww open status &>/dev/null ;; - #'R') eww open bar &>/dev/null ;; - esac -} - -# Function to handle onExit event -function onExit() { - ZONE='' - case "$1" in - 'T') eww close status &>/dev/null ;; - 'R') eww close bar &>/dev/null ;; - esac -} - -# Get screen dimensions (returns: WIDTH, HEIGHT) -eval "$(xdotool getdisplaygeometry --shell)" - -# Calculate coordinates -BLY=$((HEIGHT - BL[1])) -BRX=$((WIDTH - BR[0])) -BRY=$((HEIGHT - BR[1])) -TRX=$((WIDTH - TR[0])) -BX1=$(((WIDTH - B[0]) / 2)) -BX2=$(((WIDTH + B[0]) / 2)) -BY=$((HEIGHT - B[1])) -LY1=$(((HEIGHT - L[1]) / 2)) -LY2=$(((HEIGHT + L[1]) / 2)) -RX=$((WIDTH - R[0])) -RY1=$(((HEIGHT - R[1]) / 2)) -RY2=$(((HEIGHT + R[1]) / 2)) -H=$((HEIGHT - SIZE)) -W=$((WIDTH - SIZE)) - -# Watch mouse -while :; do - sleep 0.1 - - # Get mouse location (returns: X, Y) - eval "$(xdotool getmouselocation --shell)" - - if [ "$ZONE" = "" ]; then - if [[ "$Y" -ge "$H" ]]; then - if [[ "$X" -lt "$SIZE" ]]; then - onEnterWithDelay BL - elif [[ "$X" -gt "$BX1" && "$X" -lt "$BX2" ]]; then - onEnterWithDelay B - elif [[ "$X" -gt "$W" ]]; then - onEnterWithDelay BR - fi - elif [[ "$Y" -lt "$SIZE" && "$X" -gt $((WIDTH / 3)) && "$X" -lt $((2 * WIDTH / 3)) ]]; then - onEnterWithDelay T - elif [[ "$X" -lt "$SIZE" && "$Y" -gt "$LY1" && "$Y" -lt "$LY2" ]]; then - onEnterWithDelay L - elif [[ "$X" -gt "$W" && "$Y" -gt "$RY1" && "$Y" -lt "$RY2" ]]; then - onEnterWithDelay R - fi - else - case "$ZONE" in - 'B') [[ "$X" -lt "$BX1" || "$X" -gt "$BX2" || "$Y" -lt "$BY" ]] && onExit B ;; - 'L') [[ "$X" -ge "${L[0]}" || "$Y" -lt "$LY1" || "$Y" -gt "$LY2" ]] && onExit L ;; - 'R') [[ "$X" -le "$RX" || "$Y" -lt "$RY1" || "$Y" -gt "$RY2" ]] && onExit R ;; - 'T') [[ "$X" -lt "$BX1" || "$X" -gt "$BX2" || "$Y" -gt "${T[1]}" ]] && onExit T ;; - 'BL') [[ "$X" -ge "${BL[0]}" || "$Y" -lt "$BLY" ]] && onExit BL ;; - 'BR') [[ "$X" -le "$BRX" || "$Y" -lt "$BRY" ]] && onExit BR ;; - 'TL') [[ "$X" -ge "${TL[0]}" || "$Y" -ge "${TL[1]}" ]] && onExit TL ;; - 'TR') [[ "$X" -le "$TRX" || "$Y" -ge "${TR[1]}" ]] && onExit TR ;; - esac - fi -done |
