xmobar: show the next calcurse appointment
Time of today's next appointment, or an icon for a whole-day event today or an appointment tomorrow; click lists both days, right-click opens the calcurse scratchpad. Uptime dropped and the date shortened to make room.
This commit is contained in:
3 files changed
+48
-10
No files matched your search
Executable
+42
@@ -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="<fc=#ff79c6>$icon $(date -d "@$next" +%H:%M)</fc>"
|
||||||
|
elif $event; then
|
||||||
|
text="<fc=#8be9fd>$icon</fc>"
|
||||||
|
elif [[ -n $next ]]; then
|
||||||
|
text="<fc=#ff79c6>$icon</fc>"
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "$text | "
|
||||||
@@ -45,17 +45,15 @@ Config { overrideRedirect = True
|
|||||||
, ("us" , "<fc=#ffb86c>US</fc>")
|
, ("us" , "<fc=#ffb86c>US</fc>")
|
||||||
, ("sk(qwerty)" , "<fc=#ff5555>SK</fc>")
|
, ("sk(qwerty)" , "<fc=#ff5555>SK</fc>")
|
||||||
]
|
]
|
||||||
, Run Date "\xf133 %a %Y-%m-%d <fc=#ff79c6>%H:%M</fc>" "date" 10
|
, Run Date "\xf133 %a %d/%m <fc=#ff79c6>%H:%M</fc>" "date" 10
|
||||||
, Run Uptime
|
|
||||||
[ "--template" , "\xf017 <days>d <hours>h"
|
|
||||||
] 600
|
|
||||||
, Run Com "/home/fuxino/.config/xmobar/pactl_volume.sh" [] "pactl_volume" 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/ens_brief.sh" [] "ens_brief" 18000
|
||||||
, Run Com "/home/fuxino/.config/xmobar/updates.sh" [] "updates" 600
|
, 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/backup.sh" [] "backup" 3600
|
||||||
|
, Run Com "/home/fuxino/.config/xmobar/calcurse.sh" [] "calcurse" 600
|
||||||
, Run UnsafeXMonadLog
|
, Run UnsafeXMonadLog
|
||||||
]
|
]
|
||||||
, sepChar = "%"
|
, sepChar = "%"
|
||||||
, alignSep = "}{"
|
, alignSep = "}{"
|
||||||
, template = " | %UnsafeXMonadLog% } %uptime% | %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%LZIB% <fc=#565f89>·</fc> %ens_brief%</action> | %pactl_volume% | <action=`env GDK_DPI_SCALE=1.25 gsimplecal`>%date%</action> "
|
, template = " | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%LZIB% <fc=#565f89>·</fc> %ens_brief%</action> | %pactl_volume% | <action=`env GDK_DPI_SCALE=1.25 gsimplecal`>%date%</action> "
|
||||||
}
|
}
|
||||||
@@ -45,18 +45,16 @@ Config { overrideRedirect = True
|
|||||||
, ("us" , "<fc=#ffb86c>US</fc>")
|
, ("us" , "<fc=#ffb86c>US</fc>")
|
||||||
, ("sk(qwerty)" , "<fc=#ff5555>SK</fc>")
|
, ("sk(qwerty)" , "<fc=#ff5555>SK</fc>")
|
||||||
]
|
]
|
||||||
, Run Date "\xf133 %a %Y-%m-%d <fc=#ff79c6>%H:%M</fc>" "date" 10
|
, Run Date "\xf133 %a %d/%m <fc=#ff79c6>%H:%M</fc>" "date" 10
|
||||||
, Run Uptime
|
|
||||||
[ "--template" , "\xf017 <days>d <hours>h"
|
|
||||||
] 600
|
|
||||||
, Run XPropertyLog "_XMONAD_TRAYPAD"
|
, Run XPropertyLog "_XMONAD_TRAYPAD"
|
||||||
, Run Com "/home/fuxino/.config/xmobar/pactl_volume.sh" [] "pactl_volume" 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/ens_brief.sh" [] "ens_brief" 18000
|
||||||
, Run Com "/home/fuxino/.config/xmobar/updates.sh" [] "updates" 600
|
, 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/backup.sh" [] "backup" 3600
|
||||||
|
, Run Com "/home/fuxino/.config/xmobar/calcurse.sh" [] "calcurse" 600
|
||||||
, Run UnsafeXMonadLog
|
, Run UnsafeXMonadLog
|
||||||
]
|
]
|
||||||
, sepChar = "%"
|
, sepChar = "%"
|
||||||
, alignSep = "}{"
|
, alignSep = "}{"
|
||||||
, template = " | %UnsafeXMonadLog% } %uptime% | %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%LZIB% <fc=#565f89>·</fc> %ens_brief%</action> | %pactl_volume% | <action=`env GDK_DPI_SCALE=1.25 gsimplecal`>%date%</action> %_XMONAD_TRAYPAD% "
|
, template = " | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%LZIB% <fc=#565f89>·</fc> %ens_brief%</action> | %pactl_volume% | <action=`env GDK_DPI_SCALE=1.25 gsimplecal`>%date%</action> %_XMONAD_TRAYPAD% "
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user