update 'xu4q' aliases, add nut script
This commit is contained in:
parent
c5c1a95a34
commit
10d7a78891
2 changed files with 80 additions and 5 deletions
80
scripts/nut.sh
Executable file
80
scripts/nut.sh
Executable file
|
@ -0,0 +1,80 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# author: Daniel Sommer <daniel.sommer@velvettear.de>
|
||||
# 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
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue