blob: ee010e688894740e64a9888422d8e7220e52db58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/bin/bash
EWW=$(which eww)
STATE_FILE="$HOME/.eww_module_state"
BAR_CLASS="Eww - bar" # Update this with the actual class name of your eww bar window
# Function to check if the focused window is the eww bar
is_eww_bar_focused() {
focused_class=$(xprop -id "$(xdotool getactivewindow)" | awk -F '"' '/WM_CLASS/{print $4}')
[ "$focused_class" == "$BAR_CLASS" ]
}
# Check if the module is currently running
if [ -e "$STATE_FILE" ]; then
# If the file exists, the module is running, so close it
rm "$STATE_FILE"
"$EWW" close bar &
xdotool key --clearmodifiers Escape
# Introduce a delay before checking if the eww bar is focused
sleep 0.2
# Check if the eww bar is focused, if not, close it
if ! is_eww_bar_focused; then
sleep 0.2
"$EWW" close bar &
xdotool key --clearmodifiers Escape
fi
else
# If the file doesn't exist, the module is not running, so start it
touch "$STATE_FILE"
"$EWW" open bar &
fi
|