2022-10-08 02:31:35 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# ram module for status/stellar
|
|
|
|
|
|
|
|
# values
|
|
|
|
RAM_USED="$(echo "$(free -h --giga | awk '/^Mem/ {print $3}')B")"
|
|
|
|
RAM_TOTAL="$(echo "$(free -h --giga | awk '/^Mem/ {print $2}')B")"
|
|
|
|
RAM_LEFT="$(echo "$(free -h --giga | awk '/^Mem/ {print $7}')B")"
|
|
|
|
ICON="$1"
|
2022-10-08 12:47:57 +02:00
|
|
|
BUTTON="$(cat /tmp/speedwm-button)"
|
|
|
|
|
|
|
|
case "$TERMINAL" in
|
|
|
|
"") TERMINAL=st
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$BUTTON" in
|
|
|
|
"3") $TERMINAL -e htop ;;
|
|
|
|
esac
|
2022-10-08 02:31:35 +02:00
|
|
|
|
|
|
|
# no spacing if there's no icon
|
|
|
|
if [ "$ICON" != "" ]; then
|
2022-10-08 12:47:57 +02:00
|
|
|
ICONSPACING=" " # one character spacing
|
2022-10-08 02:31:35 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# send the notification
|
|
|
|
SEND_NOTIF() {
|
|
|
|
FULL_RAM="$(printf "${ICON}${ICONSPACING}Used: $RAM_USED\nFree: $RAM_LEFT\nTotal: $RAM_TOTAL\n")"
|
|
|
|
notify-send "$FULL_RAM"
|
|
|
|
|
|
|
|
echo "Notification sent successfully!"
|
|
|
|
echo "INFO: $FULL_RAM"
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
command -v notify-send > /dev/null && SEND_NOTIF
|
|
|
|
echo "FATAL: libnotify not installed, can't send notification."
|
|
|
|
|
|
|
|
exit 1
|