Latest articles:
1: Quine...
2: Japan and It's ...
3: Exploitation...
4: Obfuscation...
5: Life is lame...
6: An experiment i...
7: Conky buses!...
8: Nullam rewritte...
9: Kill my family ...
10: Take my mind...
11: Story of My Lif...
12: Existence and r...
13: I want to kill ...
14: Everyone should...
15: Nihilism, Athei...
16: I want a psychi...
17: I don't want a ...
18: Personal Preemp...
19: I am a militant...
20: Infinite life...
21: Being in the Sh...
22: 1TB gone...
23: Thought...
24: Artificial inte...
25: Simulation...
26: Very confused...
27: Introduction...
28: Disclaimer...
29: So long old bea...
30: NULLAM FAMILY T...
31: NULLAM FAMILY T...
32: But, soft! Bris...
33: Want to write h...
| Conky buses! | |
| 25/7/2009 - 00:23:24 - 0 comments - By | |
| So to show off my new code tags I'm going to show you a script I wrote to get the upcoming bus times displayed right there on your desktop!
There are three bits of code required here, first there is the code to fetch the timetable data for the current day from your local bus service. You're unlucky if they don't provide the data in html form, although if the timetable doesn't change often you can simply create the timetable file yourself. This is my code: getbusses.sh:
That one is quite simple, it shouldn't be hard to make one up for your timetable provider. The next piece of code is the workhorse. This one is executed every minute by conky. nextbus.pl:
As you can see it is rather strait forward, it cycles through each line on the "buses" file and determines if that bus is yet to come, if it is then it is printed. The program exits when $outputCount amount of buses are printed. The third and last piece of code is the easiest. Its the code to put into your .conkyrc file, here is my whole file to show context. ~/.conkyrc:
And that's it! All I need to do now is become social and want to know when I can travel to the city to go clubbing! Oh goodie! |
|