Calendar (en)
From Conky PitStop
Contents |
Calendar
Language | English Français |
Option #1 calendario.sh - with a fix
In Spacing, I showed you two lines that put a calendar into my conky that uses the calendario.sh script.
Those lines:
${font LCDMono:size=19}${color2}${pre_exec ~/Conky/scripts/calendario.sh semana} ${color 888888}${pre_exec ~/Conky/scripts/calendario.sh pasado}${color2}${pre_exec ~/Conky/scripts/calendario.sh hoy}${color 888888}${pre_exec ~/Conky/scripts/calendario.sh futuro}${font}
UPDATE: Thanks to stinkeye. 'cal' started acting funny a while back. stinkeye has a fix, where the script uses "cal |" make these changes:
Start on Monday:
ncal -M -C -h |
Start on Sunday:
ncal -C -h |
And the calendario.sh script - with ncal:
#! /bin/sh # written by: jjgomera # # ncal by stinkeye #Start on Monday: # ncal -M -C -h | #Start on Sunday: # ncal -C -h | #str=`echo '\033[01;32m29'` # original comment for "cal" # replace the 4 "cal |" with "cal -m |" to have the week start on Monday DATE=`date | awk -F" " '{print $3}'` case "$1" in mes) ncal -C -h | head -n1 ;; semana) ncal -C -h | head -n2 | tail -n1 ;; pasado) ncal -C -h | grep -v '[a-zA-Z]' | grep '[0-9]' | awk -F$DATE ' BEGIN {i=0} ($1 == $0 && i==0) {print $1}($1 != $0 && i==0){i=i+1;print $1}'; ;; hoy) echo $DATE; ;; futuro) ncal -C -h | grep -v '[a-zA-Z]' | grep '[0-9]' | awk -F$DATE ' BEGIN {i=1} (i==0) {print $0}($1 != $0 && i==1){i=i-1;print $2}'; ;; esac
Now make that “executable” and conky can use it.
Option #2 calendario.sh - highlight day as well
From: stinkeye
You can also highlight the day of the week by changing this line...
ncal -M -C -h | head -n2 | tail -n1
to
ncal -M -C -h | head -n2 | tail -n1 | sed 's/'$DAY'/${color CC9846}'$DAY'${color 919FAA}/g'
so you get the day of the week as well as the date highlighted.
First ${color CC9846} is the highlight and ${color 919FAA} takes you back to the original colour.
Needs to have...
DAY=`date +%a | cut -c1-2`
in the calendario.sh for the day highlight to work.
#! /bin/sh # written by: jjgomera # modified by stinkeye #str=`echo '\033[01;32m29'` # # replace the 4 "cal |" with "cal -m |" to have the week start on Monday DATE=`date | awk -F" " '{print $3}'` [COLOR="Red"]DAY=`date +%a | cut -c1-2`[/COLOR] case "$1" in mes) ncal -M -C -h | head -n1 ;; semana) ncal -M -C -h | head -n2 | tail -n1 [COLOR="red"]| sed 's/'$DAY'/${color CC9846}'$DAY'${color 919FAA}/g'[/COLOR] ;; pasado) ncal -M -C -h | grep -v '[a-zA-Z]' | grep '[0-9]' | awk -F$DATE ' BEGIN {i=0} ($1 == $0 && i==0) {print $1}($1 != $0 && i==0){i=i+1;print $1}'; ;; hoy) echo $DATE; ;; futuro) ncal -M -C -h | grep -v '[a-zA-Z]' | grep '[0-9]' | awk -F$DATE ' BEGIN {i=1} (i==0) {print $0}($1 != $0 && i==1){i=i-1;print $2}'; ;; esac
Nicely done stinkeye!
Option #3 one liner - with a fix
Crinos512
April 26th, 2009 at 06:29
That whole script can be replaced with: ncal -C -h | works here too after a fashion, horizontal spacing is strange
${color 888888}${font LCDMono:bold:size=12}${execpi 60 DJS=`date +%_d`; cal | sed '1d' | sed '/./!d' | sed 's/$/ /' | fold -w 21 | sed -n '/^.\{21\}/p' | sed 's/^/${alignc} /' | sed /" $DJS "/s/" $DJS "/" "'${color2}'"$DJS"'${color 888888}'" "/}
I can’t claim to have crafted that code, but I wish I could and it looks like: