mirror of
https://github.com/tuxedocomputers/tuxedo-touchpad-switch.git
synced 2025-01-18 11:41:10 +01:00
autodetect correct kded touchpad module
plasma 5.24 renamed the "touchpad" kded module to "kded_touchpad". fix this by listing all loaded modules in kded and look for the correct module name to use. Otherwise it would try to use the wrong one, fail to initialize, and not re-enable the touchpad after resuming after suspend leaving the user with an unusable touchpad and no easy way to enable it. This now also gives an error message and exits, if no touchpad module is loaded. Fixes: #9
This commit is contained in:
parent
88c8e45610
commit
f510c10a03
1 changed files with 45 additions and 2 deletions
|
@ -160,12 +160,55 @@ static int kded5_modules_touchpad_init(GDBusProxy *proxy) {
|
|||
|
||||
int setup_kde(int lockfile_arg) {
|
||||
lockfile = lockfile_arg;
|
||||
|
||||
const char *object_path = NULL;
|
||||
|
||||
GDBusProxy *kded5 = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
|
||||
G_DBUS_PROXY_FLAGS_NONE, NULL,
|
||||
"org.kde.kded5",
|
||||
"/kded",
|
||||
"org.kde.kded5",
|
||||
NULL, NULL);
|
||||
if (kded5 == NULL) {
|
||||
cerr << "main(...): g_dbus_proxy_new_for_bus_sync(...) failed." << endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
GVariant *loadedModulesParam = g_dbus_proxy_call_sync(kded5, "loadedModules", NULL, G_DBUS_CALL_FLAGS_NONE, G_MAXINT, NULL, NULL);
|
||||
if (loadedModulesParam != NULL && g_variant_is_of_type(loadedModulesParam, (const GVariantType *)"(as)") && g_variant_n_children(loadedModulesParam) ) {
|
||||
GVariant *loadedModules = g_variant_get_child_value(loadedModulesParam, 0);
|
||||
GVariantIter *iter;
|
||||
gchar *str;
|
||||
|
||||
g_variant_get(loadedModules, "as", &iter);
|
||||
while (g_variant_iter_loop(iter, "s", &str)) {
|
||||
if (strcmp(str, "kded_touchpad") == 0) {
|
||||
object_path = "/modules/kded_touchpad";
|
||||
break; // break is fine here, we dont need to free unpacked strings
|
||||
}
|
||||
if (strcmp(str, "touchpad") == 0) {
|
||||
object_path = "/modules/touchpad";
|
||||
break; // break is fine here, we dont need to free unpacked strings
|
||||
}
|
||||
}
|
||||
|
||||
g_variant_iter_free(iter);
|
||||
g_variant_unref(loadedModules);
|
||||
g_variant_unref(loadedModulesParam);
|
||||
} else {
|
||||
g_object_unref(kded5); // not needed anymore
|
||||
cerr << "main(...): g_dbus_proxy_call_sync(...) failed." << endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
g_object_unref(kded5); // not needed anymore
|
||||
if (object_path == NULL) {
|
||||
cerr << "main(...): Could not find touchpad module in kded. Is it disabled?" << endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// sync on config and xsession change
|
||||
GDBusProxy *kded5_modules_touchpad = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION,
|
||||
G_DBUS_PROXY_FLAGS_NONE, NULL,
|
||||
"org.kde.kded5",
|
||||
"/modules/touchpad",
|
||||
object_path,
|
||||
"org.kde.touchpad",
|
||||
NULL, NULL);
|
||||
if (kded5_modules_touchpad == NULL) {
|
||||
|
|
Loading…
Reference in a new issue