Thomas Fischer's Weblog

Life, Linux, LaTeX

Posts Tagged ‘konqueror

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’ 🙂

Written by Thomas Fischer

November 9, 2009 at 22:43

Posted in KDE, Linux

Tagged with , , , , , , ,

Automatic AdBlock filter list updates in Konqueror

with 4 comments

As a KDE user, Konqueror is my favorite browser. It offers smooth integration into KDE, both in looks and features (e.g. using the Okular part to view PDFs). Its rendering engine is so good that it was forked into WebKit used in Apple’s Safari and Qt. One aspect Konqueror lacks in comparison to Firefox, though, is the support of plugins/addons of all kinds to add more features to the browser. There is a set of security and privacy enhancing plugins for Firefox I use myself and recommend to others. One of them is AdBlock Plus which uses a well-maintained list of URLs to block if you want to experience the net with less annoyance.

On the other side, Konqueror has a similar adblocking functionality built-in since KDE 3.5 (late 2005). In the configuration dialog, users can add fragments or regular expressions of URLs to be blocked. Maintaining such a list yourself is quite cumbersome, especially if you have accounts on several computers. At least since March 2007 there has been a feature request in KDE’s bug tracking system to add an automatic updater to Konqueror’s ad-filtering.

Last weekend, I started to scratch the itch and implemented an automatic filter list updater. Luckily, the internal format of AdBlock entries in Konqueror matches the one use by AdBlock Plus, except that some advanced features are not (yet) supported. Based on the then-current KDE 4.2.4 code I made changes to both kdelibs and kdebase. The former one contains the KHTML component including the actual filter, the latter contains the code for Konqueror’s settings GUI.

The changes I made to kdelibs work as follows: Read the khtmlrc configuration file to get a list of filter files following the format used by AdBlock Plus. My example configuration file contains several lists from easylist.adblock.org. The filter list files are downloaded and cached if no local copy is available or if it is outdated. Each filter list file is loaded and added to Konqueror’s current filter list each time the browser is started. The user-configured filter list is not modified, as the changes occur in memory only.

If you edit your khtmlrc manually to add new filter lists, this works already fine without GUI. For a better usability experience, I modified Konqueror’s settings dialog so that users can select from a list of preconfigured filter lists (currently, all lists from EasyList) which to actually use. Additionally, the time interval to refresh the lists can be configured.

Manual filter in Konqueror's AdBlockAutomatic filter in Konqueror's AdBlock

I refrained from adding an option to add, modify or delete list entries in the GUI. This is simply for two reasons: (1) Users may tend to enter filter lists that do not follow the format (e.g. from other adblocking filter sites) and (2) the list of available filter lists does not change that often that it cannot be changed in the next monthly update of KDE. If users are eager to add more lists not officially approved, they can still edit their configuration files manually.

All patches and an example configuration file are available from bug report 143495 in KDE’s bug tracking system. If you have constructive suggestions, please add you comments to the bug report (do not post comments in this blog, that won’t help). To support the patch in getting approved and added to the official code base, vote for the bug (login required).

Update (20091201): I posted the patches on KDE’s Review Board a few days ago and got a review from David Faure. There are some minor issues to change and fix, but his overall comment was “Nice (but obviously not for 4.4 due to the feature freeze, it will have to be for 4.5)” 🙂

Update (20100812): My AdBlock extension has become part of KDE 4.5 🙂 Check out this screen shot:AdBlock filter list in KDE 4.5

Written by Thomas Fischer

August 5, 2009 at 22:08

Posted in KDE, Linux

Tagged with , ,