Tech tip #11: How to have animated wallpapers in KDE

I’ve seen many people asking how to have animated wallpapers in KDE. The current options include specialised Plasma Widgets, or the rather limited yet specialised array of animated effects, such as desktop globe, seasonal change, or virus simulations.

Unfortunately there isn’t a native way to accomplish this, but KDE being KDE, there’s always a workaround.

The idea is to use mplayer to play a constantly looping, muted, fullscreen video and tell it to play on all desktops, underneath all apps, and not show up as a window in the taskbar, switcher, or pagers.

Here’s the snippet:

mplayer -fixed-vo -loop 0 -nosound -fs -name 'animbg' /path/to/yourvideo.avi

Save it as file and chmod +x (not required but useful for convenience)

The -fixed-vo flag prevents reopening a new window every type the -loop 0 flag is called. -nosound and -loop is self explanatory, and -fs is fullscreen. The -name flag allows us to set a specific window class, which will be picked up by a specific KDE window rule we will create.

A quick note here that mplayer also has the -title flag, which we should be able to use to create a KDE window rule for, but it seems as though either mplayer creates the window and only afterwards changes the title, or KDE has a bug, and so the KDE window rule doesn’t match at runtime.

We can then go into System settings -> Window Behaviour -> Window Rules and press “New” to create a new window rule. Set the window class to an exact match as shown below. For more information you can view the KDE Userbase page on window rules.

In the Size & Position tab, check Desktop, and set it to Force All Desktops. In the Arrangement & Access tab, check Keep below, Skip taskbar, Skip pager, and Skip switcher, and set them all to Force Yes. Hit OK, and Apply your settings. For more information you can again see the KDE Userbase page on window attributes.

Tada! Now you have an animated wallpaper! You can set KDE System Settings -> Startup & Shutdown -> Autostart to run your .sh file.


Tech Tip #10: merge PDFs into 2 per page, 3 per page, etc (n per page)

This post is mostly just a reminder to myself, but it may be useful to others.

I was recently asked to convert a .ppt, or Powerpoint slideshow document, into a three slides per page, horizontally centered, one on top of another, with frames around each slide. Powerpoint itself offers several printing options, including a 2n per page (ie. 2, 4, 8, etc) as well as handouts, which can do 3 per page but are incredibly small and have writing lines besides the slides.

Luckily, Powerpoint can save the .ppt into a .pdf, and there are plenty of PDF manipulation tools on Linux, and are generally much more readily available than on Windows. Scribus is an option, but after some searching I discovered “pdfnup“, part of the “pdfjam” package. This is the command I ended up using:

pdfnup --nup 1x3 --no-landscape --frame true --batch foo.pdf bar.pdf etc.pdf

For a full explanation of the commands, you can try looking at its manpage, or pdfnup --help, which is much more useful.


Tech Tip #9: use Klipper to automatically post to a Pastebin.

I haven’t done a tech tip in a while, but here’s a nice, simple one which I am finding very useful.

Pastebins are a really useful way to share snippets of text. However it’s sometimes a bit cumbersome to have to open a browser window, type in the URL, paste it in, click submit, then copy the URL to share with your friend. That’s why things like wgetpaste exist – small command-line utilities to automate this process and return the URL. wgetpaste isn’t the only one, of course, but they’re all rather similar.

Klipper is KDE’s Clipboard manager – whenever you copy something, via right click -> copy or ctrl-c, it gets added to your clipboard. Klipper allows you to navigate through it – so that you can paste something you copied a while back, or set up custom things to paste, or even – which is what I’ll talk about today – set it to automatically perform an action on the paste. The most common use is to automatically open a link in a browser if you copy a link from somewhere.

What we’ll tackle is to get Klipper to autopaste our clipboard item into a pastebin, and return the URL to us. So just set it up as shown below:

And you’re done! Copy something, press ctrl-alt-r to invoke the actions menu, click “Pastebin”, and now the URL of the pasted item will be in your clipboard for you to ctrl-v to your friend. Neat, eh?


Tech tip #8: Browse Amarok’s embedded MySQL database.

Amarok can probably be called one of Linux’s flagship programs. However since the upgrade from Amarok 1 to Amarok 2 there have been quite a number of controversial changes. One of these changes is that Amarok switched from an SQLite database to a MySQL database to store song information, however whether or not this was the right move is not the topic of this post (why yes, it was a good move, thanks for asking).

With this new database, users were given two choices – an external database or an embedded database. The embedded database was created to simplify the setup for users who weren’t comfortable with the idea of manually setting up a MySQL database. But what happens if you have an embedded database and afterwards you do want to mess around with it and look inside? For whatever purpose be it bugfixing, locating a specific bit of information, or bulk song management (nothing beats a good query!), sometimes you’d want to do this.

Amarok stores its embedded database information in $KDEHOME/share/apps/amarok/mysqle/amarok/ – where $KDEHOME is usually ~/.kde. So as long as you have MySQL setup elsewhere, all you have to do is create a blank database, and dump all of these files where MySQL stores its information. This location is MySQL’s datadir, which is set inside the my.cnf configuration file, normally placed in /etc/mysql/my.cnf. In a regular install, your data dir will be in /var/lib/mysql/ – and will contain one directory per database. So just copy over Amarok’s database files into the database’s directory. The final step is to ensure the files are owned by the mysql user, done by chown mysql:mysql.

Now you can browse the database normally through your preferred method (command line, PHPMyAdmin, or other MySQL client)

That’s it! I hope this is useful to somebody.


