views:

6

answers:

1

Hello, I am able to create keyboard shortcuts for Ctrl-F1 and Ctrl-F2, making them launch a script, using the Control Center interface, Input Actions section. The platform of interest is KDE 3.5 on CentOS 5 at present, but 4.x is also of less immediate interest.

What I need, however, is to create the same shortcuts from a shell script, run after installation of an RPM: this RPM creates a user and then preconfigures its KDE environment completely. So far, I've been able to do stuff like

cat > kdesktoprc <<- EOM
[Desktop0]
WallpaperMode=NoWallpaper
EOM

and then upon first login the KDE setup would pick up from there just fine. I guess what I am trying to do is preseeding this specific account, but I don't want to interfere with any other present or future account on the same host.

Unfortunately, I have not been able to make the same work with Input Actions, whose configuration is somewhat more involved. Before attempting to unravel it further, I decided to ask if there was a better way.

In other words, is there a command to create a keyboard shortcut (I don't think I can use DCOP, because KDE would not be running at the time) ?

I skimmed hints to the kconf_update mechanism, but was unable to ascertain if it was appropriate for my use case: is there a reference available ?

Thank you in advance,

A: 

I found an approach which appears to work. First, I create a .khotkeys file, call it zzz.khotkeys, and store it under /usr/hsare/apps/khotkeys. A good starting point for that is the printscreen.khotkeys file.

This .khotkeys file has two sections, a [Data] section with the hotkey definition(s), and a [Main] section where among other keys we have

Id=zzz

which is used to remember which key definitions have been already imported.

To put the definitions in zzz.khotkeys into effect, you could use this

/usr/lib/kconf_update_bin/khotkeys_update --id zzz

which seems to invoke functionality equivalent to the "Import" button in the "Input Actions" user interface.

This step incurs a number of obstacles in my scenario, which is running all of the abovce in the %post script of an RPM install.

First, khotkeys_update fails if it cannot contact an X server; on the surface this seems silly, as it should only need to perform text wrangling, but this can be addressed by placing its invocation inside a .desktop file in .kde/Autostart.

Second, khotkeys_update does not exactly look like a published interface which can be relied upon over time; since this is for CentOS/KDE 3.5 in a context where little evolution is expected, I enjoy the privilege to consider this a minor issue. If there is a published (shell) interface to perform the import, I could not find it (I did not investigate DCOP).

In the end, the same script which directly customized other configuration files under .kde/share/config also adds under .kde/Autostart a file named zzz-keys.desktop which looks like

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=ZZZ Hotkeys
Comment=Ensure ZZZ keyboard shortctus are available
Exec=/usr/lib/kconf_update_bin/khotkeys_update --id zzz

which gets the hotkeys added the first time (they end up inside khotkeysrc) and is skipped on subsequent invocations, because khotkeysrc includes a key name AlreadyInstalled which is also updated to include "zzz", so on subsequent runs khotkeys_update finds it and does not add duplicates.

Schwanritter