diff options
-rw-r--r-- | lib/colord/cd-edid.c | 24 | ||||
-rw-r--r-- | meson.build | 4 | ||||
-rw-r--r-- | meson_options.txt | 1 |
3 files changed, 29 insertions, 0 deletions
diff --git a/lib/colord/cd-edid.c b/lib/colord/cd-edid.c index 3e75a8f..a5e2328 100644 --- a/lib/colord/cd-edid.c +++ b/lib/colord/cd-edid.c @@ -106,6 +106,7 @@ cd_edid_get_monitor_name (CdEdid *edid) static gchar * cd_edid_convert_pnp_id_to_string (const gchar *pnp_id) { +#ifndef PNP_IDS gchar *vendor = NULL; struct udev_hwdb *hwdb = NULL; struct udev_list_entry *e; @@ -140,6 +141,29 @@ out: if (udev != NULL) udev_unref (udev); return vendor; +#else + g_autofree gchar *data = NULL; + + /* load pnp.ids */ + if (!g_file_get_contents (PNP_IDS, &data, NULL, NULL)) + return NULL; + if (data == NULL) + return NULL; + + /* get the vendor name from the tab delimited data */ + for (gchar *idx = data; idx != NULL; ) { + if (strncmp (idx, pnp_id, 3) == 0) { + gchar *idx2 = g_strstr_len (idx, -1, "\n"); + if (idx2 != NULL) + *idx2 = '\0'; + return g_strdup (idx + 4); + } + idx = g_strstr_len (idx, -1, "\n"); + if (idx != NULL) + idx++; + } + return NULL; +#endif } /** diff --git a/meson.build b/meson.build index ead7a7d..0e90342 100644 --- a/meson.build +++ b/meson.build @@ -182,6 +182,10 @@ if get_option('with-daemon-user') == 'root' message('RUNNING THIS AS root IS NOT A GOOD IDEA SEE --with-daemon-user') endif +if get_option('with-pnp-ids') != '' + conf.set_quoted('PNP_IDS', get_option('with-pnp-ids')) +endif + polkit = dependency('polkit-gobject-1', version : '>= 0.103') if polkit.version().version_compare('>= 0.114') conf.set('POLKIT_HAS_AUTOPTR_MACROS', '1') diff --git a/meson_options.txt b/meson_options.txt index 05aa12a..1731380 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -11,5 +11,6 @@ option('enable-print-profiles', type : 'boolean', value : false, description : ' option('enable-tests', type : 'boolean', value : true, description : 'Build self tests') option('enable-installed-tests', type : 'boolean', value : false, description : 'Install tests') option('with-daemon-user', type : 'string', value : 'root', description : 'User for running the colord daemon') +option('with-pnp-ids', type : 'string', value : '', description : 'Location of pnp.ids if hwdb is not available') option('enable-man', type : 'boolean', value : true, description : 'Generate man pages') option('enable-docs', type : 'boolean', value : true, description : 'Generate documentation') |