Friday, June 24, 2005

Starting a new X session through KDE

To be able to start a new X session through KDE:
cd /etc/X11/xdm
cp Xservers Xservers.orig

Edit the Xservers file so that it looks similar to this:

...
# you can add them here as well. Each X terminal line should
# look like:
# XTerminalName:0 foreign

# We comment out the following:
# :0 local /usr/X11R6/bin/X

# Add these lines
:0 local@tty1 /usr/X11R6/bin/X -nolisten tcp vt7
:1 local@tty2 reserve /usr/X11R6/bin/X -nolisten tcp :1 vt8
#:2 local@tty3 reserve /usr/X11R6/bin/X -nolisten tcp :2 vt9
#:3 local@tty4 reserve /usr/X11R6/bin/X -nolisten tcp :3 vt10
#:4 local@tty5 reserve /usr/X11R6/bin/X -nolisten tcp :4 vt11


You can then select Start New Session under the KDE menu. KDM and KDE are both needed for this to work. KDE does have it's own Xservers file, but on FC at least, it's a symbolic link to /etc/X11/xdm/Xservers.

Transparent Proxying

To make the host a transparent proxy, on the m/c connected directly to the ISP, edit /etc/sysctl.conf and set net.ipv4.ip_forward to 1.
Then execute the following:
# sysctl -p
# #Use appropriate network address below
# iptables -t nat -A POSTROUTING \
-s 192.168.10.0/24 -j MASQUERADE
# services iptables save
On other hosts set their default gateway to the transparent proxy's internal IP.

Cool ImageMagick stuff

Make thumbnails with ImageMagick's convert utility using:
convert -resize 25x25% filename.png filename-thumb.png

The convert utility can also convert image formats:
convert file.jpg file.png

Another cool tool in ImageMagicks arsental which can convert images is mogrify - this one's more useful when there are a many images requiring conversion:
mogrify -format jpg *.png

This will annotate an image:
convert -font helvetica -fill white -pointsize 36 \
-draw 'text 10,14 "Garden, Pune"' \
img_314.jpg annotated_314.jpg


To make an image look like it was sketched:
convert -charcoal 2 \
portrait.jpg charcoal-portrait.jpg


To make images out of a pdf file:
convert bigfile.pdf bigfilepages-%03d.png

You can also combine effects:
/bin/convert -size 460x90 xc:transparent \
-font AvantGarde-DemiOblique -pointsize 72\
-draw "text 10,75 'AvantGarde'" \
-fill darkblue -stroke yellow \
-draw "text 15,70 AvantGarde" test.jpg


This results in an image that looks like

Automounting the USB key

[update: FC3 automounts in GNOME anyways without the hoopla - that new HAL thingy works well with udev. I'll try to get the dratted thingy to work in KDE. The stuff below does NOT work out with FC3 and above.] Add this to /etc/fstab to help the USB key mount automatically in GNOME

/dev/sda1 /mnt/usb vfat \
user,iocharset=utf8,umask=0,sync,quiet,\
exec,codepage=866,noauto 0 0

If you need to automount the USB key, edit /etc/auto.master and add:
/mnt/usb /etc/auto.misc --timeout=60

Then add this line into /etc/auto.misc:
usb -fstype=auto,nosuid,nodev,\
sync,dirsync,mode=777,uid=99,gid=99,umask=000 \
:/dev/sda1

(In the above line, the user nobody has the uid and gid of 99. This is chosen as autofs runs as root.)

Then start/restart autofs :
# chkconfig --level 345 autofs on
# service autofs restart

The USB drive will be mounted/unmounted automatically.

If you want to automount USB flashdrive without using automount:
Plugin your flash drive look a the tail end of dmesg. If there is something about the usb drive on /dev/sda1, then the following will work if you have devlabel:

$ devlabel add -d /dev/sda1 \
-s /dev/flashdrive --automount \
--perms 666

Edit /etc/fstab and add this line:
/dev/flashdrive /mnt/flashdrive \
auto noauto,noatime,user,kudzu 0 0

Next time your flashdrive is plugged in, it should be automounted at /mnt/usb.

Mounting an 8-in-1 card reader

I'd written this tip down on paper - don't remember the origin.

I recently bought an 8in1 USB card reader. It uses multiple LUNs for the different media. To get all of them registered, edit grub.conf to add the kernel parameter "max_scsi_luns=8". Also add "options scsi_mod max_scsi_luns=8" to /etc/modules.conf. Reboot so the new kernel options take effect. Afteryou plug in the USB card reader, you can use the right mouse button on the root window to get a popup menu with a submenu "drives" that contains entries like "memstick", "memstick1", "memstick2", etc. After you picked one of them, it will be mounted and a new icon appears on your desktop.

Acronym tag and styles

This isn't strictly Linux - but it's kinda nice to know.
Firefox supports tags like ACRONYM and DFN. Here's an exampe of the ACRONYM tag - HTTP (Hold the mouse over the word HTTP for a few seconds).

In case you're wondering if the appearance you see here is default, it is not. It's been spruced up with this stylesheet.
<style>
acronym {
border-bottom: 1px dashed;
cursor: help;
}
</style>


I've added this to the HEAD section in my blog template.