Tips

warning: Creating default object from empty value in /var/www/legroom_v3/htdocs/modules/taxonomy/taxonomy.pages.inc on line 33.

KDE Hidden Preferences

One thing I love about KDE is it's incredible breadth of configuration options. I really like to tweak my environment to best suite my needs, preferences, and habits. I know what works best for me, and prefer to have my desktop environment reflect those preferences.

Despite the vast number of preferences in the KDE Control Center, there are still quite a few options for which new GUI preference setting exists. The Hidden Configuration KDE Wiki page discusses some of these options, and is worth a read if you use KDE. In particular, I was looking for a way to disable the listing and expanding of archive files in Konqueror's sidebar. This "feature" was borrowed from Windows XP (Compressed Folders), where it always bugged the hell out of me. If I wanted view the contents of Zip files in Windows Explorer then I'd unzip the damn file.

Needless to say, I was rather dismayed and disappointed when I saw this "feature" appear in a KDE upgrade. There is no GUI preference available for disabling it, but after quite a bit of internet searching I found the above Hidden Configuration page, which discusses how to do it. It's a useful resource, and I wanted to make a note of it here both for the benefit of others as well as so I can easily find the page again next time I setup KDE. :-)

If you would like to disable this feature as well, first try entering this command (as documented in the Wiki): kwriteconfig --file konqsidebartng.rc --group General --key ShowArchivesAsFolders --type bool false. You'll need to restart Konqueror for the change to take effect. If that does not work (it didn't for me), do this instead:

  1. Edit ~/.kde/share/config/konqsidebartng.rc
  2. Search for the option titled ShowArchivesAsFolders
  3. If you ran the kwriteconfig command, you should find it under the [General] category. Delete that under [General] and instead add ShowArchivesAsFolders=false it to the top of the file
  4. If you do not already have that setting in the file, simply add it to the top of the file as described in the last step
  5. Save the file and restart konqueror

You should now be rid of those annoying archive folders. Enjoy.

Oh, and if you'd like to disable this feature in Windows XP as well, you can easily to so by running the following command: regsvr32.exe /u zipfldr.dll. If you choose to reenable it, you can do so simply by running regsvr32.exe zipfldr.dll.

Useful New Windows Apps

I came across a couple of very useful Windows apps tonight while doing some maintenance on my systems. The first is Core Mini-SFTP Server. This is a commercial/proprietary app, but it's available free of charge. As implied by the name, it's a stripped-down sFTP server for Windows. No installation or configuration is necessary; simply download and run the executable, specify the username, password, and root directory, then click Start. Any user can now connect via SFTP using the specified credentials. It's very convenient if you simply need quick and easy access to an sFTP server on Windows, but, of course, it does have limitations. It's strictly single user, must be run interactively (ie, it cannot be run as a service when the system starts), and only minimal sftp functionality is included (the sftp client under Linux works, for example, but scp does not). Additionally, it stores the specified password in plaintext within the registry. Keep this in mind when choosing a password, and be sure to delete the key after you're finished if it's a sensitive password (HKCU\Software\FTPWare\msftpsrvr\msftpsrvr).

Next up is a fine new FOSS app for Windows. Infra Recorder is a very slick CD burning application based on cdrecord. The interface is very nice and intuitive, functionally it can do just about anything you'd expect of a CD burning application, and so far it seems quite stable (considering it's a beta release). I'm quite pleased with it so far. The audio capabilities are somewhat limited (it can only handle WAV files directly, for example), but given that I use Exact Audio Copy for all of my audio CD needs it's not much of an issue for me. It'll make a great alternative to cdrtfe, my current burning app of choice under Windows.

Enjoy. :-)

