Category Archives: KDE

Thinkpad X220 and Ultrabase 3 Docking Station

As I promised, there will be more posts related to the Fedora 16 configuration on a Thinkpad X220. This one will be about the seamless docking/undocking of the notebook from the dock.

It seems that this is largely still a grey area and is something that rarely seems to work as expected, so I had to hack it away, because this one was one of the biggest problems that I face every day because I take the notebook every day at work and dock it so I’m able to use is as a regular desktop PC and¬† in the afternoon I take it with me at home (one never knows for sure where he’ll end up the next day – at work or at a customer’s site ūüôā

What I was aiming was achieving effortless X setup and display switching under the following conditions:

1. When booting the notebook – should work as expected – show KDM on external display when docked and on local LVDS display when not

2. Proper switching when docking / undocking the notebook and there is active user X session

3. Proper switching when docking / undocking the notebook when KDM is active

4. Proper switching when the notebook is docked / undocked during it was suspended

To achieve this I’ve ended up with a simple bash script that verifies the current configuration (docked / undocked) and switches the display accordingly. What was left was to put it in the all appropriate places, so that it gets executed on all of the above listed conditions. So first about the script – it still a work in progress, but is mostly working properly. I’ll update it here when it becomes more polished. Bare in mind that this was written with KDM in mind, although it shouldn’t be so difficult to be adapted for GDM or other login manager.

The Script (thinkpad-dock.sh)


#!/bin/sh
# wait for the dock state to change
sleep 0.5

export IFS=$"\n"

DOCKED=$(cat /sys/devices/platform/dock.0/docked)

# invoke from XSetup with NO_KDM_REBOOT otherwise you'll end up in a KDM reboot loop
NO_KDM_REBOOT=0
for p in $*; do
case "$p" in
"NO_KDM_REBOOT")
NO_KDM_REBOOT=1
;;
"SWITCH_TO_LOCAL")
DOCKED=0
;;
esac
done

function switch_to_local {
export DISPLAY=$1
export XAUTHORITY=$(find /var/run/kdm -name "A${DISPLAY}-*")

# Turn off all external displays
for output in $(/usr/bin/xrandr --verbose|grep "+"|grep connected| grep -v LVDS|awk '{print $1}'); do
logger -t DOCKING "Switching off $DISPLAY"
/usr/bin/xrandr --output $output --off
done

# Turn on local display
logger -t DOCKING "Switching on LVDS1"
/usr/bin/xrandr --output LVDS1 --auto
}

function switch_to_external {
export DISPLAY=$1
export XAUTHORITY=$(find /var/run/kdm -name "A${DISPLAY}-*")

# The Display port on the docking station is on HDMI2 - lets use it and turn of local display
logger -t UNDOCKING "Switching off LVDS1 and turning on HDMI2"
/usr/bin/xrandr --output HDMI2 --primary --left-of LVDS1
/usr/bin/xrandr --output LVDS1 --off
/usr/bin/xrandr --output HDMI2 --primary --auto
}

case "$DOCKED" in
"0")
#undocked event
CONNECTED_USER=0
# Check for logged users with X sessions
for u in $(w | awk '{print $1" "$2}' | grep ' :[0-9]'); do
CONNECTED_USER=1
switch_to_local $(echo $u | awk '{print $2}')
done
if [ $CONNECTED_USER -eq 0 ] && [ ! $NO_KDM_REBOOT ]; then
# we are at login screen
logger -t KDM_DOCKING "Reloading KDM after X setup"
kill $(cat /var/run/kdm/kdm.pid)
fi
;;
"1")
#docked event
CONNECTED_USER=0
for u in $(w | awk '{print $1" "$2}' | grep ' :[0-9]'); do
CONNECTED_USER=1
switch_to_external $(echo $u | awk '{print $2}')
done
if [ $CONNECTED_USER -eq 0 ] && [ ! $NO_KDM_REBOOT ]; then
logger -t KDM_DOCKING "Reloading KDM after X setup"
kill $(cat /var/run/kdm/kdm.pid)
fi
;;
esac

The Hooks

There are several places where you should put an invoke this script.

1. KDM

Obviously you need it to be run at KDM startup when X is initialized. You need to add this line at the and of /etc/kde/kdm/Xsetup file:

/usr/local/sbin/thinkpad-dock.sh NO_KDM_REBOOT

Where /usr/local/sbin/thinkpad-dock.sh is the location of the above script.

One more thing about the KDM – in order to get proper looking KDM login screen on the external display you’ll need to alter the xorg.conf, otherwise you”ll get a little borked KDM background.

Add this file to /etc/X11/xorg.conf.d/ folder


$ cat /etc/X11/xorg.conf.d/01-external-monitor.conf
Section "Device"
Identifier      "HD3000"
Driver         "intel"
Option          "monitor-LVDS1" "local-display"
Option          "monitor-HDMI2" "external-display"
EndSection

