Imported Upstream version 1.2.0
[psensor-pkg-debian.git] / src / cfg.h
1 /*
2  * Copyright (C) 2010-2016 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 #ifndef _PSENSOR_CONFIG_H_
20 #define _PSENSOR_CONFIG_H_
21
22 #include <gdk/gdk.h>
23
24 #include <bool.h>
25 #include <color.h>
26
27 enum temperature_unit {
28         CELSIUS,
29         FAHRENHEIT
30 };
31
32 enum sensorlist_position {
33         SENSORLIST_POSITION_RIGHT,
34         SENSORLIST_POSITION_LEFT,
35         SENSORLIST_POSITION_TOP,
36         SENSORLIST_POSITION_BOTTOM
37 };
38
39 struct config {
40         struct color *graph_bgcolor;
41         struct color *graph_fgcolor;
42
43         double graph_bg_alpha;
44
45         bool alpha_channel_enabled;
46
47         bool window_restore_enabled;
48         /* Last saved position of the window. */
49         int window_x;
50         int window_y;
51         /* Last saved size of the window. */
52         int window_w;
53         int window_h;
54         /* Last saved position of the window divider. */
55         int window_divider_pos;
56
57         int graph_update_interval;
58         int graph_monitoring_duration;
59
60         int sensor_values_max_length;
61         int sensor_update_interval;
62
63         int hide_on_startup;
64
65         bool slog_enabled;
66         int slog_interval;
67 };
68
69 /* Loads psensor configuration */
70 struct config *config_load(void);
71
72 void config_save(const struct config *);
73
74 void config_cleanup(void);
75
76 GdkRGBA *config_get_sensor_color(const char *);
77 void config_set_sensor_color(const char *, const GdkRGBA *);
78
79 bool config_get_sensor_alarm_high_threshold(const char *, double *);
80 void config_set_sensor_alarm_high_threshold(const char *, int);
81
82 bool config_get_sensor_alarm_low_threshold(const char *, double *);
83 void config_set_sensor_alarm_low_threshold(const char *, int);
84
85 bool config_get_sensor_alarm_enabled(const char *);
86 void config_set_sensor_alarm_enabled(const char *, bool);
87
88 bool config_is_sensor_graph_enabled(const char *);
89 void config_set_sensor_graph_enabled(const char *, bool);
90
91 char *config_get_sensor_name(const char *);
92 void config_set_sensor_name(const char *, const char *);
93
94 bool config_is_appindicator_enabled(const char *);
95 void config_set_appindicator_enabled(const char *, bool);
96
97 bool config_is_appindicator_label_enabled(const char *);
98 void config_set_appindicator_label_enabled(const char *, bool);
99
100 bool is_slog_enabled(void);
101 void config_set_slog_enabled_changed_cbk(void (*)(void *), void *);
102
103 int config_get_slog_interval(void);
104
105 bool config_is_smooth_curves_enabled(void);
106 void config_set_smooth_curves_enabled(bool);
107
108 int config_get_sensor_position(const char *);
109 void config_set_sensor_position(const char *, int);
110
111 char *config_get_notif_script(void);
112 void config_set_notif_script(const char *);
113
114 bool config_is_sensor_enabled(const char *sid);
115 void config_set_sensor_enabled(const char *sid, bool enabled);
116
117 bool config_is_lmsensor_enabled(void);
118 void config_set_lmsensor_enable(bool);
119
120 bool config_is_gtop2_enabled(void);
121 void config_set_gtop2_enable(bool);
122
123 bool config_is_udisks2_enabled(void);
124 void config_set_udisks2_enable(bool);
125
126 bool config_is_hddtemp_enabled(void);
127 void config_set_hddtemp_enable(bool);
128
129 bool config_is_libatasmart_enabled(void);
130 void config_set_libatasmart_enable(bool);
131
132 bool config_is_nvctrl_enabled(void);
133 void config_set_nvctrl_enable(bool);
134
135 bool config_is_atiadlsdk_enabled(void);
136 void config_set_atiadlsdk_enable(bool);
137
138 enum temperature_unit config_get_temperature_unit(void);
139 void config_set_temperature_unit(enum temperature_unit);
140
141 double config_get_default_high_threshold_temperature(void);
142
143 bool config_is_window_decoration_enabled(void);
144 void config_set_window_decoration_enabled(bool);
145
146 bool config_is_window_keep_below_enabled(void);
147 void config_set_window_keep_below_enabled(bool);
148
149 bool config_is_menu_bar_enabled(void);
150 void config_set_menu_bar_enabled(bool);
151
152 bool config_is_count_visible(void);
153 void config_set_count_visible(bool);
154
155 enum sensorlist_position config_get_sensorlist_position(void);
156 void config_set_sensorlist_position(enum sensorlist_position pos);
157
158 /*
159  * Returns the user directory containing psensor data (configuration
160  * and log).
161  * Corresponds to $HOME/.psensor/
162  * Creates the directory if it does not exist;
163  * Returns NULL if it cannot be determined.
164  */
165 const char *get_psensor_user_dir(void);
166
167 void config_sync(void);
168
169 GSettings *config_get_GSettings(void);
170
171 #endif