SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#7 Re: Tips, Tricks & Scripts » Conky v1.9 Thread » 2013-07-23 16:45:02

crinos@Fortress:~$ time ./cal.C512.sh 
Su ·· 14 28
Mo 01 15 29
Tu 02 16 30
We 03 17 31
Th 04 18 ··
Fr 05 19 ··
Sa 06 20 ··
Su 07 21 ··
Mo 08 22 ··
Tu 09 ${color6}23${color} ··
We 10 24 ··
Th 11 25 ··
Fr 12 26 ··
Sa 13 27 ··


real    0m0.013s
user    0m0.004s
sys     0m0.000s

#8 Re: Tips, Tricks & Scripts » Conky v1.9 Thread » 2013-07-23 02:07:29

#!/bin/bash
# Crinos512 - 22 July 2013
# /media/5/Conky/scripts/cal.C512.sh
LAR=`date +%d`

ncal -h | sed -e 's/     /  ··  /g' | sed -e '1d' -e 's/\<'$LAR'\>/${color6}&${color}/' | awk  '{if (length($2)==1) { $2 = "0"  $2 ; }print $1, $2, $4, $6}' | tail -n7
ncal -h | sed -e 's/     /  ··  /g' | sed -e '1d' -e 's/\<'$LAR'\>/${color6}&${color}/' | awk  '{{if (length($3)==1) { $3 = "0"  $3 ; }{if (length($7)<1) { $7 = "--"  $7 ; }}} print $1, $3, $5, $7}' | tail -n7

#9 Re: Tips, Tricks & Scripts » Conky v1.9 Thread » 2013-07-22 20:10:08

You only need LAR defined once.

#!/bin/bash
# Crinos512 - 22 July 2013
# /media/5/Conky/scripts/cal.C512.sh
LAR=`date +%d`

ncal -h | sed -e 's/     /  ··  /g' | sed -e '1d' -e 's/\<'$LAR'\>/${color6}&${color}/' | awk  '{if (length($2)==1) { $2 = "0"  $2 ; }print $1, $2, $4, $6}' | tail -n7
ncal -h | sed -e 's/     /  ··  /g' | sed -e '1d' -e 's/\<'$LAR'\>/${color6}&${color}/' | awk  '{{if (length($3)==1) { $3 = "0"  $3 ; }{if (length($7)<1) { $7 = "--"  $7 ; }}} print $1, $3, $5, $7}' | tail -n7

#10 Re: Tips, Tricks & Scripts » Conky v1.9 Thread » 2013-07-22 19:36:40

ok, one more drop...  angel

ncal | sed -e 's/     /  --  /g' | awk  '{if (length($2)==1) { $2 = "0"  $2 ; } print $1, $2, $4, $6}' | tail -n7 && ncal | sed -e 's/     /  --  /g' | awk  '{{if (length($3)==1) { $3 = "0"  $3 ; }{if (length($7)<1) { $7 = "--"  $7 ; }}} print $1, $3, $5, $7}' | tail -n7
 

Produces

Su -- 14 28
Mo 01 15 29
Tu 02 16 30
We 03 17 31
Th 04 18 --
Fr 05 19 --
Sa 06 20 --
Su 07 21 --
Mo 08 22 --
Tu 09 23 --
We 10 24 --
Th 11 25 --
Fr 12 26 --
Sa 13 27 --

Remember you have 2 SED commands to do the coloration on.... each controls 7 rows.

#11 Re: Tips, Tricks & Scripts » Conky v1.9 Thread » 2013-07-22 18:14:15

ncal | sed -e 's/     /  --  /g' | awk  '{if (length($2)==1) { $2 = "0"  $2 ; }print $1, $2, $4, $6}' &&  ncal | sed -e 's/     /  --  /g' | awk  '{if (length($3)==1) { $3 = "0"  $3 ; }print $1, $3, $5, $7}' |tail -n7

#12 Re: Tips, Tricks & Scripts » Conky v1.9 Thread » 2013-07-22 17:54:42

OK, July spans 5 weeks, does he want it in 2 columns, or 14 rows?

And yes, you are dead on with the coloring for the current date.  big_smile

#13 Re: Tips, Tricks & Scripts » Conky v1.9 Thread » 2013-07-22 17:01:41

It's not too bad for a oneliner... My conky is a bit rusty but you could just run the whole thing as:

{exec 60 ncal | sed -e 's/     /  --  /g' | awk  '{if (length($2)==1) { $2 = "0"  $2 ; }print $1, $2, $5}' &&  ncal | sed -e 's/     /  --  /g' | awk  '{if (length($3)==1) { $3 = "0"  $3 ; }print $1, $3, $6}' |tail -n7 &&  ncal | sed -e 's/     /  --  /g' | awk  '{if (length($7)<1) { $7 = "--"  $7 ; }print $1, $4, $7}' |tail -n7}

as a bash script it's more readable:

#!/bin/bash

ncal | sed -e 's/     /  --  /g' | awk  '{if (length($2)==1) { $2 = "0"  $2 ; }print $1, $2, $5}' 
ncal | sed -e 's/     /  --  /g' | awk  '{if (length($3)==1) { $3 = "0"  $3 ; }print $1, $3, $6}' | tail -n7
ncal | sed -e 's/     /  --  /g' | awk  '{if (length($7)<1)  { $7 = "--"  $7 ; }print $1, $4, $7}' | tail -n7

...then you could just do the

{execpi 60 ./nameofscript.sh}

This should also allow you to pull the current date into a variable (inside the script) with

date '+d%'

which you can then sed to add your day's formatting. Easy right? smile

I'll try to wrap it all up together in a bit... have a sick server to look at right quick.

#14 Re: Tips, Tricks & Scripts » Conky v1.9 Thread » 2013-07-22 15:21:38

ncal | sed -e 's/     /  --  /g' | awk  '{if (length($2)==1) { $2 = "0"  $2 ; }print $1, $2, $5}' &&  ncal | sed -e 's/     /  --  /g' | awk  '{if (length($3)==1) { $3 = "0"  $3 ; }print $1, $3, $6}' |tail -n7 &&  ncal | sed -e 's/     /  --  /g' | awk  '{if (length($7)<1) { $7 = "--"  $7 ; }print $1, $4, $7}' |tail -n7

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo