Friday, July 8, 2011

Weather in conky

Although conkyForecast is an excellent script, (and should be the first step for anyone who wants weather in their conky) when I recently reformatted and lost all my conkyForecast files I wasn't too keen on going through the registration again.

So I've been looking at alternate ways of getting weather, particularly getting pretty icons. One was is here
look a few posts down for the code, although seeing as it is specific to my local weather station for the weather and the images, it probably wont work for you.

also out of this i had a way of drawing rounded corner boxes which I have further developed in various background scripts.

With the weather there is also time and date and system info. Everything is generated in a Lua script. Not only do I find it easier, I find it is lighter on resources than running code from the conkyrc.

An example of that is here
Conky system monitor

I wanted to get as much information about my system onto the screen using lua and conky. This is what I came up with

from this post

These setups are pretty complex and require some other things to be running such as vnstat.
NEW UPADTES! amazing!

Lua calendar

I think this is the most up to date code for the lua calendar

The standard way to get calendars in conky is by cal followed by some complicated regex to make the current day show up in a different color. Other than that you don't have much control over the layout and you have to use a mono font otherwise everything is out of line.

This calendar can use any font you like and still keep aligned. You can also control many other aspects of the calendar layout.

Sunday, December 26, 2010

Mayan calendar

I made the calendar much more readable by adding text labels around the rings like so:

I've just been cleaning up the code and found a couple of errors that have been corrected. You can find the code for the above here.

--Original post below-----------------------

I have been thinking about setting up a "year clock" using multiple rings showing progress in the year, month, day, hour, and minute. I had come up with some designs like so:

In this case the largest circle is the year and the dot on the circle is where we are in the year. The next largest circle is the month and the dot where we are in the month and so on. I had set it up so that everything moved in increments of 1 second. The right side shows what the set up would look like on midnight of December 31st. The nice thing about this clock is that it will never look the same twice in a year. However, it isn't exactly easy to read :)

Next I tried this:

Which uses similar mechanics as the clock above, but as you can see the rings are marked with information. Each circle rotated so that the current date/time was at the top of the ring. Unfortunately this clock proved to be extremely cpu intensive (it was actually pushing my cpu to 100%). I reoriented the circles to this:

But there was no was this script was going to be viable. But I liked the look of the above, with the rings within rings.

Then later I had the idea to try something else and this is what I came up with:

This is when things started looking very Mayan :)
In the above calendar clock, year is the innermost circle and instead of having the circles move I had indicators move around the circles. I also went on to add some system info indicators like so:

The code for the above is here.

Sector11 has also made some cool looking additions to the calendar part. You can see that here. I have a nice Mayan symbol dingbat font that may well be used in conjunction with my circlewriting script to add some glyphs to the calendar also.
I posted a perspective bar set up some time ago, and thought I would revisit a 3D approach. This is what I ended up with.

The bar rises and falls in relation to whatever conky output you feed it. The script can be found here.

It took a crash refresher course in basic trigonometry to get everything working and I can't guarantee that if you try the script it will work. The bar looks as I wanted it to, but I was hoping to be able to define simple coordinates and have multiple bars generated that all fitted together.

This didn't work out in this script as I the math I was using wasn't calculating the right perspectives for subsequent bars.
Updates, I have a couple of things that I've been working on recently.

First there is a amalgamated circle generating and circlewriting lua script.
It can do things like this:

And this is a little more complicated (obviously you can get whatever colors you want for rings and text I was just feeling monochrome when I made these.)

The intertwining effect is made by making different bits of the circle at different points in the lua script. In lua the later instances of cairo graphics are drawn above any earlier instances.

The script can be found here on the crunchbang Linux forum (where you can see a more colorful use of the script. It can also generate bars that can be placed and rotated freely.

Thursday, October 14, 2010

Splitting text into individual letters

One Lua trick that I use a lot is taking a string and splitting it up into individual characters which then get stored in a table.

I used this approach for my circle writing function and many other functions. This is how it's done.

You need the following function in the Lua script above the main function. I did not write this function and I cant remember exactly where I got it from but whoever did write it has my thanks!

function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
table.insert( result, string.sub( self, from ) )
return result

These are the lines that split up the text...
print (text) --> text

sub=string.gsub(text, ".", "%1|")
-- the above inserts "|" after every character
print (sub) --> t|e|x|t|

split=string.split(sub, "|")
-- the above splits the string whenever a "|" occurs and also deletes the "|"
the resulting split up characters are stored in a table called split in this case

-- slen is the length of the original text,
so will be the number of entries in that table "split"

so that:
split[1] = "t"
split[2] = "e"
split[3] = "x"
split[4] = "t"

now I can deal with each character individually.
I could give each character a different font, or a different color
or, in the case of my square font conky below, convert each character to the square font.