2022-10-08 14:36:30 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# cpu temp module for status/stellar
|
|
|
|
|
2022-10-21 13:35:02 +02:00
|
|
|
# load config
|
2022-11-27 01:12:14 +01:00
|
|
|
module_config
|
|
|
|
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
|
|
|
|
[ "$ENABLE_ITEM8" != "true" ] && exit
|
2022-12-22 23:11:38 +01:00
|
|
|
[ -e "/tmp/module_temp_hidden" ] && exit
|
2022-11-27 01:12:14 +01:00
|
|
|
command -v sensors > /dev/null || exit
|
2022-10-08 18:07:28 +02:00
|
|
|
|
2022-10-21 13:35:02 +02:00
|
|
|
# click
|
|
|
|
CLICK() {
|
2022-11-27 01:12:14 +01:00
|
|
|
# values
|
|
|
|
ICON="$ITEM8_ICON"
|
|
|
|
[ -e "/tmp/speedwm-button" ] && BUTTON="$(cat /tmp/speedwm-button)" || BUTTON="0"
|
2022-12-22 23:11:38 +01:00
|
|
|
|
2022-11-27 01:12:14 +01:00
|
|
|
[ "$ITEM8_FORMAT_CELSIUS" = "true" ] || FARG="-F"
|
|
|
|
[ -z "$TERMINAL" ] && TERMINAL=st
|
2022-12-16 17:35:03 +01:00
|
|
|
[ -n "$ICON" ] && ICONSPACING=" " # one character spacing
|
2022-11-27 01:12:14 +01:00
|
|
|
|
|
|
|
TEMP_FULL="$(sensors $FARG)"
|
2022-12-22 23:11:38 +01:00
|
|
|
|
2022-11-27 01:12:14 +01:00
|
|
|
# send the notification
|
|
|
|
SEND_NOTIF() {
|
|
|
|
FULL_TEMP="${ICON}${ICONSPACING}$TEMP_FULL"
|
|
|
|
notify-send "$FULL_TEMP"
|
2022-12-22 23:11:38 +01:00
|
|
|
|
2022-11-27 01:12:14 +01:00
|
|
|
# some information
|
|
|
|
echo "Notification sent successfully!"
|
|
|
|
echo "INFO: $FULL_TEMP"
|
2022-12-22 23:11:38 +01:00
|
|
|
|
2022-11-27 01:12:14 +01:00
|
|
|
return
|
|
|
|
}
|
2022-12-22 23:11:38 +01:00
|
|
|
|
2022-11-27 01:12:14 +01:00
|
|
|
command -v notify-send > /dev/null && SEND_NOTIF || echo "FATAL: libnotify not installed, can't send notification."
|
|
|
|
|
|
|
|
return
|
2022-10-08 14:36:30 +02:00
|
|
|
}
|
|
|
|
|
2022-10-21 13:35:02 +02:00
|
|
|
# information itself
|
|
|
|
PRINT() {
|
2022-11-27 01:12:14 +01:00
|
|
|
[ "$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"
|
2022-10-21 13:35:02 +02:00
|
|
|
}
|
2022-10-08 14:36:30 +02:00
|
|
|
|
2022-10-21 13:35:02 +02:00
|
|
|
# argument 1
|
2022-11-27 01:12:14 +01:00
|
|
|
case "$1" in
|
2022-10-21 13:35:02 +02:00
|
|
|
"") CLICK ;;
|
2022-11-26 19:16:22 +01:00
|
|
|
"--print-file") PRINT > /tmp/module_temp ;;
|
|
|
|
"--print") PRINT ;;
|
2022-10-21 13:35:02 +02:00
|
|
|
"--click") CLICK ;;
|
|
|
|
esac
|