From cd3b65bd1c2d84780f916bb61aea616ff65f6d7d Mon Sep 17 00:00:00 2001 From: axtlos Date: Thu, 19 Jun 2025 00:47:45 +0200 Subject: Make gclue dependency optional with build option --- src/main.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 3d317a8..8dc859f 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ /* main.c * - * Copyright 2024 Unknown + * Copyright 2025 Rose * * 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 #include #include #include +#include #include -#include + +#ifdef USE_GCLUE #include 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; } -- cgit v1.2.3