Tuesday, 25 August 2009

More playing...And how to change upper- to lower-case

One of the other things I've wanted to play with for a while is sideways text...Just to broaden the look of Conky that much more!

With the help of Johnny B, I used BlockyCounterClockwise to get the following:
From Screenshots

One of the challenges of this was that this particular font reverses the rotation of letters if you type in captials, so when you run the ${execi 60 date} command, the capitals in the output look upside down! I tried setting the "uupercase yes" config variable, but that just made all the text be the opposite rotation from the numbers!

So I had to figure out how to take any single capitals in the date output and change them to lowercase...After a quick Google search, I found:
sed y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz

Not the prettiest method, but it works! To use it, simply pipe the date output into it, like so:
${execi 60 date | cut -c5 | sed y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz}

(The cut -c5 here just grabs the first letter of the month name.)

Now all we need are some more interesting sideways fonts :) (No offense of course, to Johnny B.)

4 comments:

  1. This is smart, it looks incredibly neat on screen too.

    A small suggestion, as noted the sed "isn't the prettiest solution". Using `tr` is neater like so:

    date|cut -c5|tr [A-Z] [a-z]

    I don't normally make suggestions on "this way is better because" if the original function works just dandy, but given how much shorter the line is its likely to be easier on editing conky scripts which can already have massive line lengths getting things in laid out ;)

    Keep up the great work :]

    ReplyDelete
  2. Thanks for the tip! There's nothing *wrong* with the sed method, per se, but it *was* a pain to type and I had to treble-check that I didn't leave a letter out! Your solution is much easier to code :)

    ReplyDelete
  3. Much like SubBass said I use tr...

    date | cut -c5 | tr "[:upper:]" "[:lower:]"

    should handle all characters... even Umlauts.

    ReplyDelete
  4. this will get the date in all lower case too.

    date | sed -e 's/\(.*\)/\L\1/'

    ReplyDelete