----------===========*===========----------

Wednesday, November 11, 2009

wbar theme manager




1. Set DEFAULT_THEME name in script which is a link to an available theme
2. Set TEMPLATE theme in script which should be a working set of icons correspondent with your .wbar configuration file
3. /usr/share/wbar/iconpack directory should be writable by you or you have to run this script as root (sudo)
4. To add new theme select NEW_THEME item at the top of the list in zenity wndow
5. To reset the themes after changing .wbar select RESET_THEME item of the list window



#!/bin/bash
# Copyright (C) 2008 Nayanajit Mahendra Laxaman mail: nmlaxaman@gmail.com

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

WBAR_THEME_ROOT="/usr/share/wbar/iconpack"
DEFAULT_THEME="dreamdock"
TEMPLATE="$WBAR_THEME_ROOT/dream"
THEME_ROOT="/usr/share/icons"

ICONS=$( cat ~/.wbar | grep i: | awk '{printf $2" "}' | uniq )
N_ICONS=$(cat ~/.wbar | grep i: |wc -l)
EPOCH=$((100/$N_ICONS))
PROGRESS=0
DEFAULE="gnome"

THEME=''

function select_theme(){
THEMES=$(ls $WBAR_THEME_ROOT | grep -v -e $DEFAULT_THEME -e $TEMPLATE | awk '{printf " FALSE "$1}')
NEW_THEME=$(zenity --width=300 --height=270 --list --radiolist --column "Select" --column "Theme" TRUE NEW_THEME FALSE RESET_THEMES `echo $THEMES` );
echo $NEW_THEME;
}

function new_theme_select(){
cd $THEME_ROOT
NEW_THEME=$( zenity --file-selection --directory $THEME_ROOT --title="Choose an icon theme from /usr/share/icons/" )
NEW_THEME=$( basename $NEW_THEME )
if [ ! -z "$NEW_THEME" ] 2> /dev/null
then

if [[ -e $THEME_ROOT/$NEW_THEME ]]
then
echo $NEW_THEME
else
zenity --warning --text="Theme not found "
exit 1;
fi
else
zenity --warning --text="No theme given "
exit 1;
fi
}


function generate_theme(){
mkdir $WBAR_THEME_ROOT/$THEME
cd $WBAR_THEME_ROOT/$THEME
for ICON in $ICONS
do

PROGRESS=$(($PROGRESS+$EPOCH))
echo $PROGRESS

ICON=$( basename $ICON )

FILE=$( find $THEME_ROOT/$THEME -iname $ICON | grep -i 'scalable' | head -1)

if [[ $FILE == '' ]]
then
FILE=$( find $THEME_ROOT/$DEFAULT -iname $ICON | grep -i 'scalable' | head -1)
fi

if [[ $FILE == '' ]]
then
FILE=$TEMPLATE/$ICON
fi
cp -L $FILE $ICON
done
}

THEME=$( select_theme )

if [[ $THEME == 'RESET_THEMES' ]]
then
N_THEMES=$( ls $WBAR_THEME_ROOT | grep -v -e $DEFAULT_THEME -e $TEMPLATE | wc -l)
EPOCH=$((100/$N_THEMES))
PROGRESS=0

for theme in $( ls $WBAR_THEME_ROOT | grep -v -e $DEFAULT_THEME -e $TEMPLATE )
do
PROGRESS=$(($PROGRESS+$EPOCH))
echo $PROGRESS

THEME=$theme
generate_theme
done | zenity --progress --title="Resetting wbar icon themes" --text="Be patient\nIt will take some time to reset icon themes..." --auto-close

exit 1;
fi

if [[ $THEME == 'NEW_THEME' ]]
then
THEME=$( new_theme_select )
if [[ $? == 0 ]]
then
generate_theme | zenity --progress --title="Generating wbar icon theme" --text="Be patient\nIt will take some time to generate icon theme..." --auto-close
fi
exit 1;
fi

if [[ $THEME == '' ]]
then
zenity --warning --text="Theme not changed"
exit 1;
else
cd $WBAR_THEME_ROOT
rm $DEFAULT_THEME
ln -s $THEME $DEFAULT_THEME
fi

Friday, November 6, 2009

Share your 3G/HSDPA connection with friends using simple Linux router/gateway

1. Copy following script to a file (say router_man.sh )
2. Set your local interface and Internet interface in the script
3. Make the file executable (use chmod +x router_man.sh)
4. To start(add) the router
router_man.sh -a

To stop(delete) the router
router_man.sh -d

To see the information
router_man.sh -s

5. In your friends laptop set your local IP as the gateway(router)

thats all...


#!/bin/bash
INTERNET=ppp0
LOCAL=eth0
if [[ $1 == '-a' ]]
then
iptables --table nat -A POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables -A FORWARD --in-interface $LOCAL -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
elif [[ $1 == '-d' ]]
then
iptables --table nat -D POSTROUTING --out-interface $INTERNET -j MASQUERADE
iptables -D FORWARD --in-interface $LOCAL -j ACCEPT
echo 0 > /proc/sys/net/ipv4/ip_forward
elif [[ $1 == '-s' ]]
then
echo "==iptables=="
iptables -nL
iptables -t nat -nL
echo "==ip_forward=="
cat /proc/sys/net/ipv4/ip_forward
else
echo "Invalide param!"
echo "try -a for add or -d for delete -s for status"
fi


Monday, August 17, 2009

Setting up trac with svn in Debian

