diff options
author | axtlos <rose@pinkro.se> | 2025-06-19 00:47:45 +0200 |
---|---|---|
committer | axtlos <rose@pinkro.se> | 2025-06-19 00:47:45 +0200 |
commit | cd3b65bd1c2d84780f916bb61aea616ff65f6d7d (patch) | |
tree | 71eef403d9de916e68a3b9becc70c433e1f62a16 /src/main.c | |
parent | 7654df2f9cb61572636183887d0832e448957689 (diff) | |
download | autodarkmode-main.tar.gz autodarkmode-main.tar.bz2 |
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -1,6 +1,6 @@ /* main.c * - * Copyright 2024 Unknown + * Copyright 2025 Rose <rose@pinkro.se> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,17 +21,22 @@ #include "configuration.h" #include "sun.h" +#include <stdlib.h> #include <string.h> #include <math.h> #include <signal.h> +#include <unistd.h> #include <glib.h> -#include <stdlib.h> + +#ifdef USE_GCLUE #include <geoclue.h> static GClueAccuracyLevel accuracy_level = GCLUE_ACCURACY_LEVEL_EXACT; GClueSimple *simple = NULL; GClueClient *client = NULL; +#endif + GMainLoop *main_loop; enum LocationType loctype = 0; @@ -42,6 +47,7 @@ bool isdark = false; float lat = 0; float lng = 0; +#ifdef USE_GCLUE static void get_gclue_location (GClueSimple *simple) { @@ -58,6 +64,7 @@ get_gclue_location (GClueSimple *simple) return; } +#endif void on_dark (void) @@ -159,7 +166,6 @@ gint main (gint argc, gchar *argv[]) { - //g_print ("%s\n", argv[1]); g_autoptr(GError) error = NULL; g_autoptr(GOptionContext) context = NULL; @@ -187,12 +193,18 @@ main (gint argc, lat = config_get_latitude (dict); lng = config_get_longitude (dict); } else { +#if defined USE_GCLUE get_gclue_location (gclue_simple_new_sync ("autodarkmode", accuracy_level, NULL, NULL)); g_print ("lat: %f\n", lat); g_print ("lng: %f\n", lng); +#else + fprintf (stderr, "ERROR: autodarkmode was not compiled with gclue support.\n"); + iniparser_freedict (dict); + return 1; +#endif } lat = locLat == 100 ? lat : locLat; @@ -206,5 +218,5 @@ main (gint argc, iniparser_freedict (dict); - return EXIT_SUCCESS; + return EXIT_SUCCESS; } |