2022-10-21 13:35:02 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# news module for status/stellar
|
|
|
|
|
|
|
|
# load config
|
2022-11-27 01:12:14 +01:00
|
|
|
module_config
|
|
|
|
[ -e "$HOME/.config/speedwm/statusrc" ] && . $HOME/.config/speedwm/statusrc
|
|
|
|
[ "$ENABLE_ITEM10" = "true" ] || exit
|
|
|
|
command -v newsboat > /dev/null || exit
|
|
|
|
|
|
|
|
NEWS_COUNT="$(newsboat -x print-unread | awk '{ print $1 }' || return)"
|
2022-10-21 13:35:02 +02:00
|
|
|
|
|
|
|
# clicking
|
|
|
|
CLICK() {
|
|
|
|
# values
|
|
|
|
ICON="$ITEM10_ICON"
|
|
|
|
|
2022-11-27 01:12:14 +01:00
|
|
|
[ "$NEWS_COUNT" = "Error:" ] && return
|
|
|
|
[ -e "/tmp/speedwm-button" ] && BUTTON="$(cat /tmp/speedwm-button)" || BUTTON="0"
|
|
|
|
[ -z "$TERMINAL" ] && TERMINAL=st
|
2022-12-16 17:35:03 +01:00
|
|
|
[ -n "$ICON" ] && ICONSPACING=" " # one character spacing
|
2022-10-21 13:35:02 +02:00
|
|
|
|
2022-11-27 01:12:14 +01:00
|
|
|
# check value of button
|
2022-10-21 13:35:02 +02:00
|
|
|
case "$BUTTON" in
|
2022-11-27 01:12:14 +01:00
|
|
|
"3") $TERMINAL newsboat ; return ;;
|
2022-10-21 13:35:02 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
# send the notification
|
|
|
|
SEND_NOTIF() {
|
|
|
|
notify-send "${ICON}${ICONSPACING}$NEWS_COUNT $ITEM10_TEXT"
|
|
|
|
|
2022-11-27 01:12:14 +01:00
|
|
|
# some information
|
2022-10-21 13:35:02 +02:00
|
|
|
echo "Notification sent successfully!"
|
|
|
|
echo "INFO: ${ICON}${ICONSPACING}$NEWS_COUNT $ITEM10_TEXT"
|
|
|
|
|
2022-11-27 01:12:14 +01:00
|
|
|
return
|
2022-10-21 13:35:02 +02: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."
|
2022-10-21 13:35:02 +02:00
|
|
|
|
2022-11-27 01:12:14 +01:00
|
|
|
return
|
2022-10-21 13:35:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# information itself
|
|
|
|
PRINT() {
|
2022-11-27 01:12:14 +01:00
|
|
|
[ "$NEWS_COUNT" = "Error:" ] && return || echo "$ITEM10_SEPARATOR $ITEM10_ICON $NEWS_COUNT $ITEM10_TEXT"
|
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_news ;;
|
|
|
|
"--print") PRINT ;;
|
2022-10-21 13:35:02 +02:00
|
|
|
"--click") CLICK ;;
|
|
|
|
esac
|