dmenu hacks
Recently I have been hacking into the source of dmenu . Its an awesome minimalistic tool for starting applications in linux. Initially, I created a system pop-up menu by hacking into the dmenu code. You can find it here.
The next hack using dmenu, is not exactly a hack, I created a todo list manager using dmenu. It is actually a script. You can find this here .
PS: The hacks and scripts might not be updated to the latest, so keep checking.
Matterhorn – GIMP
amazingly git
For a long long time I wanted to use version control systems (VCS) for my projects. I wanted my academic related projects to be available on my laptop as well as the university systems. VCS was a good choice to not only manage versions, but also have two copies of my project, one on my laptop and one in the campus.
I tried various on-line stuff like github, unfuddle etc, but I wanted a private one and didn’t want my repos public. The on-line ones are highly portable though.
Later it struck me, I was having a laptop which I carry everywhere and could use that as my server for VCS. Here I will share the first steps of creating VCS and also discuss few related stuff.
Why VCS?
As I already mentioned I wanted version management. This is helpful for not only code related projects but also instances like – when you are writing a paper, which you are publishing, you can maintain many versions and it will be easy to retrieve the one you want. It is very very helpful in academia where you write lots and lots of undocumented
programs and finally you are confused which is the final version
.
Which VCS?
I tried exploring different VCS like svn and git. But git seemed very interesting. Have a look here for a detailed talk on git by the creator (Linus Torvalds). I really liked the idea of decentralised VCS where you can commit on a local repo and finally push it to a main/remote repo. This works of me, every time I need not commit to my server (laptop).
Here I’ll give quick steps for creating a git repository. One thing to note in git, there is no notion of client and server, any repo is a client as well as a server (don’t bother if you don’t get it now
).
Step 1
You need to install git. I recommend directly download it from the git site. Click here
Or if you are debian based linux user
sudo apt-get install git git-core git-doc
Its always good to download the doc files also, if you are using the software for the first time
Step 2
Create two git bare repositories. One I’ll call server (one on my lappie) and on as a client (can be anywhere, lappie as well as any other system).
server$ mkdir ~/repo
server$ cd ~/repo
server$ git --bare init (UPDATE: added the 'bare' switch)
And on the client
client$ mkdir ~/project
client$ cd ~/project
client$ git init
Thats all, you have got a local git repo. Whenever you commit its going to commit here.
Step 3
Now you can add files in your client project folder.
client$ cd ~/projects
client$ echo "This is a README file" > README
To add the contents of the folder to the repository, use git add
client$ git add *
client$ git commit -a -m 'Initial commit into the repo'
The above steps allow you to have a local VCS. If you are fine with having a local repository and your main aim is to have only version management, you can stop here.
For the people who want to commit to a centralized server, continue following.
Step 4
There are different ways by which you can commit to a remote repository. I prefer the ssh method (simply because I know and I can use it
)
client$ cd ~/projects
client$ git remote add origin ssh://server.com/~/repo
client$ git push origin master
Thats all you have committed to a remote server. If you are not sure, you can check by creating a clone. One thing to note, if you have a system as a server where you have an account, replace the ssh://server.com/~/repo to ssh://username@ip_address/~/repo.
client$ cd ~
client$ git clone ssh://server.com/~/repo
This will create a new folder with the same contents. Enjoy people
.
useful one liners
Here are few interesting one liners that i used.
- To get a list of words enclosed within a tag in a html page. For instance to get all the bold words in the web page use this.
cat page.html | grep "<b>" | awk '{ first=match($0,"<b>");last=match($0,"</b>");s=substr($0,first+3,last-first-4);print s }'
- To replace one line in a file using sed. This is useful if you want to change some sort of config file setting.
sed -i '5d' file.txt ; sed -i '5i <The text to be inserted>' file.txt
- To copy files of the form foo_*.txt with the name bar_*.txt
for f in foo_*.txt; do cp $f ${f/foo/bar}; done
- To change all the file names from upper case to lower case, in the current folder
for i in ./* ; do mv $i `echo $i | tr [A-Z] [a-z]` ; done
- Change all the words foo in the file to bar (this is pretty simple), but only for the lines that has xyz
sed -i '/xyz/s/foo/bar/' file.txt
Will post more in the near future
Konqueror – Nice Browser
I was for a long time trying to switch to a different browser than firefox. I felt that firefox was not a good browser (for linux, many might not think so, but i do). I felt it was too bulky and it cached a lot of stuff. Every browser for that matter does this.
I tried Opera for a while and felt firefox was even better than Opera
. Opera was way too bulky according to me. When i finish using Opera none of the cached stuff gets deleted. It consumes a lot of disk space.
Then the truth struck me, ‘there can be no browser without this caching of items’ , but i still kept searching for new browsers.
Then I decided to try Konqueror browser. Its from KDE and has a lot of good features. Here is where i didnt bother about the size the browser takes but the features it has. Konqueror is closely tied with the KDE environment. It has the following features:
- Ofcourse a browsing environment.
- It acts like a file manager.
- It can be used as a file viewer. (this is totally cool, according to me)
- Can split the windows like a Tiled environment.
- Uses various plugins that allows it to use various protocols, like – smb:, man:, info: etc.
- It also has a terminal client. (WOW!!)
- Another amazing feature is to customize the various shortcuts used.
- It also has this cool feature where you can set the browser to load quickly. This is really cool, even when high computation is going on, it loads amazingly fast. The browser is prefetched during computer boot time.
- Lastly, this may seem absurd but for me its important, It has a good font set, that renders the text very well.
This browser as I said before is tightly coupled with KDE. It was originally used as a file manager by KDE, now it uses dolphin.
These features impressed me a lot and made me try the browser. I need to mention this – this browser actually uses less memory when compared to firefox (but I have not really tested it).
I am still going to try various browsers , please recommend some if you know. Need to try the text-only browsers next (like w3m, elinks, lynx)
Nautilus Scripts
Hi there is a way to add custom scripts to nautilus. Nautilus accepts all kind of scripting language such as Python, Perl (may be 7 also), bash etc.
Write the scripts and add them to
/home/<username>/.gnome2/nautilus-scripts/
There were two main scripts that i wanted badly
1. Open Terminal from that location in the browser
#!/bin/bash
cd $NAUTILUS_SCRIPT_CURRENT_URI
exec gnome-terminal
2. Send a file to another folder. This i wanted badly, every time I press ‘Send-To’ in nautilus right-click, I end up opening evolution
#!/bin/bash
LOC= $(zenity --file-selection --directory)
for args
do
cp $args $LOC/$args
done
Once that is done, we have to make it executable. For that we use
chmod u+x <filename>
These are two vital scripts for me. Will soon come up with a lot more.
MATRIX Wallpaper
Hey i designed a wallpaper based on matrix, Check this out

Matrix Wallpaper
The text for the background was taken by opening an image using a text editor and using that text. Awesome isnt it?? Font also based on MATRIX
Programmer Tip
Hey i came across this nice tip for programmers. What is the difference between
if ((a==0) || (b==0))
and
if ((a==0) | (b==0))
they both work the same way but there is a subtle difference. Both the truth tables are same, but there is something called ‘short circuiting’. In the first case, if the first part is true, then the entire thing is true. So the processing of the next condition is not done, this is called short circuiting. But in the latter both the conditions are executed.
This will be important if you want operations to be done inside the if condition. For some it may be trivial, but this is a general tip.
GIMP Business Card

My Visiting Card
This is a business card theme done using GIMP. Wow! i am loving GIMP its amazing.
install linux
this is a post that is a motivation for people to use linux, and a tip of those using.
Here i’ll teach you how to install linux without using a CD or DVD.
It the case that once you start using linux you automatically start to try new distros each time one is released. And this happens like in every 6 months. So it is not actually feasible to copy the ISO to a CD everytime and install them. This is a tip for distrohoppers:
1. For booting a linux machine you need two files – initrd and vmlinuz. These are the files that actually boot the system. Assuming you have a linux machine and you have downloaded say ubuntu.iso
2. Extract the iso file ( or you can also mount it in some location) and get those twofiles mentioned above. They will be present in the boot/ directory.
mount -o loop /Downloads/ubuntu.iso /mnt/ubuntu
3. Copy those two files to your existing root partition (/ubuntu/vmlinuz & /ubuntu/initrd.gz). here ubuntu directory in created in root directory (/).
mkdir /ubuntu cd
/mnt/ubuntu/casper
cp vmlinuz initrd.gz /ubuntu/
4. Now alter the existin GRUB and add these lines – you may need root permission to do that
sudo vi /boot/grub/menu.lst
title Install Linux
root (hdX,Y)
kernel /ubuntu/vmlinuz
initrd /ubuntu/initrd.gz
here X,Y refers to the hard disk where the iso is downloaded. One tip is that you can look at the already present text in the menu.lst file and get the value for X&Y. If ‘uuid’ is present, you can use that also.
5. Restart the computer and in the login screen select ‘Install Linux’. And there you have it, no more CDs needed for installing Linux