Reference:
http://trac.edgewall.org/wiki/TracOnDebian

1) Installing trac and apache2 and svn
apt-get install trac apache2 libapache2-mod-wsgi subversion

2) Creating trac projecs
NOTE: here my_project is the project name

mkdir /var/lib/trac
trac-admin /var/lib/trac/my_project initenv

3) Testing trac
tracd --port 8000 /var/lib/trac/my_project
Then open with browser http://localhost:8000

4) Deploying project in web (apache)
trac-admin /var/lib/trac deploy /var/www/trac

5) Apache2 configuration for the project
Create a file /etc/apache2/sites-enabled/trac_svn and add following to that file

WSGIScriptAlias /trac /var/www/trac/my_project/cgi-bin/trac.wsgi

<Directory /var/www/trac/cgi-bin>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>

6) Testing the depoyment
Open with browser http://localhost/trac/my_project

7) Setting up svn project
mkdir -p /var/lib/svn/my_project
svnadmin create /var/lib/svn/my_project

8)Adding Users (through apache digest authentication)
NOTE: Here user_name is your user name

i) Enabling digest auth module
cd /etc/apache2/mods-enabled
ln -s ../mods-available/auth_digest.load

ii) Adding user to htpassword file ( Use -c for the first time only)
htdigest -c /etc/trac/htpasswd my_project user_name

iii)Add following to /etc/apache2/sites-enabled/trac_svn

<Location "/trac/login">
AuthType Digest
AuthName "my_project"
AuthDigestDomain /trac/my_project
AuthUserFile /etc/trac/htpasswd
Require user user_name
</Location>

iv)Setting access level in trac
trac-admin /var/lib/trac permission add user_name TRAC_ADMIN
trac-admin /var/lib/trac permission list

9) Adding plugins to trac
download the file and remove the .zip extension and run
easy_install --always-unzip TracWebAdmin-0.1.2dev_r4240-py2.3.egg

Thursday, August 13, 2009

Using msb430 devices with contiki-2.x



Installing gcc-msb430:

Added following line to the file /etc/apt/sources.list
deb http://wyper.ca/debian i686/
Then run:
apt-get update
apt-get install binutils-msp430 gcc-msp430 msp430-libc msp430-jtag

-------------------------------------------------------------------
Burning apps:
Change ownership of /dev/parport0
chmod o+rw /dev/parport0
Compile and burn application
make TARGET=msb430 .u

Note: Here appname is your application name msb430 is the device
platform '.u' denote that it should be uploaded (burned) to the
device.

Saturday, July 25, 2009

Parameters we can used for cooja in contiki-2.x

Syntax:
java -jar cooja.jar [parameters]

Parameters:
-contiki=
Can provide custom contiki path instead of the default path which cooja is contained ( I guess )

-external_tools_config=
Can provide custom externel_tools file. The default file is  contiki-2.x/tools/cooja/build/external_tools_linux.config

-quickstart=
Quickly start the simulator using the given config file.
The configuration file can be either a saved simulation (.csc) contiki build to target cooja (.cooja) or a contiki source file (.c)
( .csc  .cooja .c )

-nogui=
Quickly starting a saved simulator(.csc), make targeted to cooja (.cooja) or contiki source file (.c)  WITHOUT gui
( .csc, .cooja, .c )
Make sure at least one test editor is controlling the simulation

-applet
Load the applets given followed by following switches given bellow
     -web=
        web applet path
     -sky_firmware=
        sky firmware
     -esb_firmware=
        esb firmware
     -build=
        build path


Tuesday, June 16, 2009

How to acquire URLs of the packages from apt (Debian,Ubuntu)[updated]

Following script will list the URLs of the packages and it's dependencies
1. copy it to apt_urls.sh
2. make it executable chmod +x apt_urls.sh
3. use it ./apt_urls.sh
eg:- ./apt_urls.sh mysql-server



CODE:

#!/bin/bash
if [[ $# = 0 ]]
then
echo "Usage:"
echo "$0 "
exit 0
fi

DEPS="/tmp/deps.list"

function get_urls(){
if [[ $1 == 'upgrade' || $1 == 'dist-upgrade' ]]
then
echo $( apt-get $1 -s | grep Inst | awk '{print $2}') > $DEPS
else
echo $( apt-get install $1 -s | grep Inst | awk '{print $2}') > $DEPS
fi
}

function list_urls(){
for PKG in $( cat $DEPS )
do
PKG_PATH=$( apt-cache show $PKG | grep Filename: | awk '{print $2}' );
PKG_DIR=$( echo $PKG_PATH| awk -F '/' '{print $2}' );
BASE_URL=$( grep ^deb /etc/apt/sources.list | grep $PKG_DIR | awk '{print $2}' );

for URL in $BASE_URL
do
echo $URL/$PKG_PATH
done | sort | uniq
done
}


get_urls $1
list_urls

Sunday, June 7, 2009

Enlightenment 17 in Arch Linux

Its really cool fast and up-to-date...

ArchLinux: http://www.archlinux.org/
ArchLinux e17:http://wiki.archlinux.org/index.php/E17
enlightenment: http://www.enlightenment.org/
elive: http://www.elivecd.org/

Saturday, May 16, 2009

Blue curl usplash and gfxboot themes

I modified a usplash theme and a gfxboot theme with adding blue curl background and the debian logo

Blue curl usplash:


Blue cur gfxboot theme:

Both can download here

Search In Note Book

Loading...