From 10d7a78891085272a43383ea0efd29cd6b944ec2 Mon Sep 17 00:00:00 2001 From: velvettear Date: Wed, 16 Oct 2024 15:50:26 +0200 Subject: [PATCH] update 'xu4q' aliases, add nut script --- scripts/nut.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ zsh/conf.d/xu4q | 5 ---- 2 files changed, 80 insertions(+), 5 deletions(-) create mode 100755 scripts/nut.sh 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"