Thomas Fischer's Weblog

Life, Linux, LaTeX

Archive for November 2009

Mounting devices in KDE without Konqueror, Dolphin, or digiKam …

leave a comment »

KDE 4 has this nice plasma widget called ‘device notifier’, which shows attached devices such as USB flash drives, CD/DVD drives, or digital cameras.

Device Notifier

Device Notifier

Clicking on this icon shows all attached devices, in my example it is a single USB flash drive named ‘256MThFisch’.

Device Notifier plasma widget

Device Notifier plasma widget

Clicking on such a device brings up a list of possible actions, e.g. to browse the files with Dolphin or Konqueror, downloading all photos with digiKam, or playing music titles with Amarok.

List of actions with device

List of actions with device

Well, this is quite nice for users relying on KDE software only. But what happens if you are a power-user, using terminals such as Konsole? Whenever you want to mount a device, you have to start an application such as Dolphin, Konqueror, or digiKam even if you do not want to use it …

Adding your own Action for Mounting

As KDE4 is very configurable, you can improve this situation. In the System Settings you can configure which action are available when a storage medium becomes available. Here, we are going to add our own action which ‘just’ mounts a device.

System Settings - Advanced

System Settings - Advanced


Configuration of Actions for Devices

Configuration of Actions for Devices

To add you own action, click on the ‘Add’ button and enter a name for the new action, such as ‘Mount’.

Adding a new action

Adding a new action

In this new action, you can an icon which resembles that action of mounting. In my case, I chose emblem-mounted.png from the emblems directory in the Oxygen icon set. For the command to execute, you can enter any command you like. If you want to see no feedback, use /bin/true. In my example, I used /usr/bin/kdialog --msgbox to get a message box showing a confirmation once the mount process is complete.

Next time you plug in an USB drive, a new option will show up to ‘just’ mount you device without starting any bloated application.

List of actions, 'just mount' option included

List of actions, 'just mount' option included

Once you activate the ‘Mount’ option, it takes 1-2 seconds and a message box pops up confirming the mount operation. The device is read to use in any application.

Message box

Message box

Current Issues

The current approach has some minor issues which may get addressed in later improvements:

  • Cases where the mounting operation fails are not handled
  • The message box does not show the devices name, type or mount point

Still, good luck with testing this ‘hack’ 🙂

Advertisements

Written by Thomas Fischer

November 9, 2009 at 22:43

Posted in KDE, Linux

Tagged with , , , , , , ,