Paul’s Linux Blog

Just Another Uber-Geek

Browsing Posts tagged Script

Thanks to this great little script you no longer need to work out which program to use to uncompress multiple file archive formats.
Add this script to your .bashrc file and use as follows:
extract file.zip

 
extract () {
if [ -f $1 ] ; then
case $1 in
*.<span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">tar</span>.bz2)   <span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">tar</span> xvjf $1    ;;
*.<span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">tar</span>.gz)    <span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">tar</span> xvzf $1    ;;
*.<span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">tar</span>.xz)    <span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">tar</span> xvJf $1    ;;
*.bz2)       bunzip2 $1     ;;
*.rar)       unrar x $1     ;;
*.gz)        gunzip $1      ;;
*.<span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">tar</span>)       <span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">tar</span> xvf $1     ;;
*.tbz2)      <span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">tar</span> xvjf $1    ;;
*.tgz)       <span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">tar</span> xvzf $1    ;;
*.<span class="highlight" style="border: 1px solid gray; background: yellow none repeat scroll 0% 0%;">zip</span>)       unzip $1       ;;
*.Z)         uncompress $1  ;;
*.7z)        7z x $1        ;;
*.xz)        unxz $1        ;;
*.exe)       cabextract $1  ;;
*)           echo "\`$1': unrecognized file compression" ;;
esac
else
echo "\`$1' is not a valid file"
fi

I have decided enough is enough and ditched the useless nm-applet manager that was always greyed out and never worked since my first update after I installed Crunchbang.

I used nm-applet on Fedora and Ubuntu but recently since I moved to crunchbang it just never worked for me. this was sad as I used to rely on VPN in the manager for my connection to work, after this broke I was left trying to figure out how to connect to my work, I ended up installing kvpn which did the job but latter moved on to a great script that automates the setup and configuration that just works for me, so well I can even browse the web and work at the same time as the routing is good too, anyway if you want to know more about VPN see my other post.

Extract of wicd man page:

Wicd is designed to give the user as much control over behavior of net-
work connections as possible.  Every network, both wired and  wireless,
has  its  own profile with its own configuration options and connection
behavior.  Wicd will try to automatically connect only to networks  the
user  specifies  it should try, with a preference first to a wired net-
work, then to wireless.
For wired connections, users have many  options  for  determining  what
network  settings  to use.  Wicd allows creation of an unlimited number
of wired profiles, each of which has its own unique settings.  The user
can  choose  to  automatically  connect  to a selected default profile,
choose a profile from a pop-up window every time wicd connects, or have
wicd automatically choose the last profile used to manually connect.
For  wireless connections, users can select any number of wireless net-
works to automatically connect; wicd will choose the one with the high-
est signal strength to try to connect.

I decided to ditch the applet manager and install wicd as follows.

wi

Exmaple of wicd Manager.

Install WICD Manager

1) install the manaager

# apt-get install wicd

2) Configure the autostart of the manager

# cp  $HOME/.config/openbox/autostart.sh $HOME/.config/openbox/autostart.sh.bak
# vi $HOME/.config/openbox/autostart.sh

find the line that say's

# Launch network manager applet
#(sleep 1s &amp;&amp; nm-applet) &amp;

Comment it out and add the following lines after it

# Launch wicd network manager applet
(sleep 1s &amp;&amp; wicd-client) &amp;

You may wish to check the wicd demon runs as a service.

To do this you need to use a service manager such as BootUpManager aka 'bum'

or install a cmd tool like chkconfig.

I will use chkconfig for this example.

# chkconfig --list |grep wicd

To ensure wicd starts at boot up use:

# chkconfig wicd o

When you next log on you should find the new applet in your tool bar if not you can open it manually by typing:

# wicd-client.
Powered by WordPress Web Design by SRS Solutions © 2010 Paul’s Linux Blog Design by SRS Solutions