Cool new window features in KDE 4.4 RC1

January 17, 2010

I just updated KDE to 4.4 RC1 in Kubuntu 9.10. The new window features are really great!

Tabbed Windows

You like tabs in browsers? Then you will like the new window tabs in KDE, that will allow you to group together different windows. Here is how it looks like:

  • First add a window to another existing window

  • Afterwards you can switch between the windows with the new window tabs

This is very usable if you are working with lots of windows and want to group together windows that are e.g. used for a single task.

Position windows so that they share the screen equally

If you have a screen with a high resolution, then it is sometimes very useful to have two windows open next to each other. I like to have e.g. documentation open in one window and in another a config file. Of course you can arrange the windows manually, so that the two windows together use the whole screen. But in KDE 4.4 you just have to move one window to the left or the right screen edge and the window will automatically be resized to half of the screen size.

Selecting windows with the task manager preview

If you have enabled desktop effects in KDE 4.X the task manager shows previews of windows by default. In KDE 4.4 it is now possible to click on a preview of a window to switch to the window.

Thanks to the KDE team – You are doing a great job!


Device notifier script for updating OSM map on Garmin device

December 30, 2009

I am regularly mapping things in Openstreetmap with my Garmin Nüvi 205 and a second GPS Tracker (iBlue 747a+).

It is very usefull to have a current version of the OSM map on the Garmin device, so that you see what is actually missing in the map when you are in the field.

I used to manually download the map file from http://dev.openstreetmap.de/aio/ and then uncompressing it to the garmin device. But I was getting tired of doing this repetitive task and so I wrote a script for this….

The script can be executed via the device notifier in KDE4 (more infos about device notifier can be found in an older blogpost of mine: Adding actions to the Device Notifier widget in KDE 4.3).


After selecting “Update OSM map on Garmin device” in the device notifier the script downloads the map and shows a progressbar.

When it is finished a pop-up appears and the device can be removed via device notifier.

I have attached the script (update_map.sh)  and the device notifier config (update_map.desktop) to this post.

The script needs the package “pv” (pipe viewer). It can be installed in kubuntu with “apt-get install pv“.

update_map.sh (place it in /usr/local/bin)

#!/bin/bash

url=http://dev.openstreetmap.de/aio/germany/gmapsupp.img.bz2
path=$1
target_dir=$path/Garmin
target_file=$target_dir/gmapsupp.img

progressfile=/tmp/progress_$$
echo 0 > $progressfile

function watch_progress {
dbusRef=$1
while [ true ]
do
sleep 1
# check if dbus object exists
qdbus $dbusRef 1>/dev/null 2>&1
if [ “$?” -ne “0” ]
then
# dbus Object does not exist (anymore)
exit 0
fi

# read current progress
progress=`tail -n1 $progressfile`

# set progress to progressbar
qdbus $dbusRef Set “” “value” $progress
done

}

if [ ! -d $target_dir ]
then
kdialog –msgbox “$target_dir does not exist!”
exit 1
fi

kdialog –yesno “Update OSM Map on $target_dir ?”
ret=$?

if [ “$ret” -eq “0” ]
then

# get file size
size=`curl -sI $url | grep Content-Length | cut -d ‘ ‘ -f 2 | sed “s/[^0-9]//g”`
kbsize=$((size/1024))k

dbusRef=`kdialog –progressbar “Downloading OSM Map” 100`
watch_progress “$dbusRef” &

wget -qO- $url | pv -s $kbsize -n 2>$progressfile | bunzip2 > $target_file
sync
sync

qdbus $dbusRef close
rm -f $progressfile

error=0
#check return codes in pipe
for rc in ${PIPESTATUS[*]}
do

if [ “$rc” -ne “0” ]
then
error=1
fi
done

if [ “$error” -ne “0” ]
then
kdialog –msgbox “There was an error updating the map”;
else
kdialog –msgbox “The map was updated successfully – You may now disconnect the device”;
fi

else
kdialog –msgbox “cancelled…”
fi

update_map.desktop (place it in e.g. /usr/share/kde4/apps/solid/actions)

[Desktop Entry]
X-KDE-Solid-Predicate=[[ StorageVolume.ignored == false AND StorageVolume.usage == ‘FileSystem’ ] OR [ IS StorageAccess AND StorageDrive.driveType == ‘Floppy’ ]]
Type=Service
Actions=open;

[Desktop Action open]
Name=Update OSM map on Garmin device
Exec=/usr/local/bin/update_map.sh %f
Icon=system-file-manager
X-Ubuntu-Gettext-Domain=desktop_kdebase-workspace


