diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2019-11-15 11:37:06 +0100 |
---|---|---|
committer | Carlos Garnacho <mrgarnacho@gmail.com> | 2020-02-29 22:36:41 +0000 |
commit | 7b00240a88a70bfd28b36cfb74b7d5c0c9223fbe (patch) | |
tree | dd7bf6515ac2c140a637d81c8a241c84b67f4e84 | |
parent | 2600d5bcb7b5b8f1afce5602ab9245afb0e96555 (diff) | |
download | gnome-settings-daemon-7b00240a88a70bfd28b36cfb74b7d5c0c9223fbe.tar.gz |
xsettings: Add support for launching Xwayland session scripts
We now look for scripts to launch at $XDG_CONFIG_DIRS/Xwayland-session.d.
This will let users/x11 services/distributors to hook other miscellaneous
X11 services that should be there before a client is able to launch.
Real life examples are:
- Xresources files should be loaded with xrdb before any client uses them
- Pulseaudio might want to export its configuration to root window
properties before SSH forwarded X11 clients may use them.
- Ibus may want to set up its XIM implementation
-rw-r--r-- | plugins/xsettings/gsd-xsettings-manager.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/plugins/xsettings/gsd-xsettings-manager.c b/plugins/xsettings/gsd-xsettings-manager.c index 75744b20..aff0c60d 100644 --- a/plugins/xsettings/gsd-xsettings-manager.c +++ b/plugins/xsettings/gsd-xsettings-manager.c @@ -1166,6 +1166,101 @@ on_shell_introspect_name_appeared_handler (GDBusConnection *connection, animations_enabled_changed (manager); } +static void +launch_xwayland_services_on_dir (const gchar *path) +{ + GFileEnumerator *enumerator; + GError *error = NULL; + GList *l, *scripts = NULL; + GFile *dir; + + g_debug ("launch_xwayland_services_on_dir: %s", path); + + dir = g_file_new_for_path (path); + enumerator = g_file_enumerate_children (dir, + G_FILE_ATTRIBUTE_STANDARD_NAME "," + G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE "," + G_FILE_ATTRIBUTE_STANDARD_TYPE, + G_FILE_QUERY_INFO_NONE, + NULL, &error); + g_object_unref (dir); + + if (!enumerator) { + if (!g_error_matches (error, + G_IO_ERROR, + G_IO_ERROR_NOT_FOUND)) { + g_warning ("Error opening '%s': %s", + path, error->message); + } + + g_error_free (error); + return; + } + + while (TRUE) { + GFileInfo *info; + GFile *child; + + if (!g_file_enumerator_iterate (enumerator, + &info, &child, + NULL, &error)) { + g_warning ("Error iterating on '%s': %s", + path, error->message); + g_error_free (error); + break; + } + + if (!info) + break; + + if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR || + !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE)) + continue; + + scripts = g_list_prepend (scripts, g_file_get_path (child)); + } + + scripts = g_list_sort (scripts, (GCompareFunc) strcmp); + + for (l = scripts; l; l = l->next) { + gchar *args[2] = { l->data, NULL }; + + g_debug ("launch_xwayland_services_on_dir: Spawning '%s'", args[0]); + if (!g_spawn_sync (NULL, args, NULL, + G_SPAWN_DEFAULT, + NULL, NULL, + NULL, NULL, NULL, + &error)) { + g_warning ("Error when spawning '%s': %s", + args[0], error->message); + g_clear_error (&error); + } + } + + g_object_unref (enumerator); + g_list_free_full (scripts, g_free); +} + +static void +launch_xwayland_services (void) +{ + const gchar * const * config_dirs; + gint i; + + config_dirs = g_get_system_config_dirs (); + + for (i = 0; config_dirs[i] != NULL; i++) { + gchar *config_dir; + + config_dir = g_build_filename (config_dirs[i], + "Xwayland-session.d", + NULL); + + launch_xwayland_services_on_dir (config_dir); + g_free (config_dir); + } +} + gboolean gsd_xsettings_manager_start (GsdXSettingsManager *manager, GError **error) @@ -1297,6 +1392,10 @@ gsd_xsettings_manager_start (GsdXSettingsManager *manager, /* Xft settings */ update_xft_settings (manager); + /* Launch Xwayland services */ + if (gnome_settings_is_wayland ()) + launch_xwayland_services (); + register_manager_dbus (manager); start_fontconfig_monitor (manager); |