#!/usr/bin/env bash
# Toggle the full-screen power menu on the focused monitor.  The open's exit
# status is ignored: it exceeds the client's 100 ms reply deadline.
detach_self "$@"
eww close popup 2>/dev/null
eww update active-panel= 2>/dev/null
screen=$(eww-bar focused)
if [[ -n $screen ]]; then
  eww open powermenu --toggle --screen "$screen" >/dev/null 2>&1
else
  eww open powermenu --toggle >/dev/null 2>&1
fi
exit 0
