#!/bin/sh

case $(printf "%s\n" "  Lock session" "󰍃  Log out" "󱂬  Kill process" "󰤄  Suspend" "  Reboot" "󰐥  Shut down" | fuzzel -d -l 7) in
  "  Lock session")
    swaylock
    ;;
  "󰍃  Log out")
    if pidof dwl > /dev/null; then
      kill "$(pidof dwl)"
    elif pidof river > /dev/null; then
      kill "$(pidof river)"
    fi
    ;;
  "󱂬  Kill process")
    ps -o pid,comm,user | \
      awk -v u="$USER" '$3 == u { print $1, $2 }' | \
      fuzzel -d -l 10 -p "Kill: " | awk '{ print $1 }' | \
      xargs -r kill 
    ;;
  "󰤄  Suspend")
    loginctl suspend
    ;;
  "  Reboot")
    loginctl reboot
    ;;
  "󰐥  Shut down")
    loginctl poweroff
esac

