53 lines
1.3 KiB
Plaintext
53 lines
1.3 KiB
Plaintext
|
#!/bin/sh
|
||
|
# cpu temp module for status/stellar
|
||
|
|
||
|
# load config
|
||
|
module_config
|
||
|
[ -e "$HOME/.config/dwm/statusrc" ] && . $HOME/.config/dwm/statusrc
|
||
|
[ "$ENABLE_ITEM8" != "true" ] && exit
|
||
|
[ -e "/tmp/module_temp_hidden" ] && exit
|
||
|
command -v sensors > /dev/null || exit
|
||
|
|
||
|
# click
|
||
|
CLICK() {
|
||
|
# values
|
||
|
ICON="$ITEM8_ICON"
|
||
|
[ -e "/tmp/dwm-button" ] && BUTTON="$(cat /tmp/dwm-button)" || BUTTON="0"
|
||
|
|
||
|
[ "$ITEM8_FORMAT_CELSIUS" = "true" ] || FARG="-F"
|
||
|
[ -z "$TERMINAL" ] && TERMINAL=st
|
||
|
[ -n "$ICON" ] && ICONSPACING=" " # one character spacing
|
||
|
|
||
|
TEMP_FULL="$(sensors $FARG)"
|
||
|
|
||
|
# send the notification
|
||
|
SEND_NOTIF() {
|
||
|
FULL_TEMP="${ICON}${ICONSPACING}$TEMP_FULL"
|
||
|
notify-send "$FULL_TEMP"
|
||
|
|
||
|
# some information
|
||
|
echo "Notification sent successfully!"
|
||
|
echo "INFO: $FULL_TEMP"
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
command -v notify-send > /dev/null && SEND_NOTIF || echo "FATAL: libnotify not installed, can't send notification."
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
# information itself
|
||
|
PRINT() {
|
||
|
[ "$ITEM8_FORMAT_CELSIUS" = "true" ] && TEMP="$(sensors | grep temp1 | awk '{ print $2 }')" || TEMP="$(sensors -f | grep temp1 | awk '{ print $2 }')"
|
||
|
[ -z "$TEMP" ] || echo "$ITEM8_SEPARATOR $ITEM8_ICON $TEMP"
|
||
|
}
|
||
|
|
||
|
# argument 1
|
||
|
case "$1" in
|
||
|
"") CLICK ;;
|
||
|
"--print-file") PRINT > /tmp/module_temp ;;
|
||
|
"--print") PRINT ;;
|
||
|
"--click") CLICK ;;
|
||
|
esac
|