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!

Advertisements

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


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


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: