Okular Formats Follow-Up

After finding out you can read epub ebooks with Okular, I checked the list of supported formats (as of KDE 4.2): PDF PS Tiff CHM DjVu Images DVI XPS ODT FictionBook ComicBook Plucker EPub Fax. That includes OpenDocument(e.g. OpenOffice, KOffice) Writer Documents, CHM (aka. Windows Help) files, Djvu and others. I wonder what's the current list for the current 4.5.

Viewing Ebooks in KDE

I just discovered by accident that Okular - at least in version 4.5 - has the power to display ebooks. And it does it quite nicely, too.

Gnash 0.8.8 with VAAPI support out

But don't get too excited yet. It does not seem to be as fast as hoped in many cases and there are no Ubuntu packages yet except for the still unstable Maverick release. If you run that with VAAPI, try deb http://www.getgnash.org/debs/ubuntu maverick main.

DVD Backup with Mencoder and dual audio Matroska

Three easy steps:

1. mplayer dvd:// -vf cropdetect -ss 1200
2. mencoder -alang en -oac copy -ovc x264 -x264encopts crf=23:trellis=1:ratetol=inf:frameref=2:bframes=2:8x8dct:ssim:psnr: -o main.avi (add interlace to x264encopts if necessary)
3. mencoder -oac copy -alang de -o tempaudio.avi -ovc frameno dvd://
4. mkvmerge -v -o "Main en de ac3.mkv" --title "My Big Backup" --language 1:eng main.avi --language 0:ger -D tempaudio.avi

Add subtitles to your gusto, mix and enjoy!

Switching the XV area between different screens

Very easy once you know the command: xvattr -a XV_CRTC -v 1 for screen 1, xvattr -a XV_CRTC -v 0 for screen 0, etc. Check this page for more.

How Your Browser Determines Battery Runtime

Using Chrome I noticed a lot of CPU usage with some open web pages. This is much better when using Opera. Also Chrome seems to constantly write something to disk, which stops it from spinning down, which saves lots of energy. Hence I will now use Opera again, at least when surfing on battery... What are your experiences with CPU usage and disk access with browsers\?

Syncronized Folders across Windows and Linux - (Cloud-)Free Encrypted Cross-Platform Synchronisation with Unison

I always wanted to sync a few folders of my system across all my computers. E.g. the my scripts directory, where I constantly fiddle with my scripts and create new ones, my documents I always want to be able to have and edit everywhere, etc. I would never know where the most current version is without bothersome comparison of the dates. I would have to check every file and then copy the newer one. But that's now history, thanks to unison and my sync scripts.

What you need
The biggest problem is that you need a Linux server somewhere that is best constantly running and connected. I sync all my files with an online server. This is not a big deal because with SSH the connection is securely encrypted. Also due to compression and the fact that files are only transferred once, sync is pretty fast even with an ADSL connection. Of course this won't work for slow dial up connections in combination with large files. But as long as there are only small changes in certain files, even dial up might work for you. A Linux server is not really needed, but makes the setup much easier, which is why that's what I demonstrate here. And of course if you only want to sync two computers with each other, then there's no need for a constantly active server. It should work with Mac as a client or even server, but I don't own one so I can't help with that.

You can get your unison downloads for Mac, Windows here and for Linux here (Ubuntu binaries i386 for 9.10 and 10.04 and more in this ppa. I recommend version 2.40.16, read below for why.

For Windows you also need to get Putty Agent (Pagent), Putty Puttygen and Plink get them at http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. For Linux you also need openssh-server ssh-agent, ssh-keygen (in the openssh-client package) and keychain. You need to setup a working ssh connection with public key authentication for this to work without your interaction in the background. See here how to do this.

Bugs in the past
At the time I found it, over a year ago, it was still pretty buggy. It couldn't handle unicode, special characters or Umlauts properly. Especially between different system you'd end up with two differently named versions of a file unless you restricted yourself to normal a-z characters - very annoying.

But recently new version has come out, which fixes the problem. Now unison is not only a tool to synchronize flawlessly across different systems, it's also faster and prettier "GUI" than older versions and it still synchronized across encrypted ssh connections if you want it to. In my view this makes it the perfect tool for my needs. I've set it up to synchronize my laptop and my netbook with each other and my server system over ssh.

How it works
It's blazingly fast by only copying those parts of the files that have changed. And it doesn't transfer any files to check this. It runs both on the server and the client and only transfers the dates and hash coddes of the files via a secure compressed ssh connection. You can find out more about unison at LinuxJournal.

The easiest setup and the one I will show here is a star topology setup. This means there are several client systems synchronizing with one server. It works because unison knows which files are newer. The great side effect is that you automatically have a distributed backup on all your systems - the server and all clients of all your files.

The script runs automatically every X minutes in the background via cron on Linux (completely invisible) and is called by the Windows Task Manager on Windows (almost invisible).

Important to know
You need to use exactly the same version on all system you deploy it. There are easy to install packages for Debian and Ubuntu and precompiled versions for Windows. I haven't worked with OS X version yet, but they should work as well. I use a Linux server, Windows on the server side should be possible to set up but it's going to be much more difficult. Setting up the client on Windows is already non-trivial.

As you don't modify the same file on both systems at the same time before a server sync, then there won't be any problems. If you do, unison will not sync them. You need to call unison by itself and it will prompt you to chose how to deal with the situation.

The Linux version uses the symlink feature of Linux to let you configure which folders to sync on the go. In Windows this won't work, so all your folders you want to sync need to be inside one parent folder. I know no way around this, though the unison config file might have a solution somewhere...

Sync script:

LOG="tee -a $HOME/logs/mysync2.log"
source $HOME/scripts/functions $HOME/scripts/variables

main ()
echo Starting at $(date)

# exit if running on battery
grep on-line /proc/acpi/ac_adapter/*/state >> /dev/null
if [ ! $? ]; # 1 if not "on-line"
echo Running on battery. Leaving now...
exit 0;
echo Running on AC Adapter.

# use ssh-agent
source $HOME/.keychain/*-sh 2>&1
echo sock $SSH_AUTH_SOCK pid $SSH_AGENT_PID me $(whoami)
ssh-add -l || (echo "SSH Key not active\!"; ssh-add || exit 1)

cd $HOME

unison-2.40.16 sync -batch -maxbackups 2 ${@} 2>&1

echo Exiting at $(date)

main | $LOG

It checks and exits when the system is running on battery. To be able to work in the background, it uses ssh-agent. So you need to setup ssh key authentication.

Unison config in ~/.unison/sync.prf:
# Unison preferences file
root = /home/user/sync
root = ssh://user@syncserver:port/syncfolder
follow = Path *
ignore = Path {scripts/s3.sh}

This is a sample config file. It follows all symlinks in the $HOME/sync folder to syncfolder on syncserver via ssh. The ignore section shows you how to exclude certain files from synchronization.

Windows Setup
This should already work just fine in Linux. Now let's turn to the Windows client.

The Window setup, as you will see, it much more "fun". There are several steps you need: Putty Agent (Pagent), Putty Puttygen and Plink (see above for links) and then a few bash scripts.

You need to copy your private ssh key from your linux box and convert it to putty's format with puttygen. Then copy it into a safe folder. I have it in the same folder as the Unison.exe. Then setup an ssh connection to your server with Putty that uses the key and save it to profile name unisonssh. Copy the following bash files to your unison folder and adjust the path names accordingly.

Putty Agent.bat:
pageant.exe sshkey.ppk
This needs to be a script or otherwise it's not started in the right folder and won't find the key. Try it with the full path of the key file then. This must be linked into Autostart if your and will prompt you for your ssh key password if your key is password protected.

SSH Connect.bat
@plink -C -ssh -load unisonssh -i "C:\unison\sshkey.ppk" -l djtm -P 22 unison -server -auto
Change the path to where your ssh key lies and the port to your server's port if necessary.

Unison Sync.bat
cd "C:\unison\"
unison2.4.exe -sshcmd sshconnect.bat -backups -backupdir unisonbackups -backuplocation central -batch -confirmbigdeletes -contactquietly

Testing it
Now is a good chance to try everything works fine. Try creating a file one one system and see how after two syncs it magically appears on the other. Edit it there to see how the edits are transferred back to the first system.

Scheduling it
Once everything works you can schedule it to run regularly without you needing to do anything. In Linux, you should install keychain for this to work in scripts and then enter the following into your cron. (To edit your cron type crontab -e)
*/15 * * * * $HOME/scripts/unisonsync
The */15 means to sync every 15 minutes. Don't worry, usually nothing will be done - I hardly ever notice anything happening. Of course the path should be where your unison sync script lies.

In Windows it's a tad more difficult again. The most difficult part of it all is to make it run in the background without annyoing you every 15 minutes or so. The following command looks a bit quirky, but that's the best I could do. Enter exactly this behind Execute: in the task scheduler.
cmd /C start /LOW /MIN "Unison Sync" "C:\unison\unison.bat"
and "C:\unison" next to execute in. Check both execute only when logged in and, under the settings tab, not to start the task if you're running on battery.

And now - finally - enjoy great, free, in sync folders!

Another older, less detailed guide is available here and here. Thanks to the authors of Unison.

DOUBLE_CONSOLE_SWITCH=true can lead to keyboard problems

With this option enabled, my keyboard was no longer working in X after suspend. In my case, with the poulsbo chipset, the better option was to switch the console *after* suspend. Then X keeps working flawlessly.

Enable XvMC on Intel Chipsets

All you need is any current distribution (Ubuntu 9.10+). Then you need to enable it in /etc/X11/xorg.conf:
Section "Device"
Identifier "Videocard0"
Driver "intel"
Option "XvMC" "true"
. Then play an MPEG2 file with /usr/bin/mplayer -vc ffmpeg12mc -vo xvmc and Enjoy\!

Which e-book readers *don't* use Linux?

If you have a look at the Wikipedia page comparing e-book readers (http://en.wikipedia.org/wiki/Comparison_of_e-book_readers) right now you find almost only Linux variants including Android. The more efficiency you need, the more Windows will no longer be able to compete, as it can't be adjusted to the circumstances. I wonder when Microsoft will start to partially open source parts of Windows...

New version of Compcache - ZRam

A new version was just uploaded writes the main developer. Now you can use it to mount /tmp there, too:

hg clone https://compcache.googlecode.com/hg/ compcache

The README file in the source root contains information on how to use it. Some of its features include (see Changelog for details):
- Devices are now called /dev/zram ( = 0, 1, 2 ...) instead of ramzswap since they can now handle any kind of I/O and not limited to use as swap.
- Replaced ioctls with sysfs interface. So no need for separate tool like rzscontrol.
- Percpu stats and buffers for improved scalability
- Lots of other cleanups, minor fixes.

(quote from http://code.google.com/p/compcache/issues/detail?id=68)

Speed up your system for free with the -ck patches

Well, okay, unfortunately it does take quite some time to compile your kernel, so really it's not for free. But you don't need new hardware to get a system that responds much quicker and more fluently - without using more power on battery thanks to dynticks. I've always wondered why in my impression the kernel had become less responsive some time after the beginning of the 2.6 era. Con Kolivas has fixed this - again. I just wish there was a Ubuntu ppa for his kernels.

Internal PDF Reader in Chromium

Chrome and Chromium are really that similar. All you need to do is:
sudo ln -s /opt/google/chrome/libpdf.so /usr/lib/chromium-browser/libpdf.so

Then you can read PDFs directly in Chromium. But be warned, this may interfere with Chrome's License as well as future Chromium Updates.

Thank you, GParted LiveCD\!

I've just used GParted for the first time. It worked fabulously for me. Resizing a partition by 14 GB and moving the other one out of the way in below 10 minutes and without any problems. The biggest problem was that the current version was not working with the Ubuntu USB boot disk creator. There was some kind of problem with isolinux or syslinux. So I just replaced it with the much preferred GRUB. (grub-install /dev/sdb1). Then I entered the settings manually and the rest was easy. I'm normally not a GNOME user, but I really love how (once booted) it just works\!

Bash CLI TCP Access

Have you ever been in the situation that you are on an absolutely minimally equipped system, yet you want to access TCP? Than BASH can be your savior. Simply use /dev/tcp to access a remote server, e.g. cat /dev/tcp/ and nc -l 1234 > test.tar.bz2 on the other side...

Linux Heavy IO Latency Issues Fixed?

A new patch was just published (http://www.phoronix.com/scan.php?page=news_item&px=ODQ3Mw) that might very well fix the latency issues many desktop users have noticed during heavy transfers to and from disk. You can get the patch here: http://lkml.org/lkml/2010/8/1/40. The patch changes vmscan.c and I wonder when it will enter mainline so it can easily be tested via Ubuntu's kernel ppa (kernel.ubuntu.com/~kernel-ppa/mainline/).

New Low Power Record - Power Management Progress in 2.6.35

I just wanted to test how low the system can go in it's power usage with the power management framework of kernel 2.6.35 and the results amaze me. A test just showed that the system can save an additional 0.8 watts with the new kernel. Before the minimum battery usage without wifi was 5.6 W. Now in kernel 2.6.35 this has gone down another 0.8 W to 4.8 W - or 8.3 hours with just over 70 % battery. This is amazing. Even with wifi active the system now goes down to about 6 W - significantly increasing the amount of time you can be online surfing on battery. I wonder how much energy recent kernels save on other systems.

Easy Posting with Blogger from the Command Line

Posting with Blogger is now really easy just using the command line. An example command looks like this
google blogger --blog="Linux Tipps & More" --title="Some title" post "Here comes the content"

You can of course put all this into a script so it becomes even easier to post new blog entries:
google blogger --blog="Linux Tipps & More" --title="$1" --tags=$2 post "$3".

Ubuntu 10.04 working with the MSI Wind U110

I finally managed to get it to work. All I needed to do it go to /etc/default/acpi-support and set DOUBLE_CONSOLE_SWITCH to true. Now I can resume from standby in Ubuntu 10.04. For now I've only done this on my test system, but soon I will upgrade the main system - finally.

Update: Actually it's still a bit buggy then. I still get a blue flickering after resume until I manually switch to X with Alt-F7 and back a few times.

Fixing Suspend for the MSI Wind U110 in 2.6.34 and 2.6.35

The MSI Wind U110 suddenly stopped going into suspend more in newer kernels starting at 2.6.34. A kernel developed found where the issue is located. Actually the system did go into suspend mode, but it came right back immediately.

The issue is very easy and quickly solved, though, with a single simple command:
echo LID | sudo tee /proc/acpi/wakeup

Now I can go into suspend again, and the system still comes back from suspend as expected, nice! :)

Unfortunately for some reasons this does still not mean that suspend is working in Ubuntu 10.04 for me. Probably an issue related to the updated Xserver in 10.04. Though I can suspend and resume now, X crashes and restarts after resume.

Fun with Compcache/RamZSwap

If you run a netbook, a system with few memory, or just for the fun of it. Using RamZSwap helps your performance and is included since 2.6.33 and really easy:

1. Get and compile a current version of rzscontrol in the compcache package sub-projects folder.
2. sudo swapoff -a
3. sudo modprobe ramzswap
4. sudo rzscontrol /dev/ramzswap0 --verbose --init
5. sudo swapon /dev/ramzswap0

Enjoy! Check out lwn's tech info about it.

Update: Actually it does work for me in 2.6.33, but in 2.6.35 it does not work at all and the --backing_swap /dev/your-current-swap-partition support was removed.

Update2: You can make it work with a bit of source code modification. The author writes, though, that he will soon release a new version of both his kernel module and command line tool that can be installed and run in 2.6.35.

Comparing Kernel Dmesgs: Remove Timing Info and Diff Side by Side

I often wanted to compare what new messages appear or disappear in a new kernel so check out what might have changed, esp. when debugging. The problem is that diff is confused by the timing information that is by default prepended to dmesg information in Ubuntu kernels.

Here's how to remove the timing information to have a clean, diff-compatible dmesg log:
sed 's/^...............//'
The command basically removes the first (number of dots ".") characters of every line.

Then you can use diff to compare the dmesg files side by side:
diff -y -w -B --suppress-common-lines dmesg-A dmesg-B
Of course this is still not magic, but at least now diff can filter out a lot of similarities for you.

Standby-Strom des Edision Avantage DVB-T Receiver - Energiespar-Tipps

Ich habe gerade mal ein bisschen rumprobiert, um zu sehen wieviel das Teil an Standby-Strom verbraucht. Normal, ohne USB oder SD-Karte, verbraucht es recht gute 1,5 Watt (Conrad Voltkraft 3000 Energy Meter, ist recht exakt, Herstellerangabe < 2 Watt). Mit USB-Festplatte, die offenbar nicht ausgeht: 3,5 Watt.

Normal:    1,5 Watt
Stick:        1,5 Watt
USB-HD:  3,5 Watt
SDHC:      4,4 Watt

Es empfiehlt sich also aus Stromkostengründen einen USB-Stick dafür zu kaufen und keine Festplatte, auch wenn letztere weniger Kostet pro MB. Sonst zahlt man das Geld über die Stromkosten wieder zurück (1 Watt sind bei 22 cent pro kWh ca 2 € im Jahr). Auf jeden Fall sollte man auf eine SDHC verzichten, die jährlich ca. 6 € an Strom zusätzlich kosten würde. Wenn man ihn vom Strom trennt, spart man ca. 3 € pro Jahr, muss dann aber natürlich auf zeitgesteuerte Videoaufnahmen verzichten.

Insgesamt bin ich mit dem Gerät sehr zufrieden, vor allem für den günstigen Preis. Es lohnt aber, noch in einen möglichst kleinen/kurzen USB-Stick (da nur vorderseitiger USB-Anschluss) und ein besseres SCART-Kabel zu investieren (das mitgelieferte macht ein sehr schlechtes Bild!).

Die Videorekorderfunktion mit Timer muss ich noch testen. Sofortaufnahme und "Pause", also "Time Shifting", haben bereits gut funktioniert.