[Remind-Fans] controlling the outpur of -s

tsr.offentlig at tsr.se tsr.offentlig at tsr.se
Tue Jun 22 14:56:51 EDT 2010


El Tue, 22 Jun 2010 16:47:51 +0100
Andrew Ho <andrewho at andrewho.co.uk> escribió:
> tsr.offentlig at tsr.se <tsr.offentlig at tsr.se> wrote [2010-06-22 14:09
> +0200]:
> >I've just discovered remind and I think I've finnaly managed to set 
> >up my national holidays (will post on 43folders-wiki soon)
> 
> Last time I tried, the 43folders wiki wasn't letting me create an 
> account.  If we really have become unable to update that wiki,
> perhaps we should think about setting up another one (I have some
> scripts that might be of interest to British remind users).
> 

This seems like a good idea.

> >2) The output is almost perfect (I want to incorporate the
> >wekk-nr-thing I saw in the mail archive) but I wonder if I can
> >reformat it so that:
> >2010/06/22 * peradm 60 900 15:00-16:00 appointment-text-consorship
> >becomes:
> >Tue 2010-06-22 15:00-16:00 [peradm]  appointment-text-consorship Wen 
> 
> You could this with (g)awk quite easily -- it's what I use to 
> manipulate remind.  Just pipe the output through:
> 
> [snip...see previous msg for details]
>
> YMMV; you may want to tweak that script as it's just what I hacked up 
> and may not be robust enough.

Yes. my mileage with awk is at 10 meters atm, but still I managed to
tweak it perfectly, thanks! Here is what I came up with:

#!/usr/bin/gawk -f

{
	wday = strftime("s.%W - %a", mktime(gensub(/\//, " ", "g", $1)
" 00 00 00"))
	wdayInt = strftime("%w", mktime(gensub(/\//, " ", "g", $1) " 00
00 00"))
	date = strftime("%Y-%m-%d", mktime(gensub(/\//, " ", "g", $1) "
00 00 00"))
	time = ($5 == "*") ? "" : $6
	
	if ($3 == "*") tag = "";
	else if ($3 == "helg") {
		tag = "";
		dateColor = "\033[02;31m";
	}
	else if (wdayInt == 0) {
		tag = "[" $3 "]";
		dateColor = "\033[02;31m";
	}
	else {
		tag = "[" $3 "]";
		dateColor = "\033[0m";
	}

	body = ($5 == "*") ? substr($0, length($1 $2 $3 $4 $5) + 6) :
	substr($0, length($1 $2 $3 $4 $5 $6) + 7)
	printf "\033[02;32m%s %s%s \033[02;32m%-11s \033[02;33m%-8s
	\033[0m%s\n", wday, dateColor, date, time, tag, body
}

This script parses the lines and:
1) if there isn't any duration info adjusts to that
2) for sundays colors the date in red
3) for REMs tagged with 'helg' (holiday in swedish) colors the date in
red (so I also had to tag all national holidays with helg, but that is
ok I think)
4) colors the week-nbr, week-day and time in green
5) colors the tag in yellow

 I also discovered that the "dur" mentioned before and in
rem2ps-manpage consists of two fields: first the starttime as minutes
from midnight and then the duration expressed like "1pm-2pm". This
required some adjustment, but nothing too hard.

One step closer... (now I will add an alias for #: rem -m -s+2 -b1 |
/path/to/gawk_script and ask conky to run that, lets see...) 


/Tomas



More information about the Remind-fans mailing list