Added support for APC UPS daemon monitoring.
[monky] / src / text_object.h
1 /* Conky, a system monitor, based on torsmo
2  *
3  * Any original torsmo code is licensed under the BSD license
4  *
5  * All code written since the fork of torsmo is licensed under the GPL
6  *
7  * Please see COPYING for details
8  *
9  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
10  * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
11  *      (see AUTHORS)
12  * All rights reserved.
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  * You should have received a copy of the GNU General Public License
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25  *
26  */
27 #ifndef _TEXT_OBJECT_H
28 #define _TEXT_OBJECT_H
29
30 #include "config.h"             /* for the defines */
31 #include "timed_thread.h"       /* timed_thread */
32
33 #ifdef TCP_PORT_MONITOR
34 #include "tcp-portmon.h"        /* tcp_port_monitor_data */
35 #endif
36
37 #include "mail.h"               /* local_mail_s */
38 #include "fs.h"                 /* struct fs_stat */
39
40 #ifdef NVIDIA
41 #include "nvidia.h"             /* nvidia_s */
42 #endif
43
44 enum text_object_type {
45         OBJ_addr,
46 #if defined(__linux__)
47         OBJ_addrs,
48 #endif /* __linux__ */
49 #ifndef __OpenBSD__
50         OBJ_acpiacadapter,
51         OBJ_adt746xcpu,
52         OBJ_adt746xfan,
53         OBJ_acpifan,
54         OBJ_acpitemp,
55         OBJ_battery,
56         OBJ_battery_time,
57         OBJ_battery_percent,
58         OBJ_battery_bar,
59         OBJ_battery_short,
60 #endif /* !__OpenBSD__ */
61         OBJ_buffers,
62         OBJ_cached,
63         OBJ_color,
64         OBJ_color0,
65         OBJ_color1,
66         OBJ_color2,
67         OBJ_color3,
68         OBJ_color4,
69         OBJ_color5,
70         OBJ_color6,
71         OBJ_color7,
72         OBJ_color8,
73         OBJ_color9,
74         OBJ_conky_version,
75         OBJ_conky_build_date,
76         OBJ_conky_build_arch,
77         OBJ_font,
78         OBJ_cpu,
79         OBJ_cpugauge,
80         OBJ_cpubar,
81         OBJ_cpugraph,
82         OBJ_loadgraph,
83         OBJ_diskio,
84         OBJ_diskio_read,
85         OBJ_diskio_write,
86         OBJ_diskiograph,
87         OBJ_diskiograph_read,
88         OBJ_diskiograph_write,
89         OBJ_downspeed,
90         OBJ_downspeedf,
91         OBJ_downspeedgraph,
92         OBJ_else,
93         OBJ_endif,
94         OBJ_eval,
95         OBJ_image,
96         OBJ_exec,
97         OBJ_execi,
98         OBJ_texeci,
99         OBJ_execgauge,
100         OBJ_execbar,
101         OBJ_execgraph,
102         OBJ_execibar,
103         OBJ_execigraph,
104         OBJ_execigauge,
105         OBJ_execp,
106         OBJ_execpi,
107         OBJ_freq,
108         OBJ_freq_g,
109         OBJ_fs_bar,
110         OBJ_fs_bar_free,
111         OBJ_fs_free,
112         OBJ_fs_free_perc,
113         OBJ_fs_size,
114         OBJ_fs_type,
115         OBJ_fs_used,
116         OBJ_fs_used_perc,
117         OBJ_goto,
118         OBJ_tab,
119         OBJ_hr,
120         OBJ_offset,
121         OBJ_voffset,
122         OBJ_alignr,
123         OBJ_alignc,
124         OBJ_i2c,
125         OBJ_platform,
126         OBJ_hwmon,
127 #if defined(__linux__)
128         OBJ_disk_protect,
129         OBJ_i8k_version,
130         OBJ_i8k_bios,
131         OBJ_i8k_serial,
132         OBJ_i8k_cpu_temp,
133         OBJ_i8k_left_fan_status,
134         OBJ_i8k_right_fan_status,
135         OBJ_i8k_left_fan_rpm,
136         OBJ_i8k_right_fan_rpm,
137         OBJ_i8k_ac_status,
138         OBJ_i8k_buttons_status,
139 #if defined(IBM)
140         OBJ_ibm_fan,
141         OBJ_ibm_temps,
142         OBJ_ibm_volume,
143         OBJ_ibm_brightness,
144         OBJ_smapi,
145         OBJ_smapi_bat_bar,
146         OBJ_smapi_bat_perc,
147         OBJ_smapi_bat_temp,
148         OBJ_smapi_bat_power,
149         OBJ_if_smapi_bat_installed,
150 #endif /* IBM */
151         /* information from sony_laptop kernel module
152          * /sys/devices/platform/sony-laptop */
153         OBJ_sony_fanspeed,
154         OBJ_if_gw,
155         OBJ_ioscheduler,
156         OBJ_gw_iface,
157         OBJ_gw_ip,
158         OBJ_laptop_mode,
159         OBJ_pb_battery,
160         OBJ_voltage_mv,
161         OBJ_voltage_v,
162         OBJ_wireless_essid,
163         OBJ_wireless_mode,
164         OBJ_wireless_bitrate,
165         OBJ_wireless_ap,
166         OBJ_wireless_link_qual,
167         OBJ_wireless_link_qual_max,
168         OBJ_wireless_link_qual_perc,
169         OBJ_wireless_link_bar,
170 #endif /* __linux__ */
171 #if defined(__FreeBSD__) || defined(__linux__)
172         OBJ_if_up,
173 #endif
174         OBJ_if_empty,
175         OBJ_if_match,
176         OBJ_if_existing,
177         OBJ_if_mounted,
178         OBJ_if_running,
179         OBJ_if_updatenr,
180         OBJ_top,
181         OBJ_top_mem,
182         OBJ_top_time,
183         OBJ_tail,
184         OBJ_head,
185         OBJ_lines,
186         OBJ_words,
187         OBJ_kernel,
188         OBJ_loadavg,
189         OBJ_machine,
190         OBJ_mails,
191         OBJ_new_mails,
192         OBJ_seen_mails,
193         OBJ_unseen_mails,
194         OBJ_flagged_mails,
195         OBJ_unflagged_mails,
196         OBJ_forwarded_mails,
197         OBJ_unforwarded_mails,
198         OBJ_replied_mails,
199         OBJ_unreplied_mails,
200         OBJ_draft_mails,
201         OBJ_trashed_mails,
202         OBJ_mboxscan,
203         OBJ_mem,
204         OBJ_memeasyfree,
205         OBJ_memfree,
206         OBJ_memgauge,
207         OBJ_membar,
208         OBJ_memgraph,
209         OBJ_memmax,
210         OBJ_memperc,
211         OBJ_mixer,
212         OBJ_mixerl,
213         OBJ_mixerr,
214         OBJ_mixerbar,
215         OBJ_mixerlbar,
216         OBJ_mixerrbar,
217         OBJ_if_mixer_mute,
218 #ifdef X11
219         OBJ_monitor,
220         OBJ_monitor_number,
221 #endif
222         OBJ_nameserver,
223         OBJ_nodename,
224         OBJ_nvidia,
225         OBJ_pre_exec,
226         OBJ_processes,
227         OBJ_running_processes,
228         OBJ_shadecolor,
229         OBJ_outlinecolor,
230         OBJ_stippled_hr,
231         OBJ_swap,
232         OBJ_swapbar,
233         OBJ_swapmax,
234         OBJ_swapperc,
235         OBJ_sysname,
236         OBJ_text,
237         OBJ_time,
238         OBJ_utime,
239         OBJ_tztime,
240         OBJ_totaldown,
241         OBJ_totalup,
242         OBJ_updates,
243         OBJ_upspeed,
244         OBJ_upspeedf,
245         OBJ_upspeedgraph,
246         OBJ_uptime,
247         OBJ_uptime_short,
248         OBJ_user_names,
249         OBJ_user_terms,
250         OBJ_user_times,
251         OBJ_user_number,
252         OBJ_imap_messages,
253         OBJ_imap_unseen,
254         OBJ_pop3_unseen,
255         OBJ_pop3_used,
256 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
257                 || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
258         OBJ_apm_adapter,
259         OBJ_apm_battery_time,
260         OBJ_apm_battery_life,
261 #endif /* __FreeBSD__ __OpenBSD__ */
262 #ifdef __OpenBSD__
263         OBJ_obsd_sensors_temp,
264         OBJ_obsd_sensors_fan,
265         OBJ_obsd_sensors_volt,
266         OBJ_obsd_vendor,
267         OBJ_obsd_product,
268 #endif /* __OpenBSD__ */
269 #ifdef MPD
270         OBJ_mpd_title,
271         OBJ_mpd_artist,
272         OBJ_mpd_album,
273         OBJ_mpd_random,
274         OBJ_mpd_repeat,
275         OBJ_mpd_vol,
276         OBJ_mpd_bitrate,
277         OBJ_mpd_status,
278         OBJ_mpd_bar,
279         OBJ_mpd_elapsed,
280         OBJ_mpd_length,
281         OBJ_mpd_track,
282         OBJ_mpd_name,
283         OBJ_mpd_file,
284         OBJ_mpd_percent,
285         OBJ_mpd_smart,
286         OBJ_if_mpd_playing,
287 #endif
288 #ifdef MOC
289         OBJ_moc_state,
290         OBJ_moc_file,
291         OBJ_moc_title,
292         OBJ_moc_artist,
293         OBJ_moc_song,
294         OBJ_moc_album,
295         OBJ_moc_totaltime,
296         OBJ_moc_timeleft,
297         OBJ_moc_curtime,
298         OBJ_moc_bitrate,
299         OBJ_moc_rate,
300 #endif
301 #ifdef XMMS2
302         OBJ_xmms2_artist,
303         OBJ_xmms2_album,
304         OBJ_xmms2_title,
305         OBJ_xmms2_genre,
306         OBJ_xmms2_comment,
307         OBJ_xmms2_url,
308         OBJ_xmms2_date,
309         OBJ_xmms2_tracknr,
310         OBJ_xmms2_bitrate,
311         OBJ_xmms2_id,
312         OBJ_xmms2_duration,
313         OBJ_xmms2_elapsed,
314         OBJ_xmms2_size,
315         OBJ_xmms2_percent,
316         OBJ_xmms2_status,
317         OBJ_xmms2_bar,
318         OBJ_xmms2_smart,
319         OBJ_xmms2_playlist,
320         OBJ_xmms2_timesplayed,
321         OBJ_if_xmms2_connected,
322 #endif
323 #ifdef AUDACIOUS
324         OBJ_audacious_status,
325         OBJ_audacious_title,
326         OBJ_audacious_length,
327         OBJ_audacious_length_seconds,
328         OBJ_audacious_position,
329         OBJ_audacious_position_seconds,
330         OBJ_audacious_bitrate,
331         OBJ_audacious_frequency,
332         OBJ_audacious_channels,
333         OBJ_audacious_filename,
334         OBJ_audacious_playlist_length,
335         OBJ_audacious_playlist_position,
336         OBJ_audacious_main_volume,
337         OBJ_audacious_bar,
338 #endif
339 #ifdef BMPX
340         OBJ_bmpx_title,
341         OBJ_bmpx_artist,
342         OBJ_bmpx_album,
343         OBJ_bmpx_track,
344         OBJ_bmpx_uri,
345         OBJ_bmpx_bitrate,
346 #endif
347 #ifdef EVE
348         OBJ_eve,
349 #endif
350 #ifdef RSS
351         OBJ_rss,
352 #endif
353 #ifdef TCP_PORT_MONITOR
354         OBJ_tcp_portmon,
355 #endif
356 #ifdef HAVE_ICONV
357         OBJ_iconv_start,
358         OBJ_iconv_stop,
359 #endif
360 #ifdef HDDTEMP
361         OBJ_hddtemp,
362 #endif
363         OBJ_scroll,
364         OBJ_combine,
365         OBJ_entropy_avail,
366         OBJ_entropy_poolsize,
367         OBJ_entropy_bar,
368 #ifdef APCUPSD
369         OBJ_apcupsd,
370         OBJ_apcupsd_name,
371         OBJ_apcupsd_model,
372         OBJ_apcupsd_upsmode,
373         OBJ_apcupsd_cable,
374         OBJ_apcupsd_status,
375         OBJ_apcupsd_linev,
376         OBJ_apcupsd_load,
377         OBJ_apcupsd_loadbar,
378         OBJ_apcupsd_loadgraph,
379         OBJ_apcupsd_charge,
380         OBJ_apcupsd_timeleft,
381         OBJ_apcupsd_temp,
382         OBJ_apcupsd_lastxfer,
383 #endif
384 };
385
386 struct text_object {
387         struct text_object *next, *prev;        /* doubly linked list of text objects */
388         struct text_object *sub;                /* for objects parsing text into objects */
389         union {
390                 char *s;                /* some string */
391                 int i;                  /* some integer */
392                 long l;                 /* some other integer */
393                 unsigned int sensor;
394                 struct net_stat *net;
395                 struct fs_stat *fs;
396                 struct diskio_stat *diskio;
397                 unsigned char loadavg[3];
398                 unsigned int cpu_index;
399                 struct mail_s *mail;
400
401                 struct {
402                         char *args;
403                         char *output;
404                 } mboxscan;
405
406                 struct {
407                         char *tz;       /* timezone variable */
408                         char *fmt;      /* time display formatting */
409                 } tztime;
410
411                 struct {
412                         struct fs_stat *fs;
413                         int w, h;
414                 } fsbar;                /* 3 */
415
416                 struct {
417                         int l;
418                         int w, h;
419                 } mixerbar;             /* 3 */
420
421                 struct {
422                         int fd;
423                         int arg;
424                         char devtype[256];
425                         char type[64];
426                 } sysfs;                /* 2 */
427
428                 struct {
429                         struct text_object *next;
430                         char *s;
431                         int i;
432                         char *str;
433                 } ifblock;
434
435                 struct {
436                         int num;
437                         int type;
438                 } top;
439
440                 struct {
441                         int wantedlines;
442                         int readlines;
443                         char *logfile;
444                         double last_update;
445                         float interval;
446                         char *buffer;
447                         /* If not -1, a file descriptor to read from when
448                          * logfile is a FIFO. */
449                         int fd;
450                 } tail;
451
452                 struct {
453                         double last_update;
454                         float interval;
455                         char *cmd;
456                         char *buffer;
457                         double data;
458                 } execi;                /* 5 */
459
460                 struct {
461                         float interval;
462                         char *cmd;
463                         char *buffer;
464                         double data;
465                         timed_thread *p_timed_thread;
466                 } texeci;
467
468                 struct {
469                         int a, b;
470                 } pair;                 /* 2 */
471 #ifdef TCP_PORT_MONITOR
472                 struct tcp_port_monitor_data tcp_port_monitor;
473 #endif
474 #ifdef HDDTEMP
475                 struct {
476                         char *addr;
477                         int port;
478                         char *dev;
479                         double update_time;
480                         char *temp;
481                 } hddtemp;              /* 2 */
482 #endif
483 #ifdef EVE
484                 struct {
485                         char *apikey;
486                         char *charid;
487                         char *userid;
488                 } eve;
489 #endif
490 #ifdef RSS
491                 struct {
492                         char *uri;
493                         char *action;
494                         int act_par;
495                         int delay;
496                         unsigned int nrspaces;
497                 } rss;
498 #endif
499                 struct {
500                         char *text;
501                         unsigned int show;
502                         unsigned int step;
503                         unsigned int start;
504                 } scroll;
505
506                 struct {
507                         char *left;
508                         char *seperation;
509                         char *right;
510                 } combine;
511
512                 struct local_mail_s local_mail;
513 #ifdef NVIDIA
514                 struct nvidia_s nvidia;
515 #endif /* NVIDIA */
516
517         } data;
518         int type;
519         int a, b;
520         long line;
521         unsigned int c, d, e;
522         float f;
523         char showaslog;
524         char global_mode;
525 };
526
527 /* text object list helpers */
528 int append_object(struct text_object *root, struct text_object *obj);
529
530 /* ifblock helpers
531  *
532  * Opaque is a pointer to the address of the ifblock stack's top object.
533  * Calling clients should pass the address of a defined void pointer which
534  * was initialised to NULL (empty stack).
535  * */
536 int obj_be_ifblock_if(void **opaque, struct text_object *);
537 int obj_be_ifblock_else(void **opaque, struct text_object *);
538 int obj_be_ifblock_endif(void **opaque, struct text_object *);
539 int ifblock_stack_empty(void **opaque);
540
541 #endif /* _TEXT_OBJECT_H */