7228d3f921
fork in to the makefile.
55 lines
1.3 KiB
Bash
Executable file
55 lines
1.3 KiB
Bash
Executable file
#!/bin/sh
|
|
# news module for status/stellar
|
|
|
|
# load config
|
|
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)"
|
|
|
|
# clicking
|
|
CLICK() {
|
|
# values
|
|
ICON="$ITEM10_ICON"
|
|
|
|
[ "$NEWS_COUNT" = "Error:" ] && return
|
|
[ -e "/tmp/speedwm-button" ] && BUTTON="$(cat /tmp/speedwm-button)" || BUTTON="0"
|
|
[ -z "$TERMINAL" ] && TERMINAL=st
|
|
[ ! -z "$ICON" ] && ICONSPACING=" " # one character spacing
|
|
|
|
# check value of button
|
|
case "$BUTTON" in
|
|
"3") $TERMINAL newsboat ; return ;;
|
|
esac
|
|
|
|
# send the notification
|
|
SEND_NOTIF() {
|
|
notify-send "${ICON}${ICONSPACING}$NEWS_COUNT $ITEM10_TEXT"
|
|
|
|
# some information
|
|
echo "Notification sent successfully!"
|
|
echo "INFO: ${ICON}${ICONSPACING}$NEWS_COUNT $ITEM10_TEXT"
|
|
|
|
return
|
|
}
|
|
|
|
command -v notify-send > /dev/null && SEND_NOTIF || echo "FATAL: libnotify not installed, can't send notification."
|
|
|
|
return
|
|
}
|
|
|
|
# information itself
|
|
PRINT() {
|
|
[ "$NEWS_COUNT" = "Error:" ] && return || echo "$ITEM10_SEPARATOR $ITEM10_ICON $NEWS_COUNT $ITEM10_TEXT"
|
|
}
|
|
|
|
# argument 1
|
|
case "$1" in
|
|
"") CLICK ;;
|
|
"--print-file") PRINT > /tmp/module_news ;;
|
|
"--print") PRINT ;;
|
|
"--click") CLICK ;;
|
|
esac
|