speedwm-personal/modules/module_date
speediegq 38caf833c8 Add net status, modify existing modules to use previous commit, use
wildcards in Makefile, not sure why I haven't done this earlier
2022-10-08 12:47:57 +02:00

42 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
# date module for status/stellar
# values
DATE_DAY="$(date +%d)" # day number
DATE_DAY_OF_YEAR="$(date +%j)" # year day number
DATE_DAY_W_SHORT="$(date +%a)" # short day (ie. mon)
DATE_DAY_W_LONG="$(date +%A)" # long day (ie. monday)
DATE_MONTH="$(date +%m)" # month number
DATE_MONTH_W_SHORT="$(date +%b)" # short month (ie. oct)
DATE_MONTH_W_LONG="$(date +%B)" # long month (ie. october)
DATE_YEAR="$(date +%Y)" # year number
DATE_WEEK="$(date +%W)" # week number
DATE_WEEKDAY="$(date +%w)" # day of the week in number
ICON="$1" # icon is first argument
BUTTON="$(cat /tmp/speedwm-button)" # button
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_DATE="$(printf "${ICON}${ICONSPACING}$DATE_DAY_W_LONG, $DATE_MONTH_W_LONG, $DATE_DAY $DATE_YEAR\nWeek: $DATE_WEEK\nDay of the week: $DATE_WEEKDAY")"
notify-send "$FULL_DATE"
echo "Notification sent successfully!"
echo "INFO: $FULL_DATE"
exit 0
}
command -v notify-send > /dev/null && SEND_NOTIF
echo "FATAL: libnotify not installed, can't send notification."
exit 1