27 February, 2006

.initrc, bash_complete and other intersting tidbits

www.ukuug.org/events/linux2003/papers/bash_tips/Link
  • Separate basename
    • function fig2ps
      {
      fig2dev -L ps "$1" "${1%.fig}.ps"
      }
      export -f fig2ps
  • Ignore typos in cd
    • shopt -s cdspell
  • .inputrc
    • set match-hidden-files off
    • set visible-stats on
    • set completion-ignore-case on
    • set show-all-if-ambiguous on
      • Make Meta+S cycle through the list:
        "\M-s": menu-complete


function fig2ps
{
fig2dev -L ps "$1" "${1%.fig}.ps"
}
export -f fig2ps

23 February, 2006

Mouse Pad Speed

Simple:


/etc/X11/xorg.conf


under Synaptic (input device)


Option "AccelFactor" "0.03"

19 February, 2006

Check this out

kill $(pidof xmms)

ls color

For when there is no color in ls
ls --color

m4a to mp3

#!/bin/bash
#
# Dump m4a to mp3

for i in *.m4a
do
if [ -f $i ]; then
rm -f "$i.wav"
mkfifo "$i.wav"
mplayer -ao pcm "$i" -aofile "$i.wav" &
dest=`echo "$i"|sed -e 's/m4a$/mp3/'`
lame "$i.wav" "$dest"
fi
done


FAAD

# m4a to wav
for i in *.m4a
do
faad "$i"
x=`echo "$i"|sed -e 's/.m4a/.wav/'`
y=`echo "$i"|sed -e 's/.m4a/.mp3/'`
lame -h -b 192 "$x" "$y"
rm "$x"
done

Animated gif

mplayer -frames 10000 -vo jpeg outdir=.:quality=75 ./CoinWalk_Pendulum.wmv
convert -delay 5 *.jpg pendulum.gif
convert -size 320x240 pendulum.gif -resize 160x120 small_pendulum.gif

MIME Types (Mplayer)

Example: MPlayer should start WMV by Double-Click
I've uninstalled Xine and Totem, cause i only use MPlayer. After uninstalling them, I saw a disaster: Totem used to be the default player. And now there was ... nothing!
After two days of internet research, this essay was created ... so that you don't waste your time the way I had to.

Creating the desktop file
If it is not already existing, create the file "/usr/share/applications/mplayer.desktop" like this:
Code:


[Desktop Entry]
Name=Movie Player
Comment=Play multimedia files and media
Icon=mplayer.xpm
Exec=gmplayer %f
Terminal=false
MimeType=video/mpeg;video/x-msvideo;video/quicktime;video/x-ms-asf;video/x-ms-wmv
Type=Application
Categories=Application;AudioVideo;
Encoding=UTF-8


The mime types for asf and wmv already exist and are stored in the mime type database (/usr/share/mime/packages/freedesktop.org.xml)

Modify defaults.list
This file will init our DEFAULT application. It ONLY contains ONE desktop file for EACH mime type:
Code:


video/x-ms-asf=mplayer.desktop
video/x-ms-wmv=mplayer.desktop



Modify mimeinfo.cache
To take effect as default application and init the double-click feature, we need to modify the mimeinfo.cache also:
Code:


video/x-ms-asf=mplayer.desktop
video/x-ms-wmv=mplayer.desktop


This file can use MORE then ONE desktop file. If you want to be able to handle - for example - WMV files with different players, a line like this is also acceptable:
Code:


video/x-ms-wmv=mplayer.desktop;realplay.desktop


This will change the right-click-menu and insert Helix-Player, while mplayer is still default (with double-click)

After modification, log out from gnome and log in again...

Zip Pipe

FILE* TCodaEvio::Open(const char* filename, const char* mode)
{
fIsPipe=true;
static char buf[256];
TString fstr(filename);
if (fstr.EndsWith(".bz2")) {
sprintf(buf,"bunzip2 -c %s",filename); Form("bunzip2 < %
s",filename)
return popen(buf, mode);
} else if (fstr.EndsWith(".gz")) {
sprintf(buf,"gunzip -c %s",filename);
return popen(buf, mode);
} else {
fIsPipe=false;
return fopen(filename, mode);
}
}

int TCodaEvio::Close(FILE* fp)
{
if (fIsPipe) {
//fseek(fp, 0L, SEEK_END);//doesn't work?
char buf[256];
while(fgets(buf,256,fp)) {};
return pclose(fp);
} else {
return fclose(fp);
}
}

PERL: Read To Colums

$file = 'input.csv';

open (F, $file) || die ("Could not open $file!");

while ($line = )
{
($field1,$field2,$field3,$field4) = split ',', $line;
print "$field1 : $field2 : $field3 : $field4";

}

close (F);

Setting and unsetting desktop image

#/bin/bash

filename=/home/mushonti/pictures/mozilla1280.jpg

gconftool-2 --unset /desktop/gnome/background/picture_filename
gconftool-2 --type=string --set /desktop/gnome/background/picture_filename $filename

SSH cygwin


http://pigtail.net/LRP/printsrv/cygwin-sshd.html

say "yes" to Xforwarding

In order for the "Y" flag to work in "ssh -Y" and forward X, edit /etc/ssh/sshd_config and change

X11Forwarding no
to
X11Forwarding yes

customized shortcuts

gconf-editor>apps>metacity>global_key_bindings / commands. Great stuff.

Remove Icons from Desktop (GNOME)

gconf-editod > apps>nautilus>preferences>show_desktop

Sudo is great

/etc/sudoers

Opening Ports Linux

To open ports to TCP access 6881 to 6999
/sbin/iptables -I INPUT -p tcp --destination-port 6881:6999 -j ACCEPT
Save settings
/sbin/iptables-save > /etc/sysconfig/iptables
See what's going on
netstat -anp --tcp

See if settings were saved
/sbin/iptables -L