diff --git a/.config/xmobar/calcurse.sh b/.config/xmobar/calcurse.sh
new file mode 100755
index 0000000..c83a08d
--- /dev/null
+++ b/.config/xmobar/calcurse.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+# Next calcurse item for xmobar: pink " 10:15 | " for an appointment later today, a cyan icon for a whole-day
+# event today, a pink icon alone when the next appointment is tomorrow; empty otherwise.
+# With "list": show today's and tomorrow's items in a notification (for a click on the bar)
+set -uo pipefail
+
+icon=$'\xf3\xb0\x83\xad' # nf-md-calendar, as UTF-8 bytes so the locale doesn't matter
+today=$(date +%F)
+
+query() {
+ calcurse -Q --filter-type cal --days 2 --output-datefmt %F "$@"
+}
+
+if [[ ${1:-} == list ]]; then
+ tomorrow=$(date -d tomorrow +%F)
+ body=$(query --format-apt '%S–%E %m\n' --format-recur-apt '%S–%E %m\n' \
+ --format-event 'all day %m\n' --format-recur-event 'all day %m\n' |
+ sed -e 's/&/\&/g; s/\</g; s/>/\>/g' -e "s/^$today:$/Today:/; s/^$tomorrow:$/Tomorrow:/")
+ notify-send -a calcurse -i x-office-calendar "Calendar" "${body:-Nothing today or tomorrow}"
+ exit
+fi
+
+now=$(date +%s)
+day="" next="" event=false
+while read -r kind start; do
+ case $kind in
+ *:) day=${kind%:} ;;
+ A) [[ -z $next ]] && ((start > now)) && next=$start ;;
+ E) [[ $day == "$today" ]] && event=true ;;
+ esac
+done < <(query --format-apt 'A %s\n' --format-recur-apt 'A %s\n' --format-event 'E\n' --format-recur-event 'E\n')
+
+if [[ -n $next && $(date -d "@$next" +%F) == "$today" ]]; then
+ text="$icon $(date -d "@$next" +%H:%M)"
+elif $event; then
+ text="$icon"
+elif [[ -n $next ]]; then
+ text="$icon"
+else
+ exit 0
+fi
+echo "$text | "
diff --git a/.config/xmobar/xmobarrc_hdmi b/.config/xmobar/xmobarrc_hdmi
index d2c9f5c..1df6071 100644
--- a/.config/xmobar/xmobarrc_hdmi
+++ b/.config/xmobar/xmobarrc_hdmi
@@ -45,17 +45,15 @@ Config { overrideRedirect = True
, ("us" , "US")
, ("sk(qwerty)" , "SK")
]
- , Run Date "\xf133 %a %Y-%m-%d %H:%M" "date" 10
- , Run Uptime
- [ "--template" , "\xf017 d h"
- ] 600
+ , Run Date "\xf133 %a %d/%m %H:%M" "date" 10
, Run Com "/home/fuxino/.config/xmobar/pactl_volume.sh" [] "pactl_volume" 10
, Run Com "/home/fuxino/.config/xmobar/ens_brief.sh" [] "ens_brief" 18000
, Run Com "/home/fuxino/.config/xmobar/updates.sh" [] "updates" 600
, Run Com "/home/fuxino/.config/xmobar/backup.sh" [] "backup" 3600
+ , Run Com "/home/fuxino/.config/xmobar/calcurse.sh" [] "calcurse" 600
, Run UnsafeXMonadLog
]
, sepChar = "%"
, alignSep = "}{"
- , template = " | %UnsafeXMonadLog% } %uptime% | %multicpu% %coretemp% | %memory% | %kbd% { %backup%%updates%%LZIB% · %ens_brief% | %pactl_volume% | %date% "
+ , template = " | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | %kbd% { %calcurse%%backup%%updates%%LZIB% · %ens_brief% | %pactl_volume% | %date% "
}
diff --git a/.config/xmobar/xmobarrc_laptop b/.config/xmobar/xmobarrc_laptop
index 5adf401..070c578 100644
--- a/.config/xmobar/xmobarrc_laptop
+++ b/.config/xmobar/xmobarrc_laptop
@@ -45,18 +45,16 @@ Config { overrideRedirect = True
, ("us" , "US")
, ("sk(qwerty)" , "SK")
]
- , Run Date "\xf133 %a %Y-%m-%d %H:%M" "date" 10
- , Run Uptime
- [ "--template" , "\xf017 d h"
- ] 600
+ , Run Date "\xf133 %a %d/%m %H:%M" "date" 10
, Run XPropertyLog "_XMONAD_TRAYPAD"
, Run Com "/home/fuxino/.config/xmobar/pactl_volume.sh" [] "pactl_volume" 10
, Run Com "/home/fuxino/.config/xmobar/ens_brief.sh" [] "ens_brief" 18000
, Run Com "/home/fuxino/.config/xmobar/updates.sh" [] "updates" 600
, Run Com "/home/fuxino/.config/xmobar/backup.sh" [] "backup" 3600
+ , Run Com "/home/fuxino/.config/xmobar/calcurse.sh" [] "calcurse" 600
, Run UnsafeXMonadLog
]
, sepChar = "%"
, alignSep = "}{"
- , template = " | %UnsafeXMonadLog% } %uptime% | %multicpu% %coretemp% | %memory% | %kbd% { %backup%%updates%%LZIB% · %ens_brief% | %pactl_volume% | %date% %_XMONAD_TRAYPAD% "
+ , template = " | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | %kbd% { %calcurse%%backup%%updates%%LZIB% · %ens_brief% | %pactl_volume% | %date% %_XMONAD_TRAYPAD% "
}