diff --git a/scripts/nut.sh b/scripts/nut.sh new file mode 100755 index 0000000..7adc04e --- /dev/null +++ b/scripts/nut.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +# author: Daniel Sommer +# license: MIT + +url="https://notify.velvettear.de/ups" +user="velvettear" +password="\$Velvet90" + +[[ -z "$1" ]] && printf "error: no argument specified\n" 1>&2 && exit 1 + +ups="eaton" + +charge="$(upsc $ups battery.charge 2> /dev/null)" +time="$(upsc $ups battery.runtime 2> /dev/null)" +time="$(date -d@$time -u '+%H:%M:%S')" + +title="$(printf "$1" | tr '[:upper:]' '[:lower:]')" +prio="default" + +if [[ "$title" == "online" ]]; then + msg="$ups is running on line power +battery @ $charge% | $time" + emoji="electric_plug" +elif [[ "$title" == "onbatt" ]]; then + msg="$ups is running on battery +battery @ $charge% | $time" + prio="high" + emoji="battery" +elif [[ "$title" == "lowbatt" ]]; then + msg="$ups's battery is running low battery @ $charge% | $time" + prio="max" + emoji="exclamation" +elif [[ "$title" == "fsd" ]]; then + msg="forced shutdown in progress" + prio="max" + emoji="bangbang" +elif [[ "$title" == "commok" ]]; then + msg="communication with $ups established" + emoji="heavy_check_mark" +elif [[ "$title" == "commbad" ]]; then + msg="communication with $ups lost" + prio="high" + emoji="x" +elif [[ "$title" == "shutdown" ]]; then + msg="shutdown in progress" + prio="max" + emoji="bangbang" +elif [[ "$title" == "replbatt" ]]; then + msg="$ups's battery is dying and needs to be replaced" + prio="urgent" + emoji="skull_and_crossbones" +elif [[ "$title" == "nocomm" ]]; then + msg="$ups is currently unavailable" + prio="high" + emoji="interrobang" +elif [[ "$title" == "noparent" ]]; then + msg="upsmon parent process died and no further actions are possible" + prio="high" + emoji="skull" +elif [[ "$title" == "cal" ]]; then + msg="$ups is currently calibrating" + emoji="gear" +elif [[ "$title" == "off" ]]; then + msg="$ups is administratively off or asleep" + emoji="grey_exclamation" +elif [[ "$title" == "notoff" ]]; then + msg="$ups is no longer administratively off or asleep" + emoji="grey_exclamation" +elif [[ "$title" == "bypass" ]]; then + msg="$ups is currently bypassed" + emoji="grey_exclamation" +elif [[ "$title" == "notbypass" ]]; then + msg="$ups is no longer bypassed" + emoji="grey_exclamation" +else + printf "error: argument unknown\n" 1>&2 && exit 1 +fi + +curl -u $user:$password -d "$msg" -H "Title: $title" -H "Priority: $prio" -H "Tags: $emoji" $url diff --git a/zsh/conf.d/xu4q b/zsh/conf.d/xu4q index e7d1efc..032150d 100755 --- a/zsh/conf.d/xu4q +++ b/zsh/conf.d/xu4q @@ -17,10 +17,5 @@ alias fetch='pfetch' alias stats='pfetch' alias icat='kitten icat' -# ----- non-ssh aliases ----- # -if [[ -z "$SSH_TTY" ]]; then - alias ssh='kitty +kitten ssh' -fi - # ----- pfetch ----- # export PF_INFO="ascii title host kernel memory wm shell editor pkgs uptime palette"