Special default & gauge fixes.
[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         OBJ_if_gw,
152         OBJ_ioscheduler,
153         OBJ_gw_iface,
154         OBJ_gw_ip,
155         OBJ_laptop_mode,
156         OBJ_pb_battery,
157         OBJ_voltage_mv,
158         OBJ_voltage_v,
159         OBJ_wireless_essid,
160         OBJ_wireless_mode,
161         OBJ_wireless_bitrate,
162         OBJ_wireless_ap,
163         OBJ_wireless_link_qual,
164         OBJ_wireless_link_qual_max,
165         OBJ_wireless_link_qual_perc,
166         OBJ_wireless_link_bar,
167 #endif /* __linux__ */
168 #if defined(__FreeBSD__) || defined(__linux__)
169         OBJ_if_up,
170 #endif
171         OBJ_if_empty,
172         OBJ_if_match,
173         OBJ_if_existing,
174         OBJ_if_mounted,
175         OBJ_if_running,
176         OBJ_if_updatenr,
177         OBJ_top,
178         OBJ_top_mem,
179         OBJ_top_time,
180         OBJ_tail,
181         OBJ_head,
182         OBJ_lines,
183         OBJ_words,
184         OBJ_kernel,
185         OBJ_loadavg,
186         OBJ_machine,
187         OBJ_mails,
188         OBJ_new_mails,
189         OBJ_seen_mails,
190         OBJ_unseen_mails,
191         OBJ_flagged_mails,
192         OBJ_unflagged_mails,
193         OBJ_forwarded_mails,
194         OBJ_unforwarded_mails,
195         OBJ_replied_mails,
196         OBJ_unreplied_mails,
197         OBJ_draft_mails,
198         OBJ_trashed_mails,
199         OBJ_mboxscan,
200         OBJ_mem,
201         OBJ_memeasyfree,
202         OBJ_memfree,
203         OBJ_memgauge,
204         OBJ_membar,
205         OBJ_memgraph,
206         OBJ_memmax,
207         OBJ_memperc,
208         OBJ_mem_res,
209         OBJ_mem_vsize,
210         OBJ_mixer,
211         OBJ_mixerl,
212         OBJ_mixerr,
213         OBJ_mixerbar,
214         OBJ_mixerlbar,
215         OBJ_mixerrbar,
216 #ifdef X11
217         OBJ_monitor,
218         OBJ_monitor_number,
219 #endif
220         OBJ_nameserver,
221         OBJ_nodename,
222         OBJ_nvidia,
223         OBJ_pre_exec,
224         OBJ_processes,
225         OBJ_running_processes,
226         OBJ_shadecolor,
227         OBJ_outlinecolor,
228         OBJ_stippled_hr,
229         OBJ_swap,
230         OBJ_swapbar,
231         OBJ_swapmax,
232         OBJ_swapperc,
233         OBJ_sysname,
234         OBJ_temp1,      /* i2c is used instead in these */
235         OBJ_temp2,
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,
253         OBJ_imap_messages,
254         OBJ_imap_unseen,
255         OBJ_pop3,
256         OBJ_pop3_unseen,
257         OBJ_pop3_used,
258 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
259                 || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
260         OBJ_apm_adapter,
261         OBJ_apm_battery_time,
262         OBJ_apm_battery_life,
263 #endif /* __FreeBSD__ __OpenBSD__ */
264 #ifdef __OpenBSD__
265         OBJ_obsd_sensors_temp,
266         OBJ_obsd_sensors_fan,
267         OBJ_obsd_sensors_volt,
268         OBJ_obsd_vendor,
269         OBJ_obsd_product,
270 #endif /* __OpenBSD__ */
271 #ifdef MPD
272         OBJ_mpd_title,
273         OBJ_mpd_artist,
274         OBJ_mpd_album,
275         OBJ_mpd_random,
276         OBJ_mpd_repeat,
277         OBJ_mpd_vol,
278         OBJ_mpd_bitrate,
279         OBJ_mpd_status,
280         OBJ_mpd_host,
281         OBJ_mpd_port,
282         OBJ_mpd_password,
283         OBJ_mpd_bar,
284         OBJ_mpd_elapsed,
285         OBJ_mpd_length,
286         OBJ_mpd_track,
287         OBJ_mpd_name,
288         OBJ_mpd_file,
289         OBJ_mpd_percent,
290         OBJ_mpd_smart,
291         OBJ_if_mpd_playing,
292 #endif
293 #ifdef MOC
294         OBJ_moc_state,
295         OBJ_moc_file,
296         OBJ_moc_title,
297         OBJ_moc_artist,
298         OBJ_moc_song,
299         OBJ_moc_album,
300         OBJ_moc_totaltime,
301         OBJ_moc_timeleft,
302         OBJ_moc_curtime,
303         OBJ_moc_bitrate,
304         OBJ_moc_rate,
305 #endif
306         OBJ_music_player_interval,
307 #ifdef XMMS2
308         OBJ_xmms2_artist,
309         OBJ_xmms2_album,
310         OBJ_xmms2_title,
311         OBJ_xmms2_genre,
312         OBJ_xmms2_comment,
313         OBJ_xmms2_url,
314         OBJ_xmms2_date,
315         OBJ_xmms2_tracknr,
316         OBJ_xmms2_bitrate,
317         OBJ_xmms2_id,
318         OBJ_xmms2_duration,
319         OBJ_xmms2_elapsed,
320         OBJ_xmms2_size,
321         OBJ_xmms2_percent,
322         OBJ_xmms2_status,
323         OBJ_xmms2_bar,
324         OBJ_xmms2_smart,
325         OBJ_xmms2_playlist,
326         OBJ_xmms2_timesplayed,
327         OBJ_if_xmms2_connected,
328 #endif
329 #ifdef AUDACIOUS
330         OBJ_audacious_status,
331         OBJ_audacious_title,
332         OBJ_audacious_length,
333         OBJ_audacious_length_seconds,
334         OBJ_audacious_position,
335         OBJ_audacious_position_seconds,
336         OBJ_audacious_bitrate,
337         OBJ_audacious_frequency,
338         OBJ_audacious_channels,
339         OBJ_audacious_filename,
340         OBJ_audacious_playlist_length,
341         OBJ_audacious_playlist_position,
342         OBJ_audacious_main_volume,
343         OBJ_audacious_bar,
344 #endif
345 #ifdef BMPX
346         OBJ_bmpx_title,
347         OBJ_bmpx_artist,
348         OBJ_bmpx_album,
349         OBJ_bmpx_track,
350         OBJ_bmpx_uri,
351         OBJ_bmpx_bitrate,
352 #endif
353 #ifdef EVE
354         OBJ_eve,
355 #endif
356 #ifdef RSS
357         OBJ_rss,
358 #endif
359 #ifdef TCP_PORT_MONITOR
360         OBJ_tcp_portmon,
361 #endif
362 #ifdef HAVE_ICONV
363         OBJ_iconv_start,
364         OBJ_iconv_stop,
365 #endif
366 #ifdef HDDTEMP
367         OBJ_hddtemp,
368 #endif
369         OBJ_scroll,
370         OBJ_entropy_avail,
371         OBJ_entropy_poolsize,
372         OBJ_entropy_bar
373 };
374
375 struct text_object {
376         struct text_object *next, *prev;        /* doubly linked list of text objects */
377         struct text_object *sub;                /* for objects parsing text into objects */
378         union {
379                 char *s;                /* some string */
380                 int i;                  /* some integer */
381                 long l;                 /* some other integer */
382                 unsigned int sensor;
383                 struct net_stat *net;
384                 struct fs_stat *fs;
385                 struct diskio_stat *diskio;
386                 unsigned char loadavg[3];
387                 unsigned int cpu_index;
388                 struct mail_s *mail;
389
390                 struct {
391                         char *args;
392                         char *output;
393                 } mboxscan;
394
395                 struct {
396                         char *tz;       /* timezone variable */
397                         char *fmt;      /* time display formatting */
398                 } tztime;
399
400                 struct {
401                         struct fs_stat *fs;
402                         int w, h;
403                 } fsbar;                /* 3 */
404
405                 struct {
406                         int l;
407                         int w, h;
408                 } mixerbar;             /* 3 */
409
410                 struct {
411                         int fd;
412                         int arg;
413                         char devtype[256];
414                         char type[64];
415                 } sysfs;                /* 2 */
416
417                 struct {
418                         struct text_object *next;
419                         char *s;
420                         int i;
421                         char *str;
422                 } ifblock;
423
424                 struct {
425                         int num;
426                         int type;
427                 } top;
428
429                 struct {
430                         int wantedlines;
431                         int readlines;
432                         char *logfile;
433                         double last_update;
434                         float interval;
435                         char *buffer;
436                         /* If not -1, a file descriptor to read from when
437                          * logfile is a FIFO. */
438                         int fd;
439                 } tail;
440
441                 struct {
442                         double last_update;
443                         float interval;
444                         char *cmd;
445                         char *buffer;
446                         double data;
447                 } execi;                /* 5 */
448
449                 struct {
450                         float interval;
451                         char *cmd;
452                         char *buffer;
453                         double data;
454                         timed_thread *p_timed_thread;
455                 } texeci;
456
457                 struct {
458                         int a, b;
459                 } pair;                 /* 2 */
460 #ifdef TCP_PORT_MONITOR
461                 struct tcp_port_monitor_data tcp_port_monitor;
462 #endif
463 #ifdef HDDTEMP
464                 struct {
465                         char *addr;
466                         int port;
467                         char *dev;
468                         double update_time;
469                         char *temp;
470                 } hddtemp;              /* 2 */
471 #endif
472 #ifdef EVE
473                 struct {
474                         char *apikey;
475                         char *charid;
476                         char *userid;
477                 } eve;
478 #endif
479 #ifdef RSS
480                 struct {
481                         char *uri;
482                         char *action;
483                         int act_par;
484                         int delay;
485                 } rss;
486 #endif
487                 struct {
488                         char *text;
489                         unsigned int show;
490                         unsigned int step;
491                         unsigned int start;
492                 } scroll;
493
494                 struct local_mail_s local_mail;
495 #ifdef NVIDIA
496                 struct nvidia_s nvidia;
497 #endif /* NVIDIA */
498
499         } data;
500         int type;
501         int a, b;
502         long line;
503         unsigned int c, d, e;
504         float f;
505         char showaslog;
506         char global_mode;
507 };
508
509 /* text object list helpers */
510 int append_object(struct text_object *root, struct text_object *obj);
511
512 /* ifblock helpers
513  *
514  * Opaque is a pointer to the address of the ifblock stack's top object.
515  * Calling clients should pass the address of a defined void pointer which
516  * was initialised to NULL (empty stack).
517  * */
518 int obj_be_ifblock_if(void **opaque, struct text_object *);
519 int obj_be_ifblock_else(void **opaque, struct text_object *);
520 int obj_be_ifblock_endif(void **opaque, struct text_object *);
521 int ifblock_stack_empty(void **opaque);
522
523 #endif /* _TEXT_OBJECT_H */