Section "Monitor"
Identifier      "local-display"
Option "Enable" "false"
EndSection

Section "Monitor"
Identifier      "external-display"
Option "PreferredMode" "1680x1050"
Option "Position"       "0 0"
EndSection

Be carefull here as this instructs X to NOT enable by default the local display – it will be “later” activated when KDM is started and thinkpad-dock.sh is invoked.

2. Docking / Undocking events

You’ll need to add this file in /etc/udev/rules.d to catch all dock/undock events through udev:


$ cat 81-thinkpad-dock.rules
KERNEL=="dock.0", ACTION=="change", RUN+="/usr/local/sbin/thinkpad-dock.sh"

3. Suspend / Resume events

Finally you’ll need to ensure and check that the configuration was not changed while the notebook was suspended. To hook the script you’ll need to add this in /etc/pm/sleep.d/

$ cat 00check_dock
#!/bin/bash

case "$1" in
hibernate|suspend)
# If sleeping - pretend undocking
/usr/local/sbin/thinkpad-dock.sh SWITCH_TO_LOCAL
;;
thaw|resume)
# If resuming verify docking station presence
/usr/local/sbin/thinkpad-dock.sh
;;
esac

Only one thing to be noted here – the script needs to be executed only during the resume process, but because of some problems that I had during resuming on local display when system was suspended on the dock I had to add the hook also during suspend state and force the X server to be switched over the local display in case the machine is undocked while suspended.

EDIT:

You’ll also need to disable the KDE display management systems, so it does not ask you every time for display reconfiguration because a new display was detected. The only thing that should be done is to stop the service itself like this:

That’s all – there still some quirks that should be polished and may be the script must be made some more general – like defining some variables at the beginning, but I’ll do that later. In general it just works, is quite simple to implement I think and finally the dock is out of my way ūüôā

Tagged , , , ,

Add some fun to your KDE desktop

So today I’ve got a little bored of my o-so-serious-monochrome-desktop and decided to change it a little bit. And here I am surfing my best site for desktop “candies” ūüôā – kde-look.org.

The icons

First I’ve found some pretty good-looking and as it seems quite complete set of icons. Of course I’ve installed them directly through systemsettings->Application Appearance->Icons – it is as easy as that. Just search for kfaenza. Here is a sample screenshot from my desktop with the this iconset:

They may resemble some other OS to some extent, but I do not care Рthey are nice in the end.

The wallpaper

After that I’ve searched for something different and new and found one little nifty plasmoid package that makes wonders ūüôā – The Wallpaper Clock plasmoid. What this plasmoid is supposed to do is to sit in the background as a sort of dynamic wallpaper showing current date and time. It has lots and lots of themes and all of them looking great.

The plasmoit itself depends on¬†plasma-scriptengine-python (as I’m installing this on Fedora 14), and you’ll need to install it if you don’t have it already. Initially I’ve tried installing the package which I’ve downloaded through the plasmoid GUI (“install from local file”), but that failed¬†miserably. So I did it the old way:

$ plasmapkg -r clock # removing the plugin that failed
$ plasmapkg -i clock.plasmoid

EDIT: I’ve done this on another Fedora 14 install and this time I’ve used the “Download new plasma widgets” searched for “wallpaper clock” and directly installed it – it worked like a charm. Still if you have problems, you can try the manual install. You can verify that everything is working as expected by running it manually in separate window:

$ plasmawallpaperviewer --wallpaper clock

/EDIT

And that’s all. After that you can find it sitting under your wallpaper configuration:

As you’ll see adding themes is completely integrated into the plasmoid configuration itself (under “Get New Wallpapers”) and ¬†are very fresh and fun. Please note that some of the themes are only for registered users.

Tagged , , , ,

KDE needs your help (Kmail icon test)

I would like to invite everyone who has spare 5minutes to take this survey which will help polish the KMail UI.

Be KDE!

Tagged , ,

File indexing on Fedora 11 for KDE4.3

Today I’ve got really frustrated that I cannot search through my documents quickly and¬†made a quick research to see why Strigi (which is an file indexing service) cannot be integrated with Nepomuk¬†under my KDE 4.3 installation. I won’t go in details why it was not working but if you would like to make that integration you can read first that blog post which I found very useful:

Nepomuk + Strigi –> Resolving the mystery

With two words – there is a missing part which is responsible for the nepomuk->strigi integration and this is the soprano backend. Reading the instructions in the above blogpost I’ve just recompiled the rpm for the current 4.3 version of KDE.

So what you need to do is grab and install this package

#yum localinstall –nogpgcheck soprano-backend-sesame2-2.3.0-3.fc11.i386.rpm

#yum install strigi

nepomik-strigi

After this – its up to you – Either reboot or relogin to your KDE session and you should see something like this:

So – fire up dolphin and start your search now! ūüôā

Tagged , , , ,