39 lines
1.1 KiB
Bash
Executable File
39 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Toggle station-bar (the EWW top bar's replacement). Forwards a verb to the
|
|
# resident daemon over D-Bus; if the daemon isn't running yet, starts it
|
|
# first. Mirrors horizon-dock.sh/orbit-menu.sh's pattern.
|
|
#
|
|
# station-bar.sh -> --toggle (default)
|
|
# station-bar.sh show -> --show
|
|
# station-bar.sh hide -> --hide
|
|
#
|
|
# (No `set -e`: a non-zero `busctl` in the wait loop is expected and must not
|
|
# abort the script before it forwards the verb.)
|
|
|
|
BUS="eu.abdelbaki.stationbar"
|
|
OBJ="/eu/abdelbaki/stationbar"
|
|
APP="${HOME}/.config/station-bar/main.py"
|
|
|
|
case "${1:-toggle}" in
|
|
show) VERB="--show"; ACTION="show" ;;
|
|
hide) VERB="--hide"; ACTION="hide" ;;
|
|
*) VERB="--toggle"; ACTION="toggle" ;;
|
|
esac
|
|
|
|
registered() { busctl --user list 2>/dev/null | grep -q "$BUS"; }
|
|
|
|
if registered; then
|
|
exec gdbus call --session --dest "$BUS" --object-path "$OBJ" \
|
|
--method org.gtk.Actions.Activate "$ACTION" "[]" "{}" >/dev/null
|
|
fi
|
|
|
|
"${HOME}/.config/scripts/station-bar-start.sh" >/dev/null 2>&1 &
|
|
for _ in $(seq 1 25); do
|
|
if registered; then
|
|
exec "$0" "$@"
|
|
fi
|
|
sleep 0.2
|
|
done
|
|
|
|
exec python3 "$APP" "$VERB"
|