Mikeri's tech-babble

2019-05-11

Fast PDF thumbnail generation

Most of the well known freedesktop.org abiding file managers support thumbnail generation trough the Thumbnail Managing Standard. (My favorite is PCManFM and it is no exception.) However, my PDF documents were not thumbnailed as I did not have Evince installed. I did not want to install Evince with all the Gnome dependencies that would follow as I was (and am) very happy with Okular.

I wrote a simple thumbnailer that uses ImageMagick and it while it does work it has two things that could be better:
- it is slow
- some times it draws white areas around the thumb. I suspect this is because the document contains one or more pages that is bigger than the first page.

After stumbling across this blog post, I wrote a thumbnailer using mutool instead. Because of mupdfs high speed it is blazingly fast and does not create white space around the thumb when there are mixed page sizes.

Install mupdf-tools and put the following in ~/.local/share/thumbnailers/mutool-pdf.thumbnailer to achieve fast PDF thumbnailing:

[Thumbnailer Entry]
  TryExec=mutool
  Exec=mutool draw -w %s -h %s -o %o %i 1
  MimeType=application/pdf;application/x-pdf;image/pdf;


PS, the thumbnailer is also available as a gist.

2014-08-19

Booting Windows when early boot fails

So this was my problem; an old laptop wouldn't boot Windows XP. After the Grub menu, I would just get a black screen with a blinking cursor when choosing Windows XP. Other installed OSes worked fine.

Ntldr, Ntdetect and boot.ini were all fine. Reinstalling the MBR (running fixmbr or fdisk /mbr, deleting Grub) or running Windows repair would not fix it. Also the boot flag was set.

Turns out the partition itself, not just the disk, has a boot sector, this was probably corrupt. I got it to boot by using Grub, and replacing the line "chainloader +1" with "ntldr /ntldr" in the menu entry. This skips the boot sector on the partition and loads ntldr directly. Wehey, it booted!

Labels: , , , , , , , ,

2011-09-03

How to disable click to raise in Ubuntu Linux using Compiz

One thing I have missed greatly from my days with AmigaOS back in the day is working with overlapping windows without the active window popping to front all the time. One example would be a maximizied web browser and a small window un top of it. Whenever you click on the web browser the small window will dissapear.

Under General compiz options/Focus & Raise Behaviour you can uncheck "raise on click" to get AmigaOS-like behaviour, windows will not move to front when clicking on them. To move a window to front, simply click the title bar.

Something simular would be possible with the focus on hover option but most people find that one annoying.

Labels: , , , , , , ,

2010-01-25

Fixing Windows XP MBR without the install CD

I just had a mishap with a failed Ubuntu install (GRUB failing due to the BIOS having problems with large drives) on a laptop and needed to boot back into XP. "Normally" (or rather, in the past) the XP install CD would do the trick, but because the laptop has a SATA drive the install CD couldn't find any disks.

I could possibly have made a custom install CD (the laptop doesn't have a floppy drive for the SATA drivers the install CD needs) but an easier solution was the great SystemRescueCD. This is completely free and works well.

I booted the included FreeDOS image, typed fdisk at the FreeDOS prompt, selected my XP partition, and hey presto, a rebuild MBR option!

So there you have it, free MBR repair without the dodgy XP install CD. As I didn't find this by Googling for a solution I'm posting it here hoping it will help others in the same pinch.

Labels: , , , , , ,

2009-10-31

Commodore 64 palette file for GIMP

I wasn't able to find a good C64 palette file for GIMP, so I used the values from Philip 'Pepto' Timmermann's brilliant webpage about the C64 colour palette and typed the values into this .gpl file, just in case anyone should have use for it.

Labels: , , , , ,

2009-10-27

Automatic directory spesific saving of torrent-files in Firefox

There is (as far as I know anyway) no easy way to specify which directory to save files in by file types in Firefox. There are addons, but the only good one I found required you to open the Open-or-Save-as requester. Therefore, I made this little shell-script:

#!/bin/bash
mv $1 ~/torrents/
rename 's/\[.*?\]//g' ~/torrents/$1
exit

Save this script and do a chmod u+x on it, then point Firefox to use it on torrent files. (Edit/Preferences/Applications) Obviously, change the directory to where you want your torrent files. Of course this can be used for other file types as well.

The script also strips out those annoying square bracketed site ads like [ISOHunt] etc. (Square brackets seemed to confuse rtorrent here.)

Labels: , , , , , , , , , , , ,

2009-03-22

IPv6 with 6to4 tunneling in Debian made easy

I tried to find an easy way to implement IPv6 via 6to4 on my Debian server, but everything I found required some sort of manual intervention in the case of reboots/new IP addresses from my ISP, etc.

So I made this little init.d script using snippets from all around:

#!/bin/sh
# $Id: tun6to4 init.d script v0.1

#Change "eth1" in the following line to your own public interface:
IPV4=$(ifconfig -a | awk '/eth1/{p=1}p&&/inet addr/{sub(".*:", "", $2);print $2;exit}')

STFADDRESS=$(printf "2002:%02x%02x:%02x%02x::1" `echo $IPV4 | tr "." " "`)

case "$1" in
start)
echo -n "Starting 6to4 tunnel: "
/sbin/ip tunnel add tun6to4 mode sit ttl 64 remote any local $IPV4
/sbin/ip link set dev tun6to4 up
/sbin/ip -6 addr add $STFADDRESS/16 dev tun6to4
/sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 metric 1
#The following line enables forwarding from eth0
# /sbin/ip -6 addr add dev eth0 $STFADDRESS/64
echo "."
;;
stop)
echo -n "Stopping 6to4 tunnel: "
/sbin/ip -6 route flush dev tun6to4
/sbin/ip link set dev tun6to4 down
/sbin/ip tunnel del tun6to4
echo "."
;;
restart | force-reload)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage: /etc/init.d/tun6to4 {start|stop|restart|force-reload}"
exit 1
esac
exit 0

Modify the first uncommented line with your own lan interface, save the file as /etc/init.d/tun6to4 , then do a:
$ update-rc.d tun6to4 defaults
And you should have IPv6 connectivity up and running automatically. On reboots, the script should find your DHCP assigned IP-address and use it accordingly.

If you want to forward from your LAN, uncomment the commented /sbin/ip line and change eth0 to your LAN interface.

If you get a new IP address you'll have to rerun the script. Oh, and the ipv4-extractor uses awk.

Labels: , , , , , ,