removed hddtemp from "Recommends" field (psensor is using udisks2 by default now...
[psensor-pkg-debian.git] / src / cfg.c
1 /*
2  * Copyright (C) 2010-2014 jeanfi@gmail.com
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA
18  */
19
20 #include <errno.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include <ctype.h>
25 #include <sys/stat.h>
26 #include <sys/types.h>
27
28 #include <locale.h>
29 #include <libintl.h>
30 #define _(str) gettext(str)
31
32 #include <cfg.h>
33 #include <graph.h>
34 #include <pio.h>
35 #include <plog.h>
36
37 /* Properties of each sensor */
38 static const char *ATT_SENSOR_ALARM_ENABLED = "alarm_enabled";
39 static const char *ATT_SENSOR_ALARM_HIGH_THRESHOLD = "alarm_high_threshold";
40 static const char *ATT_SENSOR_ALARM_LOW_THRESHOLD = "alarm_low_threshold";
41 static const char *ATT_SENSOR_COLOR = "color";
42 static const char *ATT_SENSOR_GRAPH_ENABLED = "graph_enabled";
43 static const char *ATT_SENSOR_NAME = "name";
44 static const char *ATT_SENSOR_APPINDICATOR_MENU_DISABLED
45 = "appindicator_menu_disabled";
46 static const char *ATT_SENSOR_APPINDICATOR_LABEL_ENABLED
47 = "appindicator_label_enabled";
48 static const char *ATT_SENSOR_POSITION = "position";
49 static const char *ATT_SENSOR_HIDE = "hide";
50
51 /* Update interval of the measures of the sensors */
52 static const char *KEY_SENSOR_UPDATE_INTERVAL
53 = "sensor-update-interval";
54
55 /* Graph settings */
56 static const char *KEY_GRAPH_UPDATE_INTERVAL = "graph-update-interval";
57 static const char *KEY_GRAPH_MONITORING_DURATION = "graph-monitoring-duration";
58 static const char *KEY_GRAPH_BACKGROUND_COLOR = "graph-background-color";
59 static const char *DEFAULT_GRAPH_BACKGROUND_COLOR = "#e8f4e8f4a8f5";
60 static const char *KEY_GRAPH_BACKGROUND_ALPHA = "graph-background-alpha";
61 static const char *KEY_GRAPH_FOREGROUND_COLOR
62 = "graph-foreground-color";
63 static const char *KEY_GRAPH_SMOOTH_CURVES_ENABLED
64 = "graph-smooth-curves-enabled";
65
66 static const char *DEFAULT_GRAPH_FOREGROUND_COLOR = "#000000000000";
67
68 static const char *KEY_ALPHA_CHANNEL_ENABLED = "graph-alpha-channel-enabled";
69
70 /* Inteface settings */
71 static const char *KEY_INTERFACE_SENSORLIST_POSITION
72 = "interface-sensorlist-position";
73
74 static const char *KEY_INTERFACE_WINDOW_DECORATION_DISABLED
75 = "interface-window-decoration-disabled";
76
77 static const char *KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED
78 = "interface-window-keep-below-enabled";
79
80 static const char *KEY_INTERFACE_MENU_BAR_DISABLED
81 = "interface-menu-bar-disabled";
82
83 static const char *KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED
84 = "interface-unity-launcher-count-disabled";
85
86 static const char *KEY_INTERFACE_HIDE_ON_STARTUP
87 = "interface-hide-on-startup";
88
89 static const char *KEY_INTERFACE_WINDOW_RESTORE_ENABLED
90 = "interface-window-restore-enabled";
91
92 static const char *KEY_INTERFACE_WINDOW_X = "interface-window-x";
93 static const char *KEY_INTERFACE_WINDOW_Y = "interface-window-y";
94 static const char *KEY_INTERFACE_WINDOW_W = "interface-window-w";
95 static const char *KEY_INTERFACE_WINDOW_H = "interface-window-h";
96
97 static const char *KEY_INTERFACE_WINDOW_DIVIDER_POS
98 = "interface-window-divider-pos";
99
100 static const char *KEY_INTERFACE_TEMPERATURE_UNIT
101 = "interface-temperature-unit";
102
103 /* Sensor logging settings */
104 static const char *KEY_SLOG_ENABLED = "slog-enabled";
105 static const char *KEY_SLOG_INTERVAL = "slog-interval";
106
107 /* Path to the script called when a notification is raised */
108 static const char *KEY_NOTIFICATION_SCRIPT = "notif-script";
109
110 /* Provider settings */
111 static const char *KEY_PROVIDER_LMSENSORS_ENABLED
112 = "provider-lmsensors-enabled";
113 static const char *KEY_PROVIDER_ATIADLSDK_ENABLED
114 = "provider-atiadlsdk-enabled";
115 static const char *KEY_PROVIDER_GTOP2_ENABLED = "provider-gtop2-enabled";
116 static const char *KEY_PROVIDER_HDDTEMP_ENABLED = "provider-hddtemp-enabled";
117 static const char *KEY_PROVIDER_LIBATASMART_ENABLED
118 = "provider-libatasmart-enabled";
119 static const char *KEY_PROVIDER_NVCTRL_ENABLED = "provider-nvctrl-enabled";
120 static const char *KEY_PROVIDER_UDISKS2_ENABLED = "provider-udisks2-enabled";
121
122
123 static GSettings *settings;
124
125 static char *user_dir;
126
127 static GKeyFile *key_file;
128
129 static char *sensor_config_path;
130
131 static void (*slog_enabled_cbk)(void *);
132
133 static char *get_string(const char *key)
134 {
135         return g_settings_get_string(settings, key);
136 }
137
138 static void set_string(const char *key, const char *str)
139 {
140         g_settings_set_string(settings, key, str);
141 }
142
143 static void set_bool(const char *k, bool b)
144 {
145         g_settings_set_boolean(settings, k, b);
146 }
147
148 static bool get_bool(const char *k)
149 {
150         return g_settings_get_boolean(settings, k);
151 }
152
153 static void set_int(const char *k, int i)
154 {
155         g_settings_set_int(settings, k, i);
156 }
157
158 static double get_double(const char *k)
159 {
160         return g_settings_get_double(settings, k);
161 }
162
163 static void set_double(const char *k, double d)
164 {
165         g_settings_set_double(settings, k, d);
166 }
167
168 static int get_int(const char *k)
169 {
170         return g_settings_get_int(settings, k);
171 }
172
173 char *config_get_notif_script()
174 {
175         char *str;
176
177         str =  get_string(KEY_NOTIFICATION_SCRIPT);
178         if (str && !strlen(str)) {
179                 free(str);
180                 str = NULL;
181         }
182
183         return str;
184 }
185
186 void config_set_notif_script(const char *str)
187 {
188         if (str && strlen(str) > 0)
189                 set_string(KEY_NOTIFICATION_SCRIPT, str);
190         else
191                 set_string(KEY_NOTIFICATION_SCRIPT, "");
192 }
193
194 static struct color *get_background_color()
195 {
196         char *scolor;
197         struct color *c;
198
199         scolor = get_string(KEY_GRAPH_BACKGROUND_COLOR);
200
201         c = str_to_color(scolor);
202         free(scolor);
203
204         if (!c)
205                 return color_new(1, 1, 1);
206
207         return c;
208 }
209
210 static struct color *get_foreground_color()
211 {
212         char *scolor;
213         struct color *c;
214
215         scolor = get_string(KEY_GRAPH_FOREGROUND_COLOR);
216
217         c = str_to_color(scolor);
218         free(scolor);
219
220         if (!c)
221                 return color_new(0, 0, 0);
222
223         return c;
224 }
225
226 static bool is_alpha_channel_enabled()
227 {
228         return get_bool(KEY_ALPHA_CHANNEL_ENABLED);
229 }
230
231 static void set_alpha_channeld_enabled(bool b)
232 {
233         set_bool(KEY_ALPHA_CHANNEL_ENABLED, b);
234 }
235
236 static enum sensorlist_position get_sensorlist_position()
237 {
238         return get_int(KEY_INTERFACE_SENSORLIST_POSITION);
239 }
240
241 static void set_sensorlist_position(enum sensorlist_position pos)
242 {
243         set_int(KEY_INTERFACE_SENSORLIST_POSITION, pos);
244 }
245
246 static double get_graph_background_alpha()
247 {
248         return get_double(KEY_GRAPH_BACKGROUND_ALPHA);
249 }
250
251 static void set_graph_background_alpha(double alpha)
252 {
253         set_double(KEY_GRAPH_BACKGROUND_ALPHA, alpha);
254 }
255
256 static void set_background_color(const struct color *color)
257 {
258         char *scolor;
259
260         scolor = color_to_str(color);
261         if (!scolor)
262                 scolor = strdup(DEFAULT_GRAPH_BACKGROUND_COLOR);
263
264         set_string(KEY_GRAPH_BACKGROUND_COLOR, scolor);
265
266         free(scolor);
267 }
268
269 static void set_foreground_color(const struct color *color)
270 {
271         char *str;
272
273         str = color_to_str(color);
274         if (!str)
275                 str = strdup(DEFAULT_GRAPH_FOREGROUND_COLOR);
276
277         set_string(KEY_GRAPH_FOREGROUND_COLOR, str);
278
279         free(str);
280 }
281
282 bool is_slog_enabled()
283 {
284         return get_bool(KEY_SLOG_ENABLED);
285 }
286
287 static void set_slog_enabled(bool enabled)
288 {
289         set_bool(KEY_SLOG_ENABLED, enabled);
290 }
291
292 static void slog_enabled_changed_cbk(GSettings *settings,
293                                      gchar *key,
294                                      gpointer data)
295 {
296         if (slog_enabled_cbk)
297                 slog_enabled_cbk(data);
298 }
299
300 void config_set_slog_enabled_changed_cbk(void (*cbk)(void *), void *data)
301 {
302         log_fct_enter();
303
304         slog_enabled_cbk = cbk;
305
306         g_signal_connect_after(settings,
307                                "changed::slog-enabled",
308                                G_CALLBACK(slog_enabled_changed_cbk),
309                                data);
310
311         log_fct_exit();
312 }
313
314 int config_get_slog_interval()
315 {
316         return get_int(KEY_SLOG_INTERVAL);
317 }
318
319 static void set_slog_interval(int interval)
320 {
321         if (interval <= 0)
322                 interval = 300;
323
324         set_int(KEY_SLOG_INTERVAL, interval);
325 }
326
327 static bool is_window_decoration_enabled()
328 {
329         return !get_bool(KEY_INTERFACE_WINDOW_DECORATION_DISABLED);
330 }
331
332 static bool is_window_keep_below_enabled()
333 {
334         return get_bool(KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED);
335 }
336
337 static void set_window_decoration_enabled(bool enabled)
338 {
339         set_bool(KEY_INTERFACE_WINDOW_DECORATION_DISABLED, !enabled);
340 }
341
342 static void set_window_keep_below_enabled(bool enabled)
343 {
344         set_bool(KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED, enabled);
345 }
346
347 bool config_is_smooth_curves_enabled()
348 {
349         return get_bool(KEY_GRAPH_SMOOTH_CURVES_ENABLED);
350 }
351
352 void config_set_smooth_curves_enabled(bool b)
353 {
354         set_bool(KEY_GRAPH_SMOOTH_CURVES_ENABLED, b);
355 }
356
357
358 static void init()
359 {
360         log_fct_enter();
361
362         if (!settings)
363                 settings = g_settings_new("psensor");
364
365         log_fct_exit();
366 }
367
368 void config_cleanup()
369 {
370         config_sync();
371
372         if (settings) {
373                 g_settings_sync();
374                 g_object_unref(settings);
375                 settings = NULL;
376         }
377
378         if (user_dir) {
379                 free(user_dir);
380                 user_dir = NULL;
381         }
382
383         if (key_file) {
384                 g_key_file_free(key_file);
385                 key_file = NULL;
386         }
387
388         if (sensor_config_path) {
389                 free(sensor_config_path);
390                 sensor_config_path = NULL;
391         }
392
393         slog_enabled_cbk = NULL;
394 }
395
396 struct config *config_load()
397 {
398         struct config *c;
399
400         init();
401
402         c = malloc(sizeof(struct config));
403
404         c->graph_bgcolor = get_background_color();
405         c->graph_fgcolor = get_foreground_color();
406         c->graph_bg_alpha = get_graph_background_alpha();
407         c->alpha_channel_enabled = is_alpha_channel_enabled();
408         c->sensorlist_position = get_sensorlist_position();
409         c->window_decoration_enabled = is_window_decoration_enabled();
410         c->window_keep_below_enabled = is_window_keep_below_enabled();
411         c->slog_enabled = is_slog_enabled();
412         c->slog_interval = config_get_slog_interval();
413
414         c->sensor_update_interval
415             = get_int(KEY_SENSOR_UPDATE_INTERVAL);
416         if (c->sensor_update_interval < 1)
417                 c->sensor_update_interval = 1;
418
419         c->graph_update_interval = get_int(KEY_GRAPH_UPDATE_INTERVAL);
420         if (c->graph_update_interval < 1)
421                 c->graph_update_interval = 1;
422
423         c->graph_monitoring_duration = get_int(KEY_GRAPH_MONITORING_DURATION);
424
425         if (c->graph_monitoring_duration < 1)
426                 c->graph_monitoring_duration = 10;
427
428         c->menu_bar_disabled = get_bool(KEY_INTERFACE_MENU_BAR_DISABLED);
429
430         c->unity_launcher_count_disabled
431                 = get_bool(KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED);
432
433         c->hide_on_startup = get_bool(KEY_INTERFACE_HIDE_ON_STARTUP);
434
435         c->window_restore_enabled
436                 = get_bool(KEY_INTERFACE_WINDOW_RESTORE_ENABLED);
437
438         c->window_x = get_int(KEY_INTERFACE_WINDOW_X);
439         c->window_y = get_int(KEY_INTERFACE_WINDOW_Y);
440         c->window_w = get_int(KEY_INTERFACE_WINDOW_W);
441         c->window_h = get_int(KEY_INTERFACE_WINDOW_H);
442
443         c->window_divider_pos = get_int(KEY_INTERFACE_WINDOW_DIVIDER_POS);
444
445         if (!c->window_restore_enabled || !c->window_w || !c->window_h) {
446                 c->window_w = 800;
447                 c->window_h = 200;
448         }
449
450         c->temperature_unit = get_int(KEY_INTERFACE_TEMPERATURE_UNIT);
451
452         c->sensor_values_max_length = compute_values_max_length(c);
453
454         return c;
455 }
456
457 void config_save(const struct config *c)
458 {
459         set_alpha_channeld_enabled(c->alpha_channel_enabled);
460         set_background_color(c->graph_bgcolor);
461         set_foreground_color(c->graph_fgcolor);
462         set_graph_background_alpha(c->graph_bg_alpha);
463         set_sensorlist_position(c->sensorlist_position);
464         set_window_decoration_enabled(c->window_decoration_enabled);
465         set_window_keep_below_enabled(c->window_keep_below_enabled);
466         set_slog_enabled(c->slog_enabled);
467         set_slog_interval(c->slog_interval);
468
469         set_int(KEY_GRAPH_UPDATE_INTERVAL, c->graph_update_interval);
470
471         set_int(KEY_GRAPH_MONITORING_DURATION, c->graph_monitoring_duration);
472
473         set_int(KEY_SENSOR_UPDATE_INTERVAL, c->sensor_update_interval);
474
475         set_bool(KEY_INTERFACE_MENU_BAR_DISABLED, c->menu_bar_disabled);
476
477         set_bool(KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED,
478                  c->unity_launcher_count_disabled);
479
480         set_bool(KEY_INTERFACE_HIDE_ON_STARTUP, c->hide_on_startup);
481
482         set_bool(KEY_INTERFACE_WINDOW_RESTORE_ENABLED,
483                  c->window_restore_enabled);
484
485         set_int(KEY_INTERFACE_WINDOW_X, c->window_x);
486         set_int(KEY_INTERFACE_WINDOW_Y, c->window_y);
487         set_int(KEY_INTERFACE_WINDOW_W, c->window_w);
488         set_int(KEY_INTERFACE_WINDOW_H, c->window_h);
489
490         set_int(KEY_INTERFACE_WINDOW_DIVIDER_POS, c->window_divider_pos);
491
492         set_int(KEY_INTERFACE_TEMPERATURE_UNIT, c->temperature_unit);
493 }
494
495 const char *get_psensor_user_dir()
496 {
497         const char *home;
498
499         log_fct_enter();
500
501         if (!user_dir) {
502                 home = getenv("HOME");
503
504                 if (!home)
505                         return NULL;
506
507                 user_dir = path_append(home, ".psensor");
508
509                 if (mkdir(user_dir, 0700) == -1 && errno != EEXIST) {
510                         log_err(_("Failed to create the directory %s: %s"),
511                                 user_dir,
512                                 strerror(errno));
513
514                         free(user_dir);
515                         user_dir = NULL;
516                 }
517         }
518
519         log_fct_exit();
520
521         return user_dir;
522 }
523
524 static const char *get_sensor_config_path()
525 {
526         const char *dir;
527
528         if (!sensor_config_path) {
529                 dir = get_psensor_user_dir();
530
531                 if (dir)
532                         sensor_config_path = path_append(dir, "psensor.cfg");
533         }
534
535         return sensor_config_path;
536 }
537
538 static GKeyFile *get_sensor_key_file()
539 {
540         int ret;
541         GError *err;
542         const char *path;
543
544         if (!key_file) {
545                 path = get_sensor_config_path();
546
547                 key_file = g_key_file_new();
548
549                 err = NULL;
550                 ret = g_key_file_load_from_file(key_file,
551                                                 path,
552                                                 G_KEY_FILE_KEEP_COMMENTS
553                                                 | G_KEY_FILE_KEEP_TRANSLATIONS,
554                                                 &err);
555
556                 if (!ret)
557                         log_warn(_("Failed to load configuration file %s: %s"),
558                                  path,
559                                  err->message);
560         }
561
562         return key_file;
563 }
564
565 static void save_sensor_key_file()
566 {
567         GKeyFile *kfile;
568         const char *path;
569         char *data;
570
571         log_fct_enter();
572
573         kfile = get_sensor_key_file();
574
575         data = g_key_file_to_data(kfile, NULL, NULL);
576
577         path = get_sensor_config_path();
578
579         if (!g_file_set_contents(path, data, -1, NULL))
580                 log_err(_("Failed to save configuration file %s."), path);
581
582         free(data);
583
584         log_fct_exit();
585 }
586
587 void config_sync()
588 {
589         log_fct_enter();
590         if (settings)
591                 g_settings_sync();
592         save_sensor_key_file();
593         log_fct_exit();
594 }
595
596 static void sensor_set_str(const char *sid, const char *att, const char *str)
597 {
598         GKeyFile *kfile;
599
600         kfile = get_sensor_key_file();
601         g_key_file_set_string(kfile, sid, att, str);
602 }
603
604 static char *sensor_get_str(const char *sid, const char *att)
605 {
606         GKeyFile *kfile;
607
608         kfile = get_sensor_key_file();
609         return g_key_file_get_string(kfile, sid, att, NULL);
610 }
611
612 static bool sensor_get_bool(const char *sid, const char *att)
613 {
614         GKeyFile *kfile;
615
616         kfile = get_sensor_key_file();
617         return g_key_file_get_boolean(kfile, sid, att, NULL);
618 }
619
620 static void sensor_set_bool(const char *sid, const char *att, bool enabled)
621 {
622         GKeyFile *kfile;
623
624         kfile = get_sensor_key_file();
625
626         g_key_file_set_boolean(kfile, sid, att, enabled);
627 }
628
629 static int sensor_get_int(const char *sid, const char *att)
630 {
631         GKeyFile *kfile;
632
633         kfile = get_sensor_key_file();
634         return g_key_file_get_integer(kfile, sid, att, NULL);
635 }
636
637 static void sensor_set_int(const char *sid, const char *att, int i)
638 {
639         GKeyFile *kfile;
640
641         kfile = get_sensor_key_file();
642
643         g_key_file_set_integer(kfile, sid, att, i);
644 }
645
646 char *config_get_sensor_name(const char *sid)
647 {
648         return sensor_get_str(sid, ATT_SENSOR_NAME);
649 }
650
651 void config_set_sensor_name(const char *sid, const char *name)
652 {
653         sensor_set_str(sid, ATT_SENSOR_NAME, name);
654 }
655
656 void config_set_sensor_color(const char *sid, const struct color *color)
657 {
658         char *scolor;
659
660         scolor = color_to_str(color);
661
662         sensor_set_str(sid, ATT_SENSOR_COLOR, scolor);
663
664         free(scolor);
665 }
666
667 struct color *
668 config_get_sensor_color(const char *sid, const struct color *dft)
669 {
670         char *scolor;
671         struct color *color;
672
673         scolor = sensor_get_str(sid, ATT_SENSOR_COLOR);
674
675         if (scolor)
676                 color = str_to_color(scolor);
677         else
678                 color = NULL;
679
680         if (!color) {
681                 color = color_new(dft->red, dft->green, dft->blue);
682                 config_set_sensor_color(sid, color);
683         }
684
685         free(scolor);
686
687         return color;
688 }
689
690 bool config_is_sensor_graph_enabled(const char *sid)
691 {
692         return sensor_get_bool(sid, ATT_SENSOR_GRAPH_ENABLED);
693 }
694
695 void config_set_sensor_graph_enabled(const char *sid, bool enabled)
696 {
697         sensor_set_bool(sid, ATT_SENSOR_GRAPH_ENABLED, enabled);
698 }
699
700 int config_get_sensor_alarm_high_threshold(const char *sid)
701 {
702         return sensor_get_int(sid, ATT_SENSOR_ALARM_HIGH_THRESHOLD);
703 }
704
705 void config_set_sensor_alarm_high_threshold(const char *sid, int threshold)
706 {
707         sensor_set_int(sid, ATT_SENSOR_ALARM_HIGH_THRESHOLD, threshold);
708 }
709
710 int config_get_sensor_alarm_low_threshold(const char *sid)
711 {
712         return sensor_get_int(sid, ATT_SENSOR_ALARM_LOW_THRESHOLD);
713 }
714
715 void config_set_sensor_alarm_low_threshold(const char *sid, int threshold)
716 {
717         sensor_set_int(sid, ATT_SENSOR_ALARM_LOW_THRESHOLD, threshold);
718 }
719
720 bool config_is_appindicator_enabled(const char *sid)
721 {
722         return !sensor_get_bool(sid, ATT_SENSOR_APPINDICATOR_MENU_DISABLED);
723 }
724
725 void config_set_appindicator_enabled(const char *sid, bool enabled)
726 {
727         return sensor_set_bool(sid,
728                                ATT_SENSOR_APPINDICATOR_MENU_DISABLED,
729                                !enabled);
730 }
731
732 int config_get_sensor_position(const char *sid)
733 {
734         return sensor_get_int(sid, ATT_SENSOR_POSITION);
735 }
736
737 void config_set_sensor_position(const char *sid, int pos)
738 {
739         return sensor_set_int(sid, ATT_SENSOR_POSITION, pos);
740 }
741
742 bool config_get_sensor_alarm_enabled(const char *sid)
743 {
744         return sensor_get_bool(sid, ATT_SENSOR_ALARM_ENABLED);
745 }
746
747 void config_set_sensor_alarm_enabled(const char *sid, bool enabled)
748 {
749         sensor_set_bool(sid, ATT_SENSOR_ALARM_ENABLED, enabled);
750 }
751
752 bool config_is_sensor_enabled(const char *sid)
753 {
754         return !sensor_get_bool(sid, ATT_SENSOR_HIDE);
755 }
756
757 void config_set_sensor_enabled(const char *sid, bool enabled)
758 {
759         sensor_set_bool(sid, ATT_SENSOR_HIDE, !enabled);
760 }
761
762 bool config_is_appindicator_label_enabled(const char *sid)
763 {
764         return sensor_get_bool(sid, ATT_SENSOR_APPINDICATOR_LABEL_ENABLED);
765 }
766
767 void config_set_appindicator_label_enabled(const char *sid, bool enabled)
768 {
769         sensor_set_bool(sid, ATT_SENSOR_APPINDICATOR_LABEL_ENABLED, enabled);
770 }
771
772 GSettings *config_get_GSettings()
773 {
774         return settings;
775 }
776
777 bool config_is_lmsensor_enabled()
778 {
779         return get_bool(KEY_PROVIDER_LMSENSORS_ENABLED);
780 }
781
782 bool config_is_gtop2_enabled()
783 {
784         return get_bool(KEY_PROVIDER_GTOP2_ENABLED);
785 }
786
787 bool config_is_udisks2_enabled()
788 {
789         return get_bool(KEY_PROVIDER_UDISKS2_ENABLED);
790 }
791
792 bool config_is_hddtemp_enabled()
793 {
794         return get_bool(KEY_PROVIDER_HDDTEMP_ENABLED);
795 }
796
797 bool config_is_libatasmart_enabled()
798 {
799         return get_bool(KEY_PROVIDER_LIBATASMART_ENABLED);
800 }
801
802 bool config_is_nvctrl_enabled()
803 {
804         return get_bool(KEY_PROVIDER_NVCTRL_ENABLED);
805 }
806
807 bool config_is_atiadlsdk_enabled()
808 {
809         return get_bool(KEY_PROVIDER_ATIADLSDK_ENABLED);
810 }
811
812 void config_set_lmsensor_enable(bool b)
813 {
814         set_bool(KEY_PROVIDER_LMSENSORS_ENABLED, b);
815 }
816
817 void config_set_nvctrl_enable(bool b)
818 {
819         set_bool(KEY_PROVIDER_NVCTRL_ENABLED, b);
820 }
821
822 void config_set_atiadlsdk_enable(bool b)
823 {
824         set_bool(KEY_PROVIDER_ATIADLSDK_ENABLED, b);
825 }
826
827 void config_set_gtop2_enable(bool b)
828 {
829         set_bool(KEY_PROVIDER_GTOP2_ENABLED, b);
830 }
831
832 void config_set_hddtemp_enable(bool b)
833 {
834         set_bool(KEY_PROVIDER_HDDTEMP_ENABLED, b);
835 }
836
837 void config_set_libatasmart_enable(bool b)
838 {
839         set_bool(KEY_PROVIDER_LIBATASMART_ENABLED, b);
840 }
841
842 void config_set_udisks2_enable(bool b)
843 {
844         set_bool(KEY_PROVIDER_UDISKS2_ENABLED, b);
845 }