Friday, May 29, 2015

Changing mouse button settings

I have a wireless mouse which works partially.  When I say partially the left click alone does not work in it.  It could be due to the fact that it was used for many years.  However other aspects of the mouse works, like the scroll wheel, middle click, right click and the pointer moves smoothly across the screen.

The GUI based mouse setting in ubuntu could only allow you to choose between a right handed mouse or a left handed mouse.  I wanted more, I wanted the ability to say what button was left click and what button was right click.  The idea was I need to make my middle click act as left click.  If this could be accomplished I could again have a working mouse with left, right click and scroll wheel.

The site mentioned below [1] came to the rescue.


This pictures shows that when I try to reterive the button settings for my mouse it shows 1 2 3 4 all the way up to 13.  We are interested in 1 2 and 3 which corresponds to Left, Middle and Right.

So in the next xinput set-button-map command I replaced 1 2 3 with 1 1 3.  So this effectively made my left button and middle button do the work of left click.

Thursday, May 28, 2015

Small bash script - Chennai Power Outage check

This is a small script which will check if there is power outage in your are and drop you an email a day before.


if [ -f /var/scripts/powercut.txt ]
    rm /var/scripts/powercut.txt

if [ -f /var/scripts/Tomorrow.txt ]
    rm /var/scripts/Tomorrow.txt

wget -O /var/scripts/powercut.txt

NextURL=`grep "Power shutdown areas" /var/scripts/powercut.txt  | head | grep --color "href" | head -n1 | grep -P -o href.+ | cut -d\" -f2 | sed 's/^/http:\/\/\//'`

EmailSubject=`grep "Power shutdown areas" /var/scripts/powercut.txt  | head | grep --color "href" | head -n1 | grep -P -o title.+ | cut -d\" -f2`

echo "Power shutdown areas in Chennai on 30-05-15" | sed -e 's/^/NO /' -e 's/areas in Chennai/in your area/'

echo $NextURL

echo $EmailSubject

wget $NextURL -O /var/scripts/Tomorrow.txt

powercutyes=`grep -i "Your Street name" /var/scripts/Tomorrow.txt | wc -l`


echo "From: \"SenderFirstname Lastname\" " > mail.txt
echo "To: \"RecepientFirstname Lastname\" " >> mail.txt

if [ $powercutyes -gt 0 ]
    echo "We have power cut tomorrow"
    EmailSubject=`echo $EmailSubject | sed -e 's/^/YES /' -e 's/areas in Chennai/in your area/'`
    echo "Subject: $EmailSubject" >> mail.txt
    grep -i "Your Street name" Tomorrow.txt >> mail.txt
    curl --url "smtps://" --ssl-reqd --mail-from "" --mail-rcpt "" --upload-file /var/scripts/mail.txt --user ""
    EmailSubject=`echo $EmailSubject | sed -e 's/^/NO /' -e 's/areas in Chennai/in your area/'`
    echo "Subject: $EmailSubject" >> mail.txt
    echo "We don't have power cut tomorrow"
    curl --url "smtps://" --ssl-reqd --mail-from "" --mail-rcpt "" --upload-file /var/scripts/mail.txt --user ""

Monday, May 25, 2015

WiFi Keyboard cleaning

I assume/take no responsibility if you killed your keyboard.

Try to rotate the batteries in its slot to fix any contact issues between the batteries and the battery holder metal leads.