Some GNU/Linux recipes to make life easier…

Firefox tips

Ubuntu Bugs search plugin for Firefox
With this plugin, you can search for Ubuntu bugs from Firefox search box.
Just download UbuntuBugs.xml and copy it to your profile directory.

$ wget http://www.infinicode.org/code/other/UbuntuBugs.xml
$ mv UbuntuBugs.xml ~/.mozilla/firefox/you_profile_dir/searchplugins/

Now you can search on Launchpad for Ubuntu bugs.

Force open new window in tab

Just set this values on about:config

browser.link.open_external -> 3
browser.link.open_newwindow -> 3
browser.link.open_newwindow.restriction -> 2

gedit Code Snippets

Some gedit code snippets for a faster Python programming.
Copy python.xml to ~/.gnome2/gedit/snippets/

Restore GRUB bootloader

Once logged in the desired root filesystem…

# grub
grub> root (hd0,2)
grub> setup (hd0)

Backup entire system

Compress /dev/sda3 on external usb drive mounted on /media/USBDRIVE, using tarballs of 1GB.

# mkdir ~/linux-system
# mount /dev/sda3 ~/linux-system -t ext3 -o ro
# cd ~/linux-system
# tar cv --exclude=*/lost+found -f - . | split -a 2 -b 1000m - /media/USBDRIVE/LinuxSystem.tar

Uncompress:

# mount /dev/sda3 ~/linux-system -t ext3
# cat /media/USBDRIVE/LinuxSystem.tar* | tar xvf -

Backup folder using tar over the network

Compress a folder and copy it on the fly via ssh.

$ tar cvzf - /mnt/Docs | ssh user@192.168.1.2 "dd of=/mnt/Backups/Docs.tar.gz

Uncompress:

# cd /
# ssh user@192.168.1.2 "cat /mnt/Backups/Docs.tar.gz" | tar zxvf -

ATI Powerplay switch script

With this script, you can change your ATI card voltage easily.

#!/bin/bash
 
function switch {
	STATE=`aticonfig --lsp | grep "\*" | cut -d " " -f2`
	if [ $STATE == "1:" ]; then
		high
		else
		low
	fi
}
 
function high {
	echo "-----------------"
	echo "ATI PowerPlay: High voltage selected"
	echo "-----------------"
	aticonfig --set-powerstate=2
	aticonfig --lsp
}
 
function low {
	echo "-----------------"
	echo "ATI PowerPlay: Low voltage selected"
	echo "-----------------"
	aticonfig --set-powerstate=1
	aticonfig --lsp
}
 
if [ $# -eq 0 ]; then
	switch
fi
 
while getopts "slh" option
do
	case $option in
		s) switch ;;
		h) high ;;
		l) low ;;
	esac
done
 
exit 0

GDM on a window inside GNOME

With this you can have a GDM login window inside a GNOME session.

$ gdmflexiserver --xnest

Connect to Cadena Ser stream from Linux command line

#!/bin/bash
COUNT=0
while [ 1 ]
do
let COUNT=$COUNT+1
KEY=`wget –referer=”http://www.cadenaser.com/player_radio.html” “http://www.cadenaser.com/comunes/player/gettoken.php?update=200708312100&file=SER_LQ” -q -O - | awk -F\’ ‘{print $2}’ `
KEY=`echo $KEY | cut -d’ ‘ -f2`
URL=’mms://a1023.v78413.c7841.g.vm.akamaistream.net/7/1023/7841/v0001/prisaffs.download.akamai.com/7807/live/_!/radios/cadenaser.wsx?auth=’
URL=”$URL$KEY&aifp=v01″
echo “Conectando con la Cadena Ser… ($COUNT)”
mplayer “${URL}” &> /dev/null
done