Openstreetmap event calendar on a map

November 18, 2009

As someone who is interested in Openstreetmap I’d like to know when an OSM-event takes place somewhere near me.

There is an event calendar on the OSM wiki where people publish the dates of OSM mapping parties and other osm meetings.

It is nice that there is a central place where to look for such meetings. The problem with this list is however, that events all around the world are shown there and it is not easy to find events that take place in a specific region.

The only way to limit the events by a region is to use an iCal feed for a specific region. The region must be supplied in coordinates (http://www.openstreetmap.org.uk/events.ics?bbox=-0.589,51.278,0.251,51.745)  and you need a client to display the ics data. Most people won’t use this feature.

In my opinion the best place for this OSM event calendar would be an OSM map. So I decided to put the events as markers on an OSM map. Displaying maps and adding markers is really easy thanks to openlayers.org. All you need is a bit of javascript and a text file containing the markers.

The hard thing is to get the coordinates of the events. For this task I coded the following in perl.
The events in the calendar usually only contain short descriptions of the events and a link to a more detailed page (e.g. Nov 17 München monthly meeting). I first tried to get the coordinates from the city names. Such a feature is provided by  nominatim. You can query the service by http GET requests and the answer can be return in JSON format (e.g. http://nominatim.openstreetmap.org/?q=München+Germany&format=json). This worked quite well with names that are unique, but it is impossible to decide which coordinates are correct if multiple results are returned.
To get the coordinates anyway I did a trick. Each event usually links to a page in the OSM wiki where more details to this event are displayed. Usually these wiki pages contain maps showing the region where the event takes place. In the soucecode of the wiki page you find the coordinate of the region by searching for the strings “lon=” and “lat=”.

This is how the map looks like:

A working version of the map can be found here

I know that the map is not perfect. It is just hacked together in a couple of hours. There probably a lot of bugs in the map (e.g. special characters are not shown correct,…) and not all coordinates are correct. But I think you get a nice overview of where events take place and which of the events are in the near future.

I hope this example shows that it would be nice to have this feature in the OSM wiki or maybe even on the official map (to get more people in touch with the OSM community). This could be implemented very easily if all events would have been provided with coordinates. Maybe a good way to implement this would be via GeoRSS. An example can be found at the openlayers website.

iCal feed


Adding actions to the Device Notifier widget in KDE 4.3

November 5, 2009

The default behaviour

The KDE device notifier is a widget that can be used to managed plugged-in devices like e.g. usb pen-drives. In a default Kubuntu installation this is shown as an icon in the taskbar. When clicking on it it shows e.g. all partitions of plugged in devices.

device_notifier_taskbar

When you click on a partition it offers a couple of actions that can be started for that particular partition (e.g. downloading pictures to digikam or open the drive in dolphin).

device_notifier_default

Why I needed an additional action

A task I have to do every day is to move downloaded podcast on a usb pen-drive, so I listen to the podcasts on my car radio. In the beginning I moved the files manually to the drive and then I wrote a script that did this job for me.
The Script created a directory in the format ddmmyyyy (e.g. /media/disk/05112009) on the pen-drive and moved the files in there. Afterwards it did a sync to ensure that all data had been flushed to the drive.

As I always used the device notifier to mount the drive, I wanted to have my script as an action in there.

Where do I find the actions in the filesystem?

The actions of the device notifier are placed in the directory /usr/share/kde4/apps/solid/actions. There is one file for each action.
Custom actions for a specific user can be placed in ~/.kde/share/apps/solid/.

There are a couple of paramterers that describe the action e.g.:

  • X-KDE-Solid-Predicate determines for which devices the action should be available
  • Name is the label of the action shown in the device notifier
  • Exec is the command that will be executed.

There are some variables that can be passed to the exec-command (there might be more):

  • %f gives StorageAccess.filePath
  • %d gives Block.device
  • %i gives UDI

Adding an action to device notifier

To execute my mp3 moving script I created the file /usr/share/kde4/apps/solid/actions/movemp3.desktop:

[Desktop Entry]
X-KDE-Solid-Predicate=[[ StorageVolume.ignored == false AND StorageVolume.usage == ‘FileSystem’ ] OR [ IS StorageAccess AND StorageDrive.driveType == ‘Floppy’ ]]
Type=Service
Actions=open;

[Desktop Action open]
Name=Move MP3 files
Exec=/usr/local/bin/copy_mp3_files.sh %f
Icon=system-file-manager
X-Ubuntu-Gettext-Domain=desktop_kdebase-workspace

After restarting KDE the device notifier now contains a new entry:

device_notifier_new

Formerly I started the script from the terminal, but now I start it from the gui. Therefor I added some gui interaction to the script to make it more comfortable:

device_notifier_move1

device_notifier_move2

device_notifier_move3

Just in case anyone is interested in the simple script:

path=$1
mp3path=/home/$USER/pod
datum=`date +”%d%m%y”`
newpath=$path/$datum

kdialog –yesno “Move MP3-files to drive ($newpath)?”
ret=$?

if [ “$ret” -eq “0” ]
then

kdialog –yesno “Delete old files? ( `ls $path/[0-9][0-9][0-9][0-9][0-9][0-9]` )”
if [ “$?” -eq “0” ]
then
rm -r $path/[0-9][0-9][0-9][0-9][0-9][0-9]
fi
mkdir -p $newpath
mv $mp3path/*mp3 $newpath/
sync
sync
sync
kdialog –msgbox “Files were moved, you may now disconnect the drive by device notifier!”

else
kdialog –msgbox “cancelled…”
fi


Digikam 1.0.0-beta5 verwendet Openstreetmap Karten

November 3, 2009

Digikam kann schon ein ganze Weile Fotos auf einer Karte darstellen. Hierfür gibt es die Geolocation Ansicht, welche auf marble aufsetzt. Bisher wurde an dieser Stelle eine ungenaue und wenig detailierte Karte angezeigt. In der aktuellen Version können die Fotos nun auch auf der Openstreetmap Karte dargestellt werden.

digikam_with_osm

Beim herauszoomen aus der Karte werden nebeneinander liegende Bilder zu einem einzelnen zusammengefasst. Auf diesem wird wiederum die Anzahl der zusammengefassten Bilder angezeigt.  Somit wirkt die Karte auch dann nicht überladen, wenn sehr viele Fotos in einem kleinen Gebiet geschossen wurden.

Besonders praktisch finde ich, dass man das Feature mit der digikam Suche kombinieren kann. So kann man sich ganz einfach anzeigen lassen, wo man an einem bestimmten Tag gewandert ist (siehe Screenshot) oder sich z.B. alle mit “Strand” getaggten Fotos auf der Karte anzeigen lassen.

digikam_osm_search

Ein Feature vermisse ich leider noch in der Kartenansicht: Praktisch fände ich es, wenn beim Klick auf ein Foto in der Karte das Foto vergrößert dargestellt würde. Leider passiert beim Klicken auf ein Bild im Moment gar nichts.
Ich werde gleich mal auf kde.org einen Feature Request eintragen (http://bugs.kde.org/show_bug.cgi?id=212967).


Update to Kubuntu 9.10

November 3, 2009

My laptop is now finally running Kubuntu 9.10. After some problem with the upgrade I decided to do a fresh install.

After the regular upgrade the following was messed up:

  1. The boot splash was not shown correct during startup, as the screen resolution settings during boot time seem to have changed in kubuntu 9.10
  2. The x server was running with the wrong resolution (1024×768) and chose the wrong refresh rate of my connected lcd monitor.
    I changed the resolution of my connected monitor in the kde system settings to 1280×1024 and disabled the internal display. Everything looked fine then, except that the mouse pointer disappeared. But worst of all the setting was gone after reboot.

After the fresh install the monitor still didn’t use the full resolution of my connected monitor. Changing the resolution in the kde system settings worked – this time the mouse pointer didn’t disappear. But unfortunately after a reboot the resolution was again to low (1024×768).

I found a very useful page about different ways of changing screen settings: https://wiki.kubuntu.org/X/Config/Resolution

Adding the following line to /etc/kde4/kdm/Xsetop worked for me:

xrandr –output VGA1 –mode 1280×1024 –rate 60

Everything look fine until I opened firefox. The the fonts in the menu bar were far too big.

ugly_firefox

ugly firefox fonts

I then googled a bit and found the bug report Bug #420610. There it was suggested to add the following paragraph to
~/.kde/share/config/kdeglobals:

[General]
XftHintStyle=hintmedium
font=DejaVu Sans,8.-1,5,50,0,0,0,0,0

But this didn’t work. After a kde restart the fonts in firefox looked as they should, but unfortunately the fonts in kde applications  were now much to big.

After playing around with different settings I finally found a solution: In kde “system settings -> Look & Feel -> Appearance -> Fonts” I had to set Force fonts DPI to 96 DPI. Now the fonts in firefox and the other kde applications are as they should be.

fine_firefox1

At a first glance everything then looked fine. But then I entered something into the google search form and the font in the form field was again to large. I had to change the firefox paramter layout.css.dpi to 96 in about:config and restart firefox.



%d bloggers like this: