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

kglobalaccel reparseConfiguration not having effect

Tags: None
(comma "," separated)
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
I am modifying file ~/.kde/share/config/kglobalshortcutsrc and trying to make kglobalaccel process to reload its config (Python)
Code: Select all
        dbus.Interface(dbus.SessionBus().get_object('org.kde.kglobalaccel', '/MainApplication'),
                       'org.kde.KApplication').reparseConfiguration()

This also doesn't work:
Code: Select all
qdbus org.kde.kglobalaccel /MainApplication reparseConfiguration

But when i go to System Settings, i don't see my shortcut there.
If i do
Code: Select all
kquitapp kglobalaccel && sleep 2s && kglobalaccel &

everything is ok.

What might be the problem?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I suspect kglobalaccel is not intended to support having it's configuration file changed from underneath it.
What are you attempting to do by manipulating the kglobalaccel configuration file?

The recommended method of interacting with KGlobalAccel is through the class in kdelibs which shares it's name.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
I did a program for changing my KDE configuration in bulk (https://github.com/warvariuc/mykde).
One of the actions is setting additional global shortcuts. So am doing this by modifying file ~/.kde/share/config/kglobalshortcutsrc.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I see. Upon checking the code used by the control module, it appears that it interfaces not with the configuration file, but with kglobalaccel itself, over D-Bus (as all other KDE applications do, when setting global shortcuts).

I suggest either ensuring that kglobalacceld is restarted after completing your modifications, or porting your script to use doRegister and setShortcut, which are parts of the kglobalaccel D-Bus API.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
bcooksley wrote:I suggest either ensuring that kglobalacceld is restarted after completing your modifications, or porting your script to use doRegister and setShortcut, which are parts of the kglobalaccel D-Bus API.

This is what i do - restart kglobalacceld. doRegister and setShortcut are making permanent changes?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The D-Bus commands doRegister and setShortcut will make the changes at runtime, using the standard mechanisms which are used by all KDE applications. If you were to use this mechanism, then it would not be necessary to restart kglobalacceld.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
bcooksley wrote:I see. Upon checking the code used by the control module, it appears that it interfaces not with the configuration file, but with kglobalaccel itself, over D-Bus (as all other KDE applications do, when setting global shortcuts).

I suggest either ensuring that kglobalacceld is restarted after completing your modifications, or porting your script to use doRegister and setShortcut, which are parts of the kglobalaccel D-Bus API.


Can you please point to the control module source which calls doRegister - i want to see how to use the dbus interface.
I downloaded KDE sources and looked into kde-workspace/khotkeys/kcm_hotkeys/kcm_hotkeys.cpp but there is communicates only with org.kde.kded/modules/khotkeys

UPDATE:

Ah, i think i found it: kde-workspace/kcontrol/keys/kglobalshortcutseditor.cpp

Last edited by blindvic on Sat Sep 21, 2013 8:39 am, edited 1 time in total.
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
Also i want to set a global shortcut to launch terminal or other applications, but changing the config files is a too complex task in this case, because there are too many entries to change.

Is there a dbus interface for this too? Or a class in PyKDE4?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
kglobalaccel is only responsible for global shortcuts - so the doRegister / setShortcut combination of D-Bus API should suffice... does this not work in this case?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
I looked for doRegister string in the sources:
Code: Select all
vic@vic-X202E ~/projects/kde/kde-workspace (master *) » grep doRegister -r .
Binary file ./build/lib/kcm_keys.so matches
Binary file ./build/kcontrol/keys/CMakeFiles/kcm_keys.dir/kglobalaccel_interface.cpp.o matches
./build/kcontrol/keys/kglobalaccel_interface.h:    inline QDBusPendingReply<> doRegister(const QStringList &actionId)
./build/kcontrol/keys/kglobalaccel_interface.h:        return asyncCallWithArgumentList(QLatin1String("doRegister"), argumentList);
./build/kcontrol/keys/kglobalaccel_interface.moc:    "doRegister(QStringList)\0"
./build/kcontrol/keys/kglobalaccel_interface.moc:        case 7: { QDBusPendingReply<> _r = _t->doRegister((*reinterpret_cast< const QStringList(*)>(_a[1])));
vic@vic-X202E ~/projects/kde/kde-workspace (master *) »

but cannot figure out how to use doRegister. Looked at the dbus interface - it expects actionId, which i don't know what is.

Also, in my task i want to reassign global shortcut Win+L to lock screen, and when i add this shortcut via system settings, it says that this shortcut is already assigned to a Kwin action and allows me to use this shortcut anyway. When i change the shortcut directly in config files, i unset the shortcut manually in Kwin section. But is this possible via doRegister?

Thanks!
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS


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


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], Yahoo [Bot]