Hero Inc.

where heroes are an everyday occurrence

Oct-26-2008

Scripting My Life

One of the great abilities of being a computer dork with limited programming training is the knowledge that one can make his/her life even better if he/she can script away the repetitive tasks of the day. In a previous post, I talked about the iMacro plugin for FireFox. Well, I’ve taken my life a step further by trying to create a few homemade scripts via BASH.

Before people start to respond, yes I know I am a dork. I realize that working on building scripts like these on a Saturday is not someone else’s idea of fun, but I enjoyed it and that’s all that matters.

  • Open Terminal Here As Root – This script was sparked due to my dislike for having to navigate to specific folders via the command line.  Most linux/computer users will say I’m lazy and I’d have to agree with them.  I have a similar function on my work Windows environment thanks to the Microsoft Power Toys and I’ve always found it to be quite helpful and much faster for certain tasks.  I was planning to build this script for Linux (hoping it wouldn’t be too difficult to create), but someone had already beaten me to it and posted it on kde-look.org.  After downloading the file, I placed it in my home/$user/.kde/share/apps/konqueror/servicemenus in order for me to run the script through my system explorer (Konqueror).
  • Get Team Trivia Answer – As many of you may know, I quite frequently go to trivia with friends.  In Atlanta, there are many Team Trivia locations.  At these locations one question’s answer is always printed in advance on the team website.  Many times we forget to look at the answer.  This script uses several basic utilities to check the site, see if today has an answer, and if does, then the answer should be emailed to me.  For not knowing much about bash scripting, this one took me longer than I wanted it to take.  Part of the issue was this was the first script I wrote and I had to setup sendmail on my system to work with Gmail.  As I write this, the script has just run and according to my email, today’s trivia Answer is McJob.
  • Amarok Alarm Clock – Often times I enjoy waking up to Amarok playing music.  However, I often have forgotten to reset the volume level so that my music isn’t turned up to 11 and I have to jump out of bed due to the noise.  I’d rather wake up gradually.  The Amarok Alarm Clock script starts amarok and then gradually increases the volume until it is at 100%.  I even haded an extra check to turn off amarok after 15 minutes at full power.  My roommate has often times complained that I forget to turn off amarok when I leave for the weekend or I am away for week due to work.  This was very simple and easy to build thanks to Amarok’s wonderful API.
  • URPMI Unlock – URPMI is the command-line package management tool used by the Mandriva Linux distribution. There have been a few times when I try to update/download new packages for my system that I receive an error stating that urpmi is currently locked.  This script, which I did not build and found on a forum, will unlock urpmi.  It’s as simple as that.

To automate these scripts to run each day, I use kAlarm which I mentioned in a previous post.  The same funcationality could be performed as a cron job, but like I said above, I’m lazy.

Posted under Linux

Comments

Bryan Says:
October 26th, 2008 at 10:27 am

Another good thing to use is to setup an alias for any command you run repetitively from the cmd line in your .bash_profile. Say for example you are always performing ‘ls -l’ well then put that as an alias as ‘ls’ to save some time. In the .bash_profile put alias ls=’ls –l’. Now everytime you type ls the ls -l command is performed. There are TONS of other things that can be put in the .bash_profile that can make life easy. Lesson learned is to backup that file before you upgrade or reinstall. If you have a lot of mods and they get wiped out you will be an unhappy uberdork. A link with an example.
http://gd.tuwien.ac.at/linuxcommand.org/wss0020.html

mike Says:
October 26th, 2008 at 12:49 pm

seconded bryan’s bash_profile comment. i was going to suggest that for your “navigate to a certain directory” script. great post, though. now you just need to create a script to always listen to the answers mike gives at trivia.