A dmenu calendar.

git clone git://watertao.xyz/programs/calcurse_dmenu.git

commit 663ec708584c1aeba7fd5ea7dec268adb21f8c41
parent 523b2c644513ebc3cf4ac4b26a0b648b626ba06e
Author: Jeff <dev@watertao.xyz>
Date:   Sun, 10 Aug 2025 17:10:18 -0700

Added month and year change distinctions in entries view

Diffstat:
Mcalcurse_dmenu.sh | 5++---
Mentries.awk | 83++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
Mentries.sh | 5++---
3 files changed, 57 insertions(+), 36 deletions(-)

diff --git a/calcurse_dmenu.sh b/calcurse_dmenu.sh @@ -34,12 +34,11 @@ cal_lno_dmenu_string(){ __cal_title(){ s="$S_TITLE" - d="$(date +"%A, %B %d %Y")" + #d="$(date +"%A, %B %d %Y")" case "$typeflag" in - "h") s="$S_HISTORY | $d" ;; + "h") s="$S_HISTORY" ;; "t") s="$S_TODO" ;; "a") s="$S_ALARM" ;; - *) s="$d" ;; esac printf "%s" "$s" } diff --git a/entries.awk b/entries.awk @@ -51,17 +51,31 @@ function date_fmt_from_regex( rgx, mmax ) function print_seperator() { - if ( date_type == "day" ){ - if ( $1 != pdate ){ - pdate = $1 - print sseperator + + if (date_type == "day") { + if (rdate != pdate) { + pdate = rdate + if (pr_count > 1) { print "" } + } + } else if ((p_date_type != date_type) && (date_type != "etal")) { + print "" + } else { + m = substr(rdate, 5, 2) + y = substr(rdate, 1, 4) + if (y != yr) { + yr = y + print "" + print " ---- " + print "[ " y " ]" + print " ---- " + } + if (rdate != pdate && m != mnth) { + pdate = rdate + mnth = m + print "" + print " < " m " >" } - }else if ( p_date_type != date_type ){ - print sseperator } - - # Add Month names and Years - } function entry_out() @@ -71,6 +85,10 @@ function entry_out() return 0 } + pr_count++ + + get_etype() + m_date = ""; m_desc = ""; m_note = "" # Format dates @@ -131,17 +149,7 @@ function entry_out() return 0 } -BEGIN{ - cdate = strftime( "%Y%m%d" ) - yr = substr( 1, 4, cdate ) - mnth = substr( 5, 2, cdate ) - epoch = strftime( "%s" ) - cyr = strftime( "%Y" ) - ymd_x = "^[0-9]{8}" - e_type = "" - dmax_ymd = int(strftime( "%Y%m%d", dmax )) -} - +function get_etype() { if ( match( $0, ymd_x" @" )){ e_type = "apt" @@ -150,21 +158,36 @@ BEGIN{ } else if ( match( $0, /^\[/ )){ e_type = "todo" } - # if showing hereafter or hitherto today, print, else exit - if ( ( $1 >= cdate && caltype == "c" ) || ( $1 < cdate && caltype == "h" ) ){ - if ( $1 <= dmax_ymd ){ +} + +BEGIN{ + cdate = strftime( "%Y%m%d" ) + yr = cyr = substr( cdate, 1, 4 ) + mnth = substr( cdate, 5, 2 ) + epoch = strftime( "%s" ) + ymd_x = "^[0-9]{8}" + e_type = "" + dmax_ymd = int( strftime( "%Y%m%d", dmax )) + pr_count = 0 +} + +{ + rdate = $1 + if ( caltype == "t" ) { + entry_out() + next + } else if ($1 > dmax_ymd) { + exit + } else if (caltype == "c" || caltype == "a") { + if ($1 >= cdate) { entry_out() } next - } else if ( $1 >= cdate && caltype == "a" ){ - if ( $1 <= dmax_ymd ){ + } else if (caltype == "h") { + if ($1 < cdate) { entry_out() } next - } else if ( caltype == "t" ) { - entry_out() - next - } else { - exit } + exit } diff --git a/entries.sh b/entries.sh @@ -14,7 +14,7 @@ dmax="${1:-"$(date -d "5 Year" +%s)"}" datapretty="${2:-"1"}" f="$cal_apts" -[ "$caltype" = "h" ] && sflag="" || sflag="-r" +[ "$caltype" = "h" ] && sflag="-r" || sflag="" [ "$caltype" = "t" ] && f="$cal_todo" [ "$caltype" = "a" ] && f="$cal_alarm" @@ -41,5 +41,4 @@ awk \ -v sseperator="$S_SEPERATOR" \ -v caltype="$caltype" \ -v dp="$datapretty" \ - -f "$PROGDIR/entries.awk" | \ -tac + -f "$PROGDIR/entries.awk"