Added fancy new 'temperature gradients' feature.
[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 #ifdef X11
59         OBJ_battery_bar,
60 #endif
61         OBJ_battery_short,
62 #endif /* !__OpenBSD__ */
63         OBJ_buffers,
64         OBJ_cached,
65         OBJ_color,
66         OBJ_color0,
67         OBJ_color1,
68         OBJ_color2,
69         OBJ_color3,
70         OBJ_color4,
71         OBJ_color5,
72         OBJ_color6,
73         OBJ_color7,
74         OBJ_color8,
75         OBJ_color9,
76         OBJ_conky_version,
77         OBJ_conky_build_date,
78         OBJ_conky_build_arch,
79         OBJ_font,
80         OBJ_cpu,
81 #ifdef X11
82         OBJ_cpugauge,
83         OBJ_cpubar,
84         OBJ_cpugraph,
85         OBJ_loadgraph,
86 #endif
87         OBJ_diskio,
88         OBJ_diskio_read,
89         OBJ_diskio_write,
90 #ifdef X11
91         OBJ_diskiograph,
92         OBJ_diskiograph_read,
93         OBJ_diskiograph_write,
94 #endif
95         OBJ_downspeed,
96         OBJ_downspeedf,
97 #ifdef X11
98         OBJ_downspeedgraph,
99 #endif
100         OBJ_else,
101         OBJ_endif,
102         OBJ_eval,
103         OBJ_image,
104         OBJ_exec,
105         OBJ_execi,
106         OBJ_texeci,
107         OBJ_execbar,
108 #ifdef X11
109         OBJ_execgauge,
110         OBJ_execgraph,
111         OBJ_execibar,
112         OBJ_execigraph,
113         OBJ_execigauge,
114 #endif
115         OBJ_execp,
116         OBJ_execpi,
117         OBJ_freq,
118         OBJ_freq_g,
119 #ifdef X11
120         OBJ_fs_bar,
121         OBJ_fs_bar_free,
122 #endif
123         OBJ_fs_free,
124         OBJ_fs_free_perc,
125         OBJ_fs_size,
126         OBJ_fs_type,
127         OBJ_fs_used,
128         OBJ_fs_used_perc,
129         OBJ_goto,
130         OBJ_tab,
131         OBJ_hr,
132         OBJ_offset,
133         OBJ_voffset,
134         OBJ_alignr,
135         OBJ_alignc,
136         OBJ_i2c,
137         OBJ_platform,
138         OBJ_hwmon,
139 #if defined(__linux__)
140         OBJ_disk_protect,
141         OBJ_i8k_version,
142         OBJ_i8k_bios,
143         OBJ_i8k_serial,
144         OBJ_i8k_cpu_temp,
145         OBJ_i8k_left_fan_status,
146         OBJ_i8k_right_fan_status,
147         OBJ_i8k_left_fan_rpm,
148         OBJ_i8k_right_fan_rpm,
149         OBJ_i8k_ac_status,
150         OBJ_i8k_buttons_status,
151 #if defined(IBM)
152         OBJ_ibm_fan,
153         OBJ_ibm_temps,
154         OBJ_ibm_volume,
155         OBJ_ibm_brightness,
156         OBJ_smapi,
157 #ifdef X11
158         OBJ_smapi_bat_bar,
159 #endif
160         OBJ_smapi_bat_perc,
161         OBJ_smapi_bat_temp,
162         OBJ_smapi_bat_power,
163         OBJ_if_smapi_bat_installed,
164 #endif /* IBM */
165         /* information from sony_laptop kernel module
166          * /sys/devices/platform/sony-laptop */
167         OBJ_sony_fanspeed,
168         OBJ_if_gw,
169         OBJ_ioscheduler,
170         OBJ_gw_iface,
171         OBJ_gw_ip,
172         OBJ_laptop_mode,
173         OBJ_pb_battery,
174         OBJ_voltage_mv,
175         OBJ_voltage_v,
176         OBJ_wireless_essid,
177         OBJ_wireless_mode,
178         OBJ_wireless_bitrate,
179         OBJ_wireless_ap,
180         OBJ_wireless_link_qual,
181         OBJ_wireless_link_qual_max,
182         OBJ_wireless_link_qual_perc,
183 #ifdef X11
184         OBJ_wireless_link_bar,
185 #endif
186 #endif /* __linux__ */
187 #if defined(__FreeBSD__) || defined(__linux__)
188         OBJ_if_up,
189 #endif
190         OBJ_if_empty,
191         OBJ_if_match,
192         OBJ_if_existing,
193         OBJ_if_mounted,
194         OBJ_if_running,
195         OBJ_if_updatenr,
196         OBJ_top,
197         OBJ_top_mem,
198         OBJ_top_time,
199         OBJ_tail,
200         OBJ_head,
201         OBJ_lines,
202         OBJ_words,
203         OBJ_kernel,
204         OBJ_loadavg,
205         OBJ_machine,
206         OBJ_mails,
207         OBJ_new_mails,
208         OBJ_seen_mails,
209         OBJ_unseen_mails,
210         OBJ_flagged_mails,
211         OBJ_unflagged_mails,
212         OBJ_forwarded_mails,
213         OBJ_unforwarded_mails,
214         OBJ_replied_mails,
215         OBJ_unreplied_mails,
216         OBJ_draft_mails,
217         OBJ_trashed_mails,
218         OBJ_mboxscan,
219         OBJ_mem,
220         OBJ_memeasyfree,
221         OBJ_memfree,
222 #ifdef X11
223         OBJ_memgauge,
224         OBJ_membar,
225         OBJ_memgraph,
226 #endif
227         OBJ_memmax,
228         OBJ_memperc,
229         OBJ_mixer,
230         OBJ_mixerl,
231         OBJ_mixerr,
232 #ifdef X11
233         OBJ_mixerbar,
234         OBJ_mixerlbar,
235         OBJ_mixerrbar,
236 #endif
237         OBJ_if_mixer_mute,
238 #ifdef X11
239         OBJ_monitor,
240         OBJ_monitor_number,
241 #endif
242         OBJ_nameserver,
243         OBJ_nodename,
244         OBJ_nvidia,
245         OBJ_pre_exec,
246         OBJ_processes,
247         OBJ_running_processes,
248         OBJ_shadecolor,
249         OBJ_outlinecolor,
250         OBJ_stippled_hr,
251         OBJ_swap,
252 #ifdef X11
253         OBJ_swapbar,
254 #endif
255         OBJ_swapmax,
256         OBJ_swapperc,
257         OBJ_sysname,
258         OBJ_text,
259         OBJ_time,
260         OBJ_utime,
261         OBJ_tztime,
262         OBJ_totaldown,
263         OBJ_totalup,
264         OBJ_updates,
265         OBJ_upspeed,
266         OBJ_upspeedf,
267 #ifdef X11
268         OBJ_upspeedgraph,
269 #endif
270         OBJ_uptime,
271         OBJ_uptime_short,
272         OBJ_user_names,
273         OBJ_user_terms,
274         OBJ_user_times,
275         OBJ_user_number,
276         OBJ_imap_messages,
277         OBJ_imap_unseen,
278         OBJ_pop3_unseen,
279         OBJ_pop3_used,
280 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
281                 || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
282         OBJ_apm_adapter,
283         OBJ_apm_battery_time,
284         OBJ_apm_battery_life,
285 #endif /* __FreeBSD__ __OpenBSD__ */
286 #ifdef __OpenBSD__
287         OBJ_obsd_sensors_temp,
288         OBJ_obsd_sensors_fan,
289         OBJ_obsd_sensors_volt,
290         OBJ_obsd_vendor,
291         OBJ_obsd_product,
292 #endif /* __OpenBSD__ */
293 #ifdef MPD
294         OBJ_mpd_title,
295         OBJ_mpd_artist,
296         OBJ_mpd_album,
297         OBJ_mpd_random,
298         OBJ_mpd_repeat,
299         OBJ_mpd_vol,
300         OBJ_mpd_bitrate,
301         OBJ_mpd_status,
302 #ifdef X11
303         OBJ_mpd_bar,
304 #endif
305         OBJ_mpd_elapsed,
306         OBJ_mpd_length,
307         OBJ_mpd_track,
308         OBJ_mpd_name,
309         OBJ_mpd_file,
310         OBJ_mpd_percent,
311         OBJ_mpd_smart,
312         OBJ_if_mpd_playing,
313 #endif
314 #ifdef MOC
315         OBJ_moc_state,
316         OBJ_moc_file,
317         OBJ_moc_title,
318         OBJ_moc_artist,
319         OBJ_moc_song,
320         OBJ_moc_album,
321         OBJ_moc_totaltime,
322         OBJ_moc_timeleft,
323         OBJ_moc_curtime,
324         OBJ_moc_bitrate,
325         OBJ_moc_rate,
326 #endif
327 #ifdef XMMS2
328         OBJ_xmms2_artist,
329         OBJ_xmms2_album,
330         OBJ_xmms2_title,
331         OBJ_xmms2_genre,
332         OBJ_xmms2_comment,
333         OBJ_xmms2_url,
334         OBJ_xmms2_date,
335         OBJ_xmms2_tracknr,
336         OBJ_xmms2_bitrate,
337         OBJ_xmms2_id,
338         OBJ_xmms2_duration,
339         OBJ_xmms2_elapsed,
340         OBJ_xmms2_size,
341         OBJ_xmms2_percent,
342         OBJ_xmms2_status,
343 #ifdef X11
344         OBJ_xmms2_bar,
345 #endif
346         OBJ_xmms2_smart,
347         OBJ_xmms2_playlist,
348         OBJ_xmms2_timesplayed,
349         OBJ_if_xmms2_connected,
350 #endif
351 #ifdef AUDACIOUS
352         OBJ_audacious_status,
353         OBJ_audacious_title,
354         OBJ_audacious_length,
355         OBJ_audacious_length_seconds,
356         OBJ_audacious_position,
357         OBJ_audacious_position_seconds,
358         OBJ_audacious_bitrate,
359         OBJ_audacious_frequency,
360         OBJ_audacious_channels,
361         OBJ_audacious_filename,
362         OBJ_audacious_playlist_length,
363         OBJ_audacious_playlist_position,
364         OBJ_audacious_main_volume,
365 #ifdef X11
366         OBJ_audacious_bar,
367 #endif
368 #endif
369 #ifdef BMPX
370         OBJ_bmpx_title,
371         OBJ_bmpx_artist,
372         OBJ_bmpx_album,
373         OBJ_bmpx_track,
374         OBJ_bmpx_uri,
375         OBJ_bmpx_bitrate,
376 #endif
377 #ifdef EVE
378         OBJ_eve,
379 #endif
380 #ifdef RSS
381         OBJ_rss,
382 #endif
383 #ifdef HAVE_LUA
384         OBJ_lua,
385         OBJ_lua_parse,
386         OBJ_lua_read_parse,
387 #ifdef X11
388         OBJ_lua_bar,
389         OBJ_lua_graph,
390         OBJ_lua_gauge,
391 #endif /* X11 */
392 #endif /* HAVE_LUA */
393 #ifdef TCP_PORT_MONITOR
394         OBJ_tcp_portmon,
395 #endif
396 #ifdef HAVE_ICONV
397         OBJ_iconv_start,
398         OBJ_iconv_stop,
399 #endif
400 #ifdef HDDTEMP
401         OBJ_hddtemp,
402 #endif
403         OBJ_scroll,
404         OBJ_combine,
405         OBJ_entropy_avail,
406         OBJ_entropy_poolsize,
407 #ifdef X11
408         OBJ_entropy_bar,
409 #endif
410 #ifdef APCUPSD
411         OBJ_apcupsd,
412         OBJ_apcupsd_name,
413         OBJ_apcupsd_model,
414         OBJ_apcupsd_upsmode,
415         OBJ_apcupsd_cable,
416         OBJ_apcupsd_status,
417         OBJ_apcupsd_linev,
418         OBJ_apcupsd_load,
419 #ifdef X11
420         OBJ_apcupsd_loadbar,
421         OBJ_apcupsd_loadgraph,
422         OBJ_apcupsd_loadgauge,
423 #endif
424         OBJ_apcupsd_charge,
425         OBJ_apcupsd_timeleft,
426         OBJ_apcupsd_temp,
427         OBJ_apcupsd_lastxfer,
428 #endif
429 };
430
431 struct text_object {
432         struct text_object *next, *prev;        /* doubly linked list of text objects */
433         struct text_object *sub;                /* for objects parsing text into objects */
434         union {
435                 char *s;                /* some string */
436                 int i;                  /* some integer */
437                 long l;                 /* some other integer */
438                 unsigned int sensor;
439                 struct net_stat *net;
440                 struct fs_stat *fs;
441                 struct diskio_stat *diskio;
442                 unsigned char loadavg[3];
443                 unsigned int cpu_index;
444                 struct mail_s *mail;
445
446                 struct {
447                         char *args;
448                         char *output;
449                 } mboxscan;
450
451                 struct {
452                         char *tz;       /* timezone variable */
453                         char *fmt;      /* time display formatting */
454                 } tztime;
455
456 #ifdef X11
457                 struct {
458                         struct fs_stat *fs;
459                         int w, h;
460                 } fsbar;                /* 3 */
461
462                 struct {
463                         int l;
464                         int w, h;
465                 } mixerbar;             /* 3 */
466 #endif
467
468                 struct {
469                         int fd;
470                         int arg;
471                         char devtype[256];
472                         char type[64];
473                         float factor, offset;
474                 } sysfs;
475
476                 struct {
477                         struct text_object *next;
478                         char *s;
479                         int i;
480                         char *str;
481                 } ifblock;
482
483                 struct {
484                         int num;
485                         int type;
486                         int was_parsed;
487                         char *s;
488                 } top;
489
490                 struct {
491                         int wantedlines;
492                         int readlines;
493                         char *logfile;
494                         double last_update;
495                         float interval;
496                         char *buffer;
497                         /* If not -1, a file descriptor to read from when
498                          * logfile is a FIFO. */
499                         int fd;
500                 } tail;
501
502                 struct {
503                         double last_update;
504                         float interval;
505                         char *cmd;
506                         char *buffer;
507                         double data;
508                 } execi;                /* 5 */
509
510                 struct {
511                         float interval;
512                         char *cmd;
513                         char *buffer;
514                         double data;
515                         timed_thread *p_timed_thread;
516                 } texeci;
517
518                 struct {
519                         int a, b;
520                 } pair;                 /* 2 */
521 #ifdef TCP_PORT_MONITOR
522                 struct tcp_port_monitor_data tcp_port_monitor;
523 #endif
524 #ifdef HDDTEMP
525                 struct {
526                         char *addr;
527                         int port;
528                         char *dev;
529                         double update_time;
530                         char *temp;
531                 } hddtemp;              /* 2 */
532 #endif
533 #ifdef EVE
534                 struct {
535                         char *apikey;
536                         char *charid;
537                         char *userid;
538                 } eve;
539 #endif
540 #ifdef RSS
541                 struct {
542                         char *uri;
543                         char *action;
544                         int act_par;
545                         int delay;
546                         unsigned int nrspaces;
547                 } rss;
548 #endif
549                 struct {
550                         char *text;
551                         unsigned int show;
552                         unsigned int step;
553                         unsigned int start;
554                 } scroll;
555
556                 struct {
557                         char *left;
558                         char *seperation;
559                         char *right;
560                 } combine;
561
562                 struct local_mail_s local_mail;
563 #ifdef NVIDIA
564                 struct nvidia_s nvidia;
565 #endif /* NVIDIA */
566
567         } data;
568         int type;
569         int a, b;
570         long line;
571         unsigned int c, d, e;
572         float f;
573         char char_a, char_b;
574 };
575
576 /* text object list helpers */
577 int append_object(struct text_object *root, struct text_object *obj);
578
579 /* ifblock helpers
580  *
581  * Opaque is a pointer to the address of the ifblock stack's top object.
582  * Calling clients should pass the address of a defined void pointer which
583  * was initialised to NULL (empty stack).
584  * */
585 int obj_be_ifblock_if(void **opaque, struct text_object *);
586 int obj_be_ifblock_else(void **opaque, struct text_object *);
587 int obj_be_ifblock_endif(void **opaque, struct text_object *);
588 int ifblock_stack_empty(void **opaque);
589
590 #endif /* _TEXT_OBJECT_H */