Unverified Commit 3802c89e authored by Pablo Correa Gómez's avatar Pablo Correa Gómez
Browse files

feedback-manager: Search for default theme under XDG_CONFIG_HOME first



This would allow users to create their own feedback profiles
without editing system files or using root privileges
Signed-off-by: default avatarPablo Correa Gómez <ablocorrea@hotmail.com>
parent b4546808
Pipeline #68423 passed with stages
in 17 minutes and 12 seconds
......@@ -84,7 +84,10 @@ You can add your own themes in one of two ways:
1. By exporting an environment variable `FEEDBACK_THEME` with a path to a
valid theme file (not recommended, use for testing only), or
2. By adding your theme file to one of the folders in the `XDG_DATA_DIRS`
2. By creating a theme file under `$XDG_CONFIG_HOME/feedbackd/themes/default.json`.
If `XDG_CONFIG_HOME` environment variable is not set or empty, it will
default to `$HOME/.config`, or
3. By adding your theme file to one of the folders in the `XDG_DATA_DIRS`
environment variable, appended with `feedbackd/themes/`. This folder isn't
created automatically, so you have to create it yourself. Here's an example:
```bash
......
......@@ -437,9 +437,18 @@ find_themefile (void)
const gchar *comp;
g_autoptr (GError) err = NULL;
g_autofree gchar *user_config_path = NULL;
gchar **xdg_data_dirs = (gchar **) g_get_system_data_dirs ();
g_autofree gchar *compatibles = NULL;
// First look for a default file under $XDG_DATA_HOME
user_config_path = g_build_filename (g_get_user_config_dir (), "feedbackd",
"themes", "default.json", NULL);
if (g_file_test (user_config_path, (G_FILE_TEST_EXISTS))) {
g_debug ("Found user themefile at: %s", user_config_path);
return g_steal_pointer (&user_config_path);
}
// Try to read the device name
if (g_file_test (DEVICE_TREE_PATH, (G_FILE_TEST_EXISTS))) {
g_debug ("Found device tree device compatible at %s", DEVICE_TREE_PATH);
......@@ -465,7 +474,7 @@ find_themefile (void)
// Check if file exist
if (g_file_test (config_path, (G_FILE_TEST_EXISTS))) {
g_debug ("Found themefile for this device at: %s", config_path);
return g_strdup (config_path);
return g_steal_pointer (&config_path);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment