#!/bin/sh
# Ensure eww daemon is running
pgrep -x eww >/dev/null 2>&1 || eww daemon &
WINDOW="performance_monitor"
# Display distro-specific icon in status bar
# Arch: (f08c7), Gentoo: (e7e6), Other: (eb51)
if [ -f /etc/arch-release ]; then
printf '\n'
elif [ -f /etc/gentoo-release ]; then
printf '\n'
else
printf '\n'
fi
case $BLOCK_BUTTON in
1)
if eww active-windows 2>/dev/null | grep -q "$WINDOW"; then
eww update performance_monitor_visible=false
eww close "$WINDOW"
else
eww update performance_monitor_visible=true
eww open "$WINDOW"
fi
;;
3) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac