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: Pablo Correa Gómez <ablocorrea@hotmail.com>
This commit is contained in:
@@ -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
|
1. By exporting an environment variable `FEEDBACK_THEME` with a path to a
|
||||||
valid theme file (not recommended, use for testing only), or
|
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
|
environment variable, appended with `feedbackd/themes/`. This folder isn't
|
||||||
created automatically, so you have to create it yourself. Here's an example:
|
created automatically, so you have to create it yourself. Here's an example:
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -437,9 +437,18 @@ find_themefile (void)
|
|||||||
const gchar *comp;
|
const gchar *comp;
|
||||||
|
|
||||||
g_autoptr (GError) err = NULL;
|
g_autoptr (GError) err = NULL;
|
||||||
|
g_autofree gchar *user_config_path = NULL;
|
||||||
gchar **xdg_data_dirs = (gchar **) g_get_system_data_dirs ();
|
gchar **xdg_data_dirs = (gchar **) g_get_system_data_dirs ();
|
||||||
g_autofree gchar *compatibles = NULL;
|
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
|
// Try to read the device name
|
||||||
if (g_file_test (DEVICE_TREE_PATH, (G_FILE_TEST_EXISTS))) {
|
if (g_file_test (DEVICE_TREE_PATH, (G_FILE_TEST_EXISTS))) {
|
||||||
g_debug ("Found device tree device compatible at %s", DEVICE_TREE_PATH);
|
g_debug ("Found device tree device compatible at %s", DEVICE_TREE_PATH);
|
||||||
@@ -465,7 +474,7 @@ find_themefile (void)
|
|||||||
// Check if file exist
|
// Check if file exist
|
||||||
if (g_file_test (config_path, (G_FILE_TEST_EXISTS))) {
|
if (g_file_test (config_path, (G_FILE_TEST_EXISTS))) {
|
||||||
g_debug ("Found themefile for this device at: %s", config_path);
|
g_debug ("Found themefile for this device at: %s", config_path);
|
||||||
return g_strdup (config_path);
|
return g_steal_pointer (&config_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user