Tech Tip #6: Reencode any video to ensure compatibility with Windows Media Player

Other very useful tip I picked up when doing video manipulation the other day that deserves its own post is reencoding any video so that it will work on a vanilla Windows Media Player (without any other codecs added). Windows Media Player is probably the most stubborn, pathetic video player the software world has ever seen and unfortunately if you produce a video for the general public to view, you need to make sure WMP is happy to play it.

The tool for such a job is obviously ffmpeg, but the suggested commands on the compatibility page of their site seem to compress the videos to a horrendous state at the same time, so after asking on their IRC channel on freenode this is the command that turned up:

ffmpeg -i input -acodec libmp3lame -ab 128k -vcodec msmpeg4v2 -qscale 3 output.avi

Wonderful. Now I can render to whatever I please and worry about compatibility later.


Tech Tip #5: Rotate a video by 90 degrees with mencoder

I was recently doing some video editing work where the workflow was something like this: film in portrait, transfer to computer, rotate videos by 90 degrees, sequence together several videos, strip out background noise from entire video. Filming was done with a camera, sequencing was done by Kdenlive (I’ve previously only had experience with Blender’s VSE and I must say I was very happy with this new application), and the noise-stripping was done with Audacity. I must say I’m surprised at how fast this was all accomplished and kudos to all those developers who created these apps.

However one thing I didn’t know how to do was how to rotate the video by 90 degrees. Kdenlive can do it but it ends up being awkwardly stretched and I couldn’t figure out how to unstretch it. Luckily mencoder, which comes with the mplayer package, has got a few tricks up its sleeve.

More for my own records than for anybody else, here’s the command I used:

mencoder -vf rotate=2 -o output.avi -oac pcm -ovc lavc

As my input file was a .mov some of the sound wasn’t synchronised well after rotating, which was easily fixed by this option -demuxer mov. If you want to rotate clockwise instead of anticlockwise change rotate=2 to rotate=1.


Tech tip #4: Copy a random set of files from a directory.

More for archival purposes than anything, today I wanted to copy some songs out of my serious mess of a music "collection" onto my microSD card. I didn’t want to have to choose and I haven’t rated my songs so that wouldn’t help. Instead I wanted a random selection of songs. I’m not a bashmaster (absolutely pathetic at it, actually) but this is what I ended up using – after symlinking all of the various directories I had my files under together:

find -L /home/drive/music -type f -name "*.mp3" | sort -R | tail -n100 | while read file; do cp "$file" /media/disk/music/; done

-n100 represents how many files are going to be copied. Hope it helps somebody! Of course any improvements are welcome.


Tech tip #3: Rip audio from an .FLV file.

Well folks, here’s another quick tech tip that I use once in a while. How do you rip only the audio from an .FLV file? .FLV files, or Flash Video files are the format used in browser-embedded videos, common on video-sharing sites such as YouTube or Vimeo (and Eadrax!) For whatever reason if you have an .FLV file of your favourite music video, now you can get the music rocking solo.

mencoder a.flv -o a.mp3 -of rawaudio -oac mp3lame -lameopts cbr:br=192 -ovc copy

I’ll stay off tech tips for a while as the weekend is coming up.


Tech Tip: Speed up Firefox to use less CPU.

firefox_throbberIt seems as though I’m coming up with a lot of little series here on my blog.  Such existing examples include “How to actually use your computer”, “How to make a website”, and “Rapid fire”. I’ve decided to start yet another one. This one, as you’ve probably guessed from the title, is called “Tech Tips”.

For the first ever Tech Tip post, I’ve decided to address an issue quite a lot of Firefox users are experiencing. Mozilla Firefox is a popular browser and so it should seem a sad issue when people experience 30% or more CPU usage. Some testing has revealed the culprit to be tabs. Not just tabs, but specifically the loading animation – those spinning circle things – that cause this CPU usage.

Are you a victim of this issue? It’s simple to test. Open up about 3 or more tabs and tell them to load non-existent pages. This will cause Firefox to load them until they timeout. During this period, quickly fire up an xterm and start up “top”. Check the X and firefox CPU usages. If you are on Windows, press control-alt-delete and go to system processes, check the CPU usage. If you see spikes (sudden surges in CPU % usage), it’s likely it’s because of Mozilla Firefox.

Alright. How do I fix this issue? Well, you’ll have to remove that annoying loading animation. (You can try change it to something that isn’t animated, but I haven’t tested that). To remove it, you don’t need to do dirty hacks into your theme, but simply edit the Firefox css. That’s right, it’s really simple! (Wow, the power of open-source yet again!)

Step 1: If you are on Linux, go to your ~/.mozilla/firefox/***.default/chrome/ folder, where *** is a random bunch of characters. If you are on Windows, go to C:\Program Files\Mozilla Firefox\chrome\

Step 2: In that directory, find a file called userChrome-example.css. Rename it to userChrome.css. If you look in the file, you should see some examples with lots of comments explaining what things do.

Step 3: The thing you’re looking for is called the “throbber”. Stupid name, I know, but that’s what it’s called. Add these few lines and it should remove the Throbber animation on the top right of the window and the Throbber animation on each of the individual tabs – respectively (for each code block).

/* Eliminate the throbber and its annoying movement */
#throbber-box {
display: none !important;
/* Remove tab loading indicator while the tab is loading */
.tabbrowser-tabs *|tab[busy] .tab-icon {
display: none !important;

Step 4: Restart Firefox and all Throbber nastiness should be gone. Your Firefox should now use sane CPU % and feel faster in general.

Hope it helped!