Uhh..ansohus
[monky] / src / structs.h
1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2  *
3  * Conky, a system monitor, based on torsmo
4  *
5  * Any original torsmo code is licensed under the BSD license
6  *
7  * All code written since the fork of torsmo is licensed under the GPL
8  *
9  * Please see COPYING for details
10  *
11  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
12  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
13  *      (see AUTHORS)
14  * All rights reserved.
15  *
16  * This program is free software: you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation, either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  * You should have received a copy of the GNU General Public License
26  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
27  *
28  * vim: ts=4 sw=4 noet ai cindent syntax=c
29  *
30  */
31
32 #ifndef _CONKY_STRUCTS_H_
33 #define _CONKY_STRUCTS_H_
34
35 #include "config.h"     /* defines */
36
37 #include <sys/utsname.h> /* struct uname_s */
38 #include <stdio.h> /* FILE */
39
40 #ifdef X11
41 #include "x11.h"
42 #endif /* X11 */
43
44 #ifdef APCUPSD
45 #include "apcupsd.h"
46 #endif
47
48 #define MAX_TEMPLATES 10
49
50 struct entropy_s {
51         unsigned int entropy_avail;
52         unsigned int poolsize;
53 };
54
55 struct usr_info {
56         char *names;
57         char *times;
58         char *terms;
59         int number;
60 };
61
62 struct gateway_info {
63         char *iface;
64         char *ip;
65         int count;
66 };
67
68 #ifdef X11
69 struct monitor_info {
70         int number;
71         int current;
72 };
73
74 struct desktop_info {
75         int current;
76         int number;
77         unsigned int nitems;
78         char *all_names;
79         char *name;
80 };
81
82 struct x11_info {
83         struct monitor_info monitor;
84         struct desktop_info desktop;
85 };
86
87 #endif /* X11 */
88
89 struct dns_data {
90         int nscount;
91         char **ns_list;
92 };
93
94 struct conftree {
95         char* string;
96         struct conftree* horz_next;
97         struct conftree* vert_next;
98         struct conftree* back;
99 };
100
101 struct information {
102         unsigned int mask;
103
104         struct utsname uname_s;
105
106         char freq[10];
107
108         double uptime;
109
110         /* memory information in kilobytes */
111         unsigned long long mem, memeasyfree, memfree, memmax, swap, swapfree, swapmax;
112         unsigned long long bufmem, buffers, cached;
113
114         unsigned short procs;
115         unsigned short run_procs;
116
117         float *cpu_usage;
118         /* struct cpu_stat cpu_summed; what the hell is this? */
119         unsigned int cpu_count;
120         int cpu_avg_samples;
121
122         int net_avg_samples;
123
124         int diskio_avg_samples;
125
126         float loadavg[3];
127
128         struct mail_s *mail;
129         int mail_running;
130 #ifdef XMMS2
131         struct xmms2_s xmms2;
132 #endif
133 #ifdef AUDACIOUS
134         AUDACIOUS_S audacious;
135 #endif
136 #ifdef BMPX
137         struct bmpx_s bmpx;
138 #endif
139         struct usr_info users;
140         struct gateway_info gw_info;
141         struct dns_data nameserver_info;
142         struct process *cpu[10];
143         struct process *memu[10];
144         struct process *time[10];
145 #ifdef IOSTATS
146         struct process *io[10];
147 #endif
148         struct process *first_process;
149         unsigned long looped;
150         struct entropy_s entropy;
151         double music_player_interval;
152
153 #ifdef X11
154         struct x11_info x11;
155 #endif
156
157 #ifdef APCUPSD
158         APCUPSD_S apcupsd;
159 #endif
160
161         short kflags;   /* kernel settings, see enum KFLAG */
162 };
163
164 enum x_initialiser_state {
165         NO = 0,
166         YES = 1,
167         NEVER = 2
168 };
169
170 #ifdef X11
171 /* for fonts, used in fonts.c, core.c, etc */
172 struct font_list {
173
174         char name[DEFAULT_TEXT_BUFFER_SIZE];
175         int num;
176         XFontStruct *font;
177
178 #ifdef XFT
179         XftFont *xftfont;
180         int font_alpha;
181 #endif
182 };
183 #endif /* X11 */
184
185 typedef struct _conky_context_s {
186         /* variables holding various config settings */
187         int short_units;
188         int format_human_readable;
189         int cpu_separate;
190         enum {
191                 NO_SPACER = 0,
192                 LEFT_SPACER,
193                 RIGHT_SPACER
194         } use_spacer;
195         int top_cpu, top_mem, top_time;
196 #ifdef IOSTATS
197         int top_io;
198 #endif /* IOSTATS */
199         unsigned int top_name_width;
200         int output_methods;
201         int extra_newline;
202         enum x_initialiser_state x_initialised;
203         /* Update interval */
204         double update_interval;
205         double update_interval_old;
206         double update_interval_bat;
207
208         double current_update_time, next_update_time, last_update_time;
209
210         /* struct that has all info to be shared between
211          * instances of the same text object */
212         struct information info;
213
214         /* path to config file */
215         char *current_config;
216
217         /* set to 1 if you want all text to be in uppercase */
218         unsigned int stuff_in_uppercase;
219
220         /* Run how many times? */
221         unsigned long total_run_times;
222
223         /* fork? */
224         int fork_to_background;
225
226         int cpu_avg_samples, net_avg_samples, diskio_avg_samples;
227
228         /* filenames for output */
229         char *overwrite_file; FILE *overwrite_fpointer;
230         char *append_file; FILE *append_fpointer;
231
232 #ifdef X11
233         /* display to connect to */
234         char *disp;
235
236         int show_graph_scale;
237         int show_graph_range;
238
239         /* Position on the screen */
240         int text_alignment;
241         int gap_x, gap_y;
242
243         /* border */
244         int draw_borders;
245         int draw_graph_borders;
246         int stippled_borders;
247
248         int draw_shades, draw_outline;
249
250         long default_fg_color, default_bg_color, default_out_color;
251
252         /* create own window or draw stuff to root? */
253         int set_transparent;
254
255 #ifdef OWN_WINDOW
256         int own_window;
257         int background_colour;
258
259         /* fixed size/pos is set if wm/user changes them */
260         int fixed_size, fixed_pos;
261 #endif
262
263         int minimum_width, minimum_height;
264         int maximum_width;
265
266         int selected_font;
267         int last_font_height;
268
269         /* text size */
270         int text_start_x, text_start_y; /* text start position in window */
271         int text_width, text_height;
272
273         conky_window window;
274
275 #endif /* X11 */
276
277 #ifdef __OpenBSD__
278         int sensor_device;
279 #endif
280
281         long color0, color1, color2, color3, color4, color5, color6, color7, color8,
282                  color9;
283
284         char *template[MAX_TEMPLATES];
285
286         /* maximum size of config TEXT buffer, i.e. below TEXT line. */
287         unsigned int max_user_text;
288
289         /* maximum size of individual text buffers, ie $exec buffer size */
290         unsigned int text_buffer_size;
291
292         /* UTF-8 */
293         int utf8_mode;
294
295         /* no buffers in used memory? */
296         int no_buffers;
297
298         /* pad percentages to decimals? */
299         int pad_percents0;
300
301         char *global_text;
302
303         long global_text_lines;
304
305         int total_updates;
306         int updatereset;
307
308         int need_to_update;
309
310         /* formatted text to render on screen, generated in generate_text(), drawn
311          * in draw_stuff() */
312         char *text_buffer;
313
314         char **xargv;
315         int xargc;
316
317         /* used in colours.c */
318         short colour_depth;
319         long redmask, greenmask, bluemask;
320
321
322         struct font_list *fonts;
323         int font_count;
324
325         /* used in common.c */
326         double last_meminfo_update;
327         double last_fs_update;
328
329         unsigned long long need_mask;
330
331         /* two strings for internal use */
332         char *tmpstring1, *tmpstring2;
333 } conky_context;
334
335 #endif /* _CONKY_STRUCTS_H_ */