75 lines
1.5 KiB
Bash
Executable file
75 lines
1.5 KiB
Bash
Executable file
#!/bin/sh
|
|
# cpu temp module for status/stellar
|
|
|
|
# load config
|
|
. $HOME/.config/speedwm-de/status/config
|
|
BINDIR="$(dirname $(command -v status))/"
|
|
|
|
ARG1="$1"
|
|
|
|
# click
|
|
CLICK() {
|
|
# values
|
|
ICON="$ITEM8_ICON"
|
|
BUTTON="$(cat /tmp/speedwm-button)"
|
|
|
|
if [ "$ITEM8_FORMAT_CELSIUS" != "true" ]; then
|
|
FARG="-F"
|
|
fi
|
|
|
|
if [ ! -e "/tmp/iscelsius" ]; then
|
|
if [ "$FARG" = "" ]; then
|
|
FARG="-F"
|
|
fi
|
|
fi
|
|
|
|
TEMP_FULL="$(sensors $FARG)"
|
|
command -v sensors > /dev/null || exit 1
|
|
|
|
case "$TERMINAL" in
|
|
"") TERMINAL=st
|
|
esac
|
|
|
|
# no spacing if there's no icon
|
|
if [ "$ICON" != "" ]; then
|
|
ICONSPACING=" " # one character spacing
|
|
fi
|
|
|
|
# send the notification
|
|
SEND_NOTIF() {
|
|
FULL_TEMP="${ICON}${ICONSPACING}$TEMP_FULL"
|
|
notify-send "$FULL_TEMP"
|
|
|
|
echo "Notification sent successfully!"
|
|
echo "INFO: $FULL_TEMP"
|
|
|
|
exit 0
|
|
}
|
|
|
|
command -v notify-send > /dev/null && SEND_NOTIF
|
|
echo "FATAL: libnotify not installed, can't send notification."
|
|
|
|
exit 1
|
|
}
|
|
|
|
# information itself
|
|
PRINT() {
|
|
if [ "$ENABLE_ITEM8" = "true" ]; then
|
|
if [ -e "${BINDIR}sensors" ]; then
|
|
if [ "$ITEM8_FORMAT_CELSIUS" = "true" ]; then
|
|
echo "$SEPARATOR $ITEM8_ICON $(sensors | grep temp1 | awk '{ print $2 }')"
|
|
touch /tmp/iscelsius
|
|
else
|
|
echo "$SEPARATOR $ITEM8_ICON $(sensors -f | grep temp1 | awk '{ print $2 }')"
|
|
fi
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# argument 1
|
|
case "$ARG1" in
|
|
"") CLICK ;;
|
|
"--print") PRINT > /tmp/module_temp ;;
|
|
"--click") CLICK ;;
|
|
esac
|