diff options
author | Jon Lund Steffensen <jonlst@gmail.com> | 2014-04-13 22:41:26 +0200 |
---|---|---|
committer | Jon Lund Steffensen <jonlst@gmail.com> | 2014-04-13 22:41:26 +0200 |
commit | f436cf69bfd31e2d014fc9ed954349c57a0bf5b3 (patch) | |
tree | 105ff29459dbc94c90d1cae85fa28ee77c5d8834 /src | |
parent | Fix #66: Do not distribute redshift-gtk, only redshift-gtk.in (diff) | |
parent | Try to use DISPLAY=:0 if not in X (diff) | |
download | redshift-ng-f436cf69bfd31e2d014fc9ed954349c57a0bf5b3.tar.gz redshift-ng-f436cf69bfd31e2d014fc9ed954349c57a0bf5b3.tar.bz2 redshift-ng-f436cf69bfd31e2d014fc9ed954349c57a0bf5b3.tar.xz |
Fix #64: Fix Geoclue support when run outside of X
Fix check of error value returned.
Geoclue requires DISPLAY to be set, so try DISPLAY=:0 if not already set.
Diffstat (limited to 'src')
-rw-r--r-- | src/location-geoclue.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/location-geoclue.c b/src/location-geoclue.c index 5be651f..5c027c7 100644 --- a/src/location-geoclue.c +++ b/src/location-geoclue.c @@ -60,6 +60,10 @@ location_geoclue_start(location_geoclue_state_t *state) state->position = geoclue_position_new(state->provider, state->provider_path); } else { + if (getenv("DISPLAY") == NULL || *getenv("DISPLAY") == '\0') { + /* TODO This (hack) should be removed when GeoClue has been patched. */ + putenv("DISPLAY=:0"); + } GError *error = NULL; GeoclueMaster *master = geoclue_master_get_default(); GeoclueMasterClient *client = geoclue_master_create_client(master, @@ -67,9 +71,13 @@ location_geoclue_start(location_geoclue_state_t *state) g_object_unref(master); if (client == NULL) { - g_printerr(_("Unable to obtain master client: %s\n"), - error->message); - g_error_free(error); + if (error != NULL) { + g_printerr(_("Unable to obtain master client: %s\n"), + error->message); + g_error_free(error); + } else { + g_printerr(_("Unable to obtain master client\n")); + } return -1; } @@ -78,9 +86,13 @@ location_geoclue_start(location_geoclue_state_t *state) 0, FALSE, GEOCLUE_RESOURCE_NETWORK, &error)) { - g_printerr(_("Can't set requirements for master: %s\n"), - error->message); - g_error_free(error); + if (error != NULL) { + g_printerr(_("Can't set requirements for master: %s\n"), + error->message); + g_error_free(error); + } else { + g_printerr(_("Can't set requirements for master\n")); + } g_object_unref(client); return -1; |