49 lines
1.7 KiB
Bash
Executable File
49 lines
1.7 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 every monitor's bar (default)
|
|
# station-bar.sh show|hide -> --show / --hide every monitor's bar
|
|
# station-bar.sh toggle here -> toggle ONLY the bar on the focused monitor
|
|
# station-bar.sh show DP-1 -> act on a specific monitor by connector name
|
|
#
|
|
# The optional 2nd arg is a monitor target: empty = all, "here" = the currently
|
|
# focused monitor (resolved via hyprctl), or a literal connector like "HDMI-A-1".
|
|
#
|
|
# (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
|
|
|
|
TARGET="${2:-}"
|
|
if [[ "$TARGET" == "here" ]]; then
|
|
TARGET="$(hyprctl -j monitors 2>/dev/null \
|
|
| python3 -c 'import sys,json; print(next((m["name"] for m in json.load(sys.stdin) if m.get("focused")), ""))' 2>/dev/null)"
|
|
fi
|
|
|
|
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" "[<'${TARGET}'>]" "{}" >/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" "$1" "$TARGET"
|
|
fi
|
|
sleep 0.2
|
|
done
|
|
|
|
exec python3 "$APP" "$VERB" "$TARGET"
|