update waybar-toggle script

This commit is contained in:
2025-09-27 21:29:19 +02:00
parent ea57f385a6
commit a1869ca578
4 changed files with 17 additions and 15 deletions

View File

@@ -17,7 +17,7 @@
- rofi: edit $HOME/.config/rofi/config.rasi - rofi: edit $HOME/.config/rofi/config.rasi
- waybar: edit $HOME/.config/waybar/style.css - waybar: edit $HOME/.config/waybar/style.css
waybar-toggle.sh waybar-toggle restart
- oh-my-posh: edit $HOME/.config/posh_theme.omp.json - oh-my-posh: edit $HOME/.config/posh_theme.omp.json
@@ -162,7 +162,7 @@ def _change_waybar(palette: dict[str, str], flavor: str):
waybar_template = Path.home().joinpath('.config', 'waybar', 'style.css.template') waybar_template = Path.home().joinpath('.config', 'waybar', 'style.css.template')
waybar_dist = copy_template(waybar_template, Path.home().joinpath('.config', 'waybar')) waybar_dist = copy_template(waybar_template, Path.home().joinpath('.config', 'waybar'))
replace_placeholders(waybar_dist, palette, flavor) replace_placeholders(waybar_dist, palette, flavor)
os.system('waybar-toggle') os.system('waybar-toggle restart')
def _change_ohmyposh(palette: dict[str, str], flavor: str): def _change_ohmyposh(palette: dict[str, str], flavor: str):

View File

@@ -1,42 +1,44 @@
#!/usr/bin/env bash #!/usr/bin/env bash
lyrics_widget_closed=0
function close() { function close() {
killall -q waybar killall -q waybar
# Also close the lyrics widget if open # Also close the lyrics widget if open
if eww active-windows | grep -q "lyrics-single"; then if eww active-windows | grep -q "lyrics-single"; then
eww close lyrics-single eww close lyrics-single
lyrics_widget_closed=1
fi fi
} }
function open() { function open() {
# the system tray will not work with kded6 started # the system tray will not work with kded6 started
if killall -q "kded6"; then if killall -q -9 "kded6"; then
while pgrep -x "kded6" >/dev/null; do while pgrep -x "kded6" >/dev/null; do
sleep 0.2 sleep 0.2
done done
fi fi
(setsid waybar > /dev/null 2> /dev/null &)& (setsid waybar > /dev/null 2> /dev/null &)&
disown disown
# Reopen the lyrics widget if it was previously closed
if [ $lyrics_widget_closed -eq 1 ]; then
eww open lyrics-single
fi
} }
if [ -z "$1" ]; then if [ "$1" = "restart" ]; then
close close
while pgrep -x "waybar" >/dev/null; do while pgrep -x "waybar" >/dev/null; do
sleep 0.2 sleep 0.2
done done
open open
elif [ "$1" = "close" ]; then elif pgrep -x "waybar" >/dev/null; then
if ! pgrep -x "waybar" >/dev/null; then
exit 1
fi
close close
elif [ "$1" = "open" ]; then elif ! pgrep -x "waybar" >/dev/null; then
if pgrep -x "waybar" >/dev/null; then
exit 1
fi
open open
else else
echo "Usage: $0 [close|open]" echo "Usage: $0 [restart]"
exit 1 exit 1
fi fi

View File

@@ -10,7 +10,7 @@ bind = Super, X, exec, gnome-text-editor # Launch Text Editor
bind = Super, B, exec, killall btop || ghostty -e btop # Launch btop (system monitor) bind = Super, B, exec, killall btop || ghostty -e btop # Launch btop (system monitor)
bind = Super, Space, exec, eww open main --toggle # Launch dashboard (eww) bind = Super, Space, exec, eww open main --toggle # Launch dashboard (eww)
bind = Super+Shift, V, exec, pavucontrol # Launch pavucontrol (volume mixer) bind = Super+Shift, V, exec, pavucontrol # Launch pavucontrol (volume mixer)
bind = Super+Shift, K, exec, waybar-toggle close || waybar-toggle open # Toggle waybar bind = Super+Shift, K, exec, waybar-toggle # Toggle waybar
bind = Super+Shift, L, exec, lyrics-widgets # Toggle lyrics player bind = Super+Shift, L, exec, lyrics-widgets # Toggle lyrics player
bind = Super+Shift, F, exec, coin # Flip a coin bind = Super+Shift, F, exec, coin # Flip a coin