#!/usr/bin/env bash # Toggle the mnotifhist (mnotifd's notification-history viewer). # Forwards a verb to the resident daemon over D-Bus; if the daemon isn't # running yet, starts it first. Mirrors horizon-dock.sh/astro-menu.sh. # # mnotifhist.sh -> --toggle (default) # mnotifhist.sh show -> --show # mnotifhist.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.mnotifhist" OBJ="/eu/abdelbaki/mnotifhist" APP="${HOME}/.config/mnotifhist/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/mnotifhist-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"