aboutsummaryrefslogtreecommitdiff
path: root/toggle-bar
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-12-12 12:38:23 +0200
committersrdusr <trevorgray@srdusr.com>2023-12-12 12:38:23 +0200
commitb7b32f9799492c4d8c9c0aafdba5b3e334f668b5 (patch)
treee6c79fe99f709d4e6688d8738b2681dca7ff79b0 /toggle-bar
parent562d79acdcfef1d407fdf41656d770d816ee098f (diff)
downloaddotfiles-b7b32f9799492c4d8c9c0aafdba5b3e334f668b5.tar.gz
dotfiles-b7b32f9799492c4d8c9c0aafdba5b3e334f668b5.zip
Improved overall script
Diffstat (limited to 'toggle-bar')
-rwxr-xr-xtoggle-bar30
1 files changed, 23 insertions, 7 deletions
diff --git a/toggle-bar b/toggle-bar
index f8a5e17..ee010e6 100755
--- a/toggle-bar
+++ b/toggle-bar
@@ -1,17 +1,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
-# Define the file to store the state
-state_file="$HOME/.eww_module_state"
+# 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 [ -e "$STATE_FILE" ]; then
# If the file exists, the module is running, so close it
- rm "$state_file"
- $EWW close bar &
+ 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 &
+ touch "$STATE_FILE"
+ "$EWW" open bar &
fi