This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Import khotkeys shortcuts via commandline / automatically

Tags: None
(comma "," separated)
User avatar
doktor5000
Registered Member
Posts
28
Karma
0
OS
Hi all,

I'm currently searching for a way to import an exported set of shortcuts from a .khotkeys file automatically.
Only related information I've found is viewtopic.php?f=43&t=109524
Maybe also viewtopic.php?f=17&t=88836&p=165050 but that's only for KDE3 and it seems khotkeys_update does not exist anymore.

Documentation also only talks about import via kcm module: http://docs.kde.org/stable/en/kde-works ... l/khotkeys

So how to import shortcuts from a .khotkeys file via commandline?
User avatar
doktor5000
Registered Member
Posts
28
Karma
0
OS
Hmmm, when dropping the .khotkeys file into /usr/share/kde4/apps/khotkeys/ it gets automatically imported.
But it's not merged in the existing config, and I'm ending up with two groups of the same name, and even the predefined
PrintScreen shortcut gets duplicated.

So seems quite messy ... :/
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
In terms of importing shortcuts via CLI, you might want to take a look at the format of ~/.kde4/share/config/khotkeysrc - there doesn't appear to be a D-Bus interface i'm afraid. The configuration module appears to edit the configuration file directly and tell the daemon component to reload that.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
doktor5000
Registered Member
Posts
28
Karma
0
OS
bcooksley wrote:In terms of importing shortcuts via CLI, you might want to take a look at the format of ~/.kde4/share/config/khotkeysrc

Well, tried that already to merge my existing shortcuts manually into there, but didn't work quite that well.
It's also ugly to parse.

My workaround works pretty well so far, define the shortcuts in a fresh KDE install, put them in a separate group and name the group unique,
then export that, check "allow merging" and also use a unique ID. The ID will be the field "ImportId" in the [Main] section, and khotkeys will automatically
import it if the ID is different than the other ones in /usr/share/apps/khotkeys/ and has not been imported before.

During distro customization just copying my exported shortcuts into /usr/share/apps/khotkeys/ takes care that they will be present after login.

About the dbus interface, I've seen this:

[doktor5000@Mageia3 ~]$ qdbus org.kde.kded /modules/khotkeys
method QString org.kde.khotkeys.get_menuentry_shortcut(QString storageId)
method Q_NOREPLY void org.kde.khotkeys.quit()
method QString org.kde.khotkeys.register_menuentry_shortcut(QString storageId, QString sequence)
method Q_NOREPLY void org.kde.khotkeys.reread_configuration()
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString interface_name, QString property_name)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString interface_name)
method void org.freedesktop.DBus.Properties.Set(QString interface_name, QString property_name, QDBusVariant value)
method QString org.freedesktop.DBus.Introspectable.Introspect()
method QString org.freedesktop.DBus.Peer.GetMachineId()
method void org.freedesktop.DBus.Peer.Ping()


I'm not that much into the dbus interfaces, do you know if this can be used to add shortcuts via dbus calls?
Also the one below "org.kde.khotkeys.reread_configuration" could probably be used to reload khotkeys configuration?
Didn't find any documentation about this so far ...
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Yes, I suspect "org.kde.khotkeys.reread_configuration" can be used to force the custom shortcuts system to reload it's configuration.
Unfortunately i'm not sure as to the purpose of "org.kde.khotkeys.register_menuentry_shortcut".

In terms of documentation, this is an internal interface of sorts, so I would suggest checking with the actual source code behind the custom shortcuts system (khotkeys).


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], kde-naveen, Sogou [Bot], Yahoo [Bot]