Skip to content

Commit

Permalink
database: support $XDG_CONFIG_HOME/libwacom as additional path
Browse files Browse the repository at this point in the history
This completes the traditional triplet of $XDG_CONFIG_HOME, /etc, and
/usr/share for configuration files.

Having custom .tablet files in $XDG_CONFIG_HOME makes it easier for
immutable systems and also for backups that only back up the user home
directory.
  • Loading branch information
whot committed Oct 23, 2024
1 parent e5264bf commit b29d0e6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion libwacom/libwacom-database.c
Original file line number Diff line number Diff line change
Expand Up @@ -1188,13 +1188,28 @@ libwacom_database_new_for_path (const char *datadir)
LIBWACOM_EXPORT WacomDeviceDatabase *
libwacom_database_new (void)
{
WacomDeviceDatabase *db;
char *xdgdir = NULL;
char *xdg_config_home = g_strdup(g_getenv("XDG_CONFIG_HOME"));

if (!xdg_config_home)
xdg_config_home = g_strdup_printf("%s/.config/", g_get_home_dir());

xdgdir = g_strdup_printf("%s/libwacom", xdg_config_home);

char *datadir[] = {
xdgdir,
ETCDIR,
DATADIR,
NULL,
};

return database_new_for_paths(datadir);
db = database_new_for_paths(datadir);

free(xdgdir);
free(xdg_config_home);

return db;
}

LIBWACOM_EXPORT void
Expand Down

0 comments on commit b29d0e6

Please sign in to comment.