Edit: I'm afraid I'm going to have to take back some of the praise for Infra Recorder. It doesn't seem to actually want to write the disc image that you tell it to burn. Instead, it just pretends to burn it for several minutes, letting you think it's being written to disc. I discovered this after thinking I had burned a freshly downloaded 700 MB Kubuntu ISO, only to find out after I had deleted ISO that it had not, in fact, been written to disc. So, I downloaded it again, checked and double-checked all settings (especially the "simulation" option, and attempted to burn it again, but it still failed. I then fired up cdrtfe and burned it without problem on the first attempt, confirming that the disc image was fine.

I'd recommend sticking with cdrtfe for important stuff for now.

Adding Custom Actions to KDE Context Menus (aka, servicemenus)

One thing I always liked about Windows (compared to Linux) is that it's very easy to add custom actions to the context (right-click) menu for any given file types. For example, I used this ability with Universal Extractor to add UniExtract... entries to the context menu of archive files, and I use it with Open with Arguments to add Open with arguments... to .exe and .bat files. I missed that ability for quite some time once I began using Linux as my primary OS. Something as simple as extracting Zip files, for example, would require jumping to the command line and entering an appropriate unzip command[1]. However, a while back I stumbled across a tutorial entitled, "Creating Konqueror Service Menus", and was very pleasantly surprised to discover that this allowed me to do exactly what I had wanted for so long.

I setup a few custom actions (called "servicemenus" in KDE) a while back on my home system and pretty much forgot about it since it "just worked", but since I'm now using a new desktop system at home I'm already missing these custom actions. So, I figured I'd document them here while setting them up again. Hopefully this information will help out other Linux users. Much more thorough instructions can be found in the article referenced above - my instructions should be treated as more of a reference.

To begin, you'll need to create a new .desktop file for the action you want to perform. For the purposes of this article, I'm going to add a context menu item that will extract RAR files to the current directory. So, we'll create a new file named ~/.kde/share/apps/konqueror/servicemenus/rar.desktop. The file name is arbitrary, but it must be saved in the specified location, and must end with the .desktop extension. Next open the file in your favorite editor and add the following:

rar.desktop
[Desktop Entry]
ServiceTypes=application/x-rar,application/x-rar-compressed
Actions=unrar

[Desktop Action unrar]
Name=Extract Here
Exec=launch.sh %d unrar x \"%f\"
Icon=package

This code is not very intuitive, so I'll explain each option

  • ServiceTypes - specifies the type of files with which the action should be associated. The easiest way to determine this information is to run Konqueror, click Settings, Configure Konqueror, and select the File Associations section. Enter the file extension you want to associate the action with (in this case, rar, and then add the listed file types to the Service Types entry. Repeat for each extension if you want to associate with multiple types
  • Actions - specifies the name of the stanza that defines the action. Multiple actions can be specified, but we'll only use one here. Just make sure that the name entered here matches the [Desktop Action xxx] defined below.
  • Name - the name of the context menu entry that will appear when right-clicking on the given type of files
  • Exec - the action to perform when selected; more details below. Please also see this page for a full discussion of this item, including a list of valid field codes.
  • Icon - the name of the icon to associate with the context menu entry (optional). This can point to a real file if you want to use a custom icon, but you have to specify the full path and filename. In this case, I'm telling it to use the package icon from the current icon set. The easiest way (that I know of) to view these "pre-defined" icons is to right-click on any K-menu entry, select Edit Item, and click on the icon button for that item, It'll bring up an icon browser. Find the icon you like best, note the name, then close the windows and add it to the Icon entry.

Now, let's discuss the Exec entry. Ordinarily you'd probably want to call the binary directly; eg., unrar x \"%f\". In this case, however, I want to get feedback on the current progress of the operation, as well as any errors that might have occured. Since unrar is a CLI application, running it from a GUI wouldn't provide any feedback. It would simply run in the background and then exit. To work around this, I created a "wrapper" script called launch.sh that will accept arguments passed by KDE and run the command in a standalone xterm terminal[2]. Using this method, clicking the the action in the context menu will spawn a new xterm window, which will then display the current status of the operation. It will also allow you to enter any additional information that may be necessary, such as answering an overwrite prompt or providing an archive password.

The code for the wrapper script is listed below. The only dependency is that xterm must be installed in an your $PATH.

launch.sh
#!/bin/bash

# enable support for spaces
IFS=$'\r\n'

# check for number of arguments
if [ "$2" = "" ]; then
    echo "Usage: $0 <dir> <command>"
    exit 1
fi

# set directory and command
DIR=$1
shift
COM=$@

# execute command in xterm
cd $DIR
xterm -e $COM
exit

That should do it. Save both of those files, make sure that launch.sh is copied to a location in your $PATH, then try right-clicking on a RAR file. Under the Actions submenu, you should now see an entry called Extract Here. Click it, and if all goes well the contents of the RAR file should be extracted to that directory.

For reference, here's a list of all KDE servicemenus that I have created:

  • audacious.desktop - Enqueue and begin playing all selected audio files in Audacious (originally written for XMMS, and still contains the commented code if desired)
  • iso.desktop - Mount an ISO CD-Rom image in a subdirectory of the current folder to allow file browsing and copying; press Enter when complete to unmount the ISO and remove the temporary directory. This service menu requires my mountiso.sh script.
  • par.desktop - Repair damaged RAR archives using associated PAR files
  • rar.desktop - Extract contents of RAR archives
  • tbz.desktop - Extract contents of bzipped tarballs
  • tgz.desktop - Extract contents of gzipped tarballs
  • vmdk.desktop - Mount a VMware disk image in a subdirectory of the current folder to allow file browsing and copying; press Ctrl-C when complete to unmount the disk image and remove the temporary directory. This service menu requires my mountvmdk.sh script. More details can be found in the How to Mount VMware Disk Images under Linux article.
  • xine.desktop - Enque and begin playing all selected video files in Xine
  • zip.desktop - Extract contents of ZIP archives
  • launch.sh - Wrapper script to display service menu output in an xterm window; most of my servicemenus require this script

[1] Yes, I know that I can install a GUI archiving utility such as Ark. However, that's not really relevant here for two reasons:

  1. I want to right-click and extract directly within Konqueror without first opening it in a separate utility
  2. File extraction is just an easy-to-visualize simple example - there are other cases where install a separate utility is not an option or just doesn't make any sense

[2] Yes, you could theoretically call xterm directly from the .desktop file rather than using a wrapper script, but I couldn't get it to work properly. I had issues with getting xterm and the associated command (in this case, unrar) to accept the correct path, as well as dealing with spaces in the filename. My wrapper script will handle anything that's thrown at it (so far, anyway...).

Download/Saving Streaming Videos

Streaming (aka, embedded) video has been around since the beginning of the internet, and while it can certainly be a very useful technology, I hate companies and websites that require you to stream the video and don't even offer an option to download it. What if you want to view it multiple times? What if you want to show a friend or co-worker? Tough! You have to stream it (re-download it) every single time you watch it. The only possibly reason for doing this that I can think of is that it supposedly allows the hosting site more control over the video, but it creates a severe inconvenience for users, prevents a number of possible customers from watching it in the first place (eg, if they're not running a "blessed" operating system, browser, or plugin), and exponentially increases bandwidth costs for the hosting provider. Additionally, the very fact that the movie has to be sent to the client to allow it to be played and displayed means that the client still gets a copy and can still save it anyway, just with much greater hassle.

If you want to save a streaming video from a site that doesn't offer a proper download link, you have a few options. Like most things in technology these range from easy but limited to difficult but extremely flexible. For now, I'm going to discuss the easy approach. :-) I'm also going to assume you're using Mozilla Firefox (if you're not, you really should be).

There are a number of Firefox extensions available that can greatly assist with saving embedded/streaming video clips. A simple search for "download video" on the Firefox Add-ons returns 19 extensions. I've personally used VideoDownloader in the past, and it worked well.

If you don't want to install a new extension just for downloading videos, and option is to use Greasemonkey scripts. Greasemonkey is a really powerful extensions that allows users to create or install custom scripts that can change the behavior of any web page. In this case, a Greasemonkey script can analyze the page for embedded video clips, then automatically add a download link to that video; simply click the download link to save the video. Two great scripts for downloading embedded videos are Apple Trailer Download and Download Video (though I use this version of Download Video). Note that you must first install Greasemonkey before you can install these scripts. You can find a lot more useful Greasemonkey scripts on my Mozilla Firefox Tips and Tricks page, as well as a massive collection of contributed scripts on Userscripts.org.

The primary limitation with the extension/script method is that it's often limited to particular sites. Apple Trailer Download, for example, is limited to just movie trailers hosted on the Apple Movie Trailers website. Download Video and VideoDownloader both support a number of different sites (including the most popular, YouTube and Google Video), but are still limited to only sites they "know" about. I'll follow up this article with more advanced techniques and suggestions that should help you save just about any embedded video.

How to Create Truly Obscure Passwords

I recently came across an interesting article on Irongeek.com (which itself is a pretty interesting security site that I'll probably add to my list of news feeds) entitled, "ALT+NUMPAD ASCII Key Combos: The α and Ω of Creating Obscure Passwords." The author suggests the idea of using non-standard (ie, not defined on standard keyboards) special characters as part of your password. It's common knowledge that adding special characters to your password greatly increases the difficulty of guessing or brute forcing the password. This extends the idea by adding normally hidden (and often unthought of) characters to the mix. So, while something like abCD1234%^&* might be a good example of using special characters in a password (though obviously you'd want something more random than that sequence), consider this password: äßÇн²¶╔¥¢. I'd love to see the password cracker that can crack that one. :-)

Of course, as the author mentions there are downsides to this. Increased complexity notwithstanding, its strength is also its main weakness; these are non-standard characters, and as such not all applications and operating support them in the same manner (or at all). While this may work great as a Windows user password, for example, it may not be possible to use it as a Linux user password.

Regardless, it's still an interesting concept that deserves some attention. Check out the article for more details on the subject, as well as a tutorial and reference charts for entering special characters. The Wikipedia article on Windows Alt keycodes (also referenced in the article) is another good resource.