d9a48ad7eac73c35b6408eeeebf36e89c13760d2
[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_mixer,
209         OBJ_mixerl,
210         OBJ_mixerr,
211         OBJ_mixerbar,
212         OBJ_mixerlbar,
213         OBJ_mixerrbar,
214         OBJ_if_mixer_mute,
215 #ifdef X11
216         OBJ_monitor,
217         OBJ_monitor_number,
218 #endif
219         OBJ_nameserver,
220         OBJ_nodename,
221         OBJ_nvidia,
222         OBJ_pre_exec,
223         OBJ_processes,
224         OBJ_running_processes,
225         OBJ_shadecolor,
226         OBJ_outlinecolor,
227         OBJ_stippled_hr,
228         OBJ_swap,
229         OBJ_swapbar,
230         OBJ_swapmax,
231         OBJ_swapperc,
232         OBJ_sysname,
233         OBJ_text,
234         OBJ_time,
235         OBJ_utime,
236         OBJ_tztime,
237         OBJ_totaldown,
238         OBJ_totalup,
239         OBJ_updates,
240         OBJ_upspeed,
241         OBJ_upspeedf,
242         OBJ_upspeedgraph,
243         OBJ_uptime,
244         OBJ_uptime_short,
245         OBJ_user_names,
246         OBJ_user_terms,
247         OBJ_user_times,
248         OBJ_user_number,
249         OBJ_imap_messages,
250         OBJ_imap_unseen,
251         OBJ_pop3_unseen,
252         OBJ_pop3_used,
253 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
254                 || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
255         OBJ_apm_adapter,
256         OBJ_apm_battery_time,
257         OBJ_apm_battery_life,
258 #endif /* __FreeBSD__ __OpenBSD__ */
259 #ifdef __OpenBSD__
260         OBJ_obsd_sensors_temp,
261         OBJ_obsd_sensors_fan,
262         OBJ_obsd_sensors_volt,
263         OBJ_obsd_vendor,
264         OBJ_obsd_product,
265 #endif /* __OpenBSD__ */
266 #ifdef MPD
267         OBJ_mpd_title,
268         OBJ_mpd_artist,
269         OBJ_mpd_album,
270         OBJ_mpd_random,
271         OBJ_mpd_repeat,
272         OBJ_mpd_vol,
273         OBJ_mpd_bitrate,
274         OBJ_mpd_status,
275         OBJ_mpd_bar,
276         OBJ_mpd_elapsed,
277         OBJ_mpd_length,
278         OBJ_mpd_track,
279         OBJ_mpd_name,
280         OBJ_mpd_file,
281         OBJ_mpd_percent,
282         OBJ_mpd_smart,
283         OBJ_if_mpd_playing,
284 #endif
285 #ifdef MOC
286         OBJ_moc_state,
287         OBJ_moc_file,
288         OBJ_moc_title,
289         OBJ_moc_artist,
290         OBJ_moc_song,
291         OBJ_moc_album,
292         OBJ_moc_totaltime,
293         OBJ_moc_timeleft,
294         OBJ_moc_curtime,
295         OBJ_moc_bitrate,
296         OBJ_moc_rate,
297 #endif
298 #ifdef XMMS2
299         OBJ_xmms2_artist,
300         OBJ_xmms2_album,
301         OBJ_xmms2_title,
302         OBJ_xmms2_genre,
303         OBJ_xmms2_comment,
304         OBJ_xmms2_url,
305         OBJ_xmms2_date,
306         OBJ_xmms2_tracknr,
307         OBJ_xmms2_bitrate,
308         OBJ_xmms2_id,
309         OBJ_xmms2_duration,
310         OBJ_xmms2_elapsed,
311         OBJ_xmms2_size,
312         OBJ_xmms2_percent,
313         OBJ_xmms2_status,
314         OBJ_xmms2_bar,
315         OBJ_xmms2_smart,
316         OBJ_xmms2_playlist,
317         OBJ_xmms2_timesplayed,
318         OBJ_if_xmms2_connected,
319 #endif
320 #ifdef AUDACIOUS
321         OBJ_audacious_status,
322         OBJ_audacious_title,
323         OBJ_audacious_length,
324         OBJ_audacious_length_seconds,
325         OBJ_audacious_position,
326         OBJ_audacious_position_seconds,
327         OBJ_audacious_bitrate,
328         OBJ_audacious_frequency,
329         OBJ_audacious_channels,
330         OBJ_audacious_filename,
331         OBJ_audacious_playlist_length,
332         OBJ_audacious_playlist_position,
333         OBJ_audacious_main_volume,
334         OBJ_audacious_bar,
335 #endif
336 #ifdef BMPX
337         OBJ_bmpx_title,
338         OBJ_bmpx_artist,
339         OBJ_bmpx_album,
340         OBJ_bmpx_track,
341         OBJ_bmpx_uri,
342         OBJ_bmpx_bitrate,
343 #endif
344 #ifdef EVE
345         OBJ_eve,
346 #endif
347 #ifdef RSS
348         OBJ_rss,
349 #endif
350 #ifdef TCP_PORT_MONITOR
351         OBJ_tcp_portmon,
352 #endif
353 #ifdef HAVE_ICONV
354         OBJ_iconv_start,
355         OBJ_iconv_stop,
356 #endif
357 #ifdef HDDTEMP
358         OBJ_hddtemp,
359 #endif
360         OBJ_scroll,
361         OBJ_combine,
362         OBJ_entropy_avail,
363         OBJ_entropy_poolsize,
364         OBJ_entropy_bar
365 };
366
367 struct text_object {
368         struct text_object *next, *prev;        /* doubly linked list of text objects */
369         struct text_object *sub;                /* for objects parsing text into objects */
370         union {
371                 char *s;                /* some string */
372                 int i;                  /* some integer */
373                 long l;                 /* some other integer */
374                 unsigned int sensor;
375                 struct net_stat *net;
376                 struct fs_stat *fs;
377                 struct diskio_stat *diskio;
378                 unsigned char loadavg[3];
379                 unsigned int cpu_index;
380                 struct mail_s *mail;
381
382                 struct {
383                         char *args;
384                         char *output;
385                 } mboxscan;
386
387                 struct {
388                         char *tz;       /* timezone variable */
389                         char *fmt;      /* time display formatting */
390                 } tztime;
391
392                 struct {
393                         struct fs_stat *fs;
394                         int w, h;
395                 } fsbar;                /* 3 */
396
397                 struct {
398                         int l;
399                         int w, h;
400                 } mixerbar;             /* 3 */
401
402                 struct {
403                         int fd;
404                         int arg;
405                         char devtype[256];
406                         char type[64];
407                 } sysfs;                /* 2 */
408
409                 struct {
410                         struct text_object *next;
411                         char *s;
412                         int i;
413                         char *str;
414                 } ifblock;
415
416                 struct {
417                         int num;
418                         int type;
419                 } top;
420
421                 struct {
422                         int wantedlines;
423                         int readlines;
424                         char *logfile;
425                         double last_update;
426                         float interval;
427                         char *buffer;
428                         /* If not -1, a file descriptor to read from when
429                          * logfile is a FIFO. */
430                         int fd;
431                 } tail;
432
433                 struct {
434                         double last_update;
435                         float interval;
436                         char *cmd;
437                         char *buffer;
438                         double data;
439                 } execi;                /* 5 */
440
441                 struct {
442                         float interval;
443                         char *cmd;
444                         char *buffer;
445                         double data;
446                         timed_thread *p_timed_thread;
447                 } texeci;
448
449                 struct {
450                         int a, b;
451                 } pair;                 /* 2 */
452 #ifdef TCP_PORT_MONITOR
453                 struct tcp_port_monitor_data tcp_port_monitor;
454 #endif
455 #ifdef HDDTEMP
456                 struct {
457                         char *addr;
458                         int port;
459                         char *dev;
460                         double update_time;
461                         char *temp;
462                 } hddtemp;              /* 2 */
463 #endif
464 #ifdef EVE
465                 struct {
466                         char *apikey;
467                         char *charid;
468                         char *userid;
469                 } eve;
470 #endif
471 #ifdef RSS
472                 struct {
473                         char *uri;
474                         char *action;
475                         int act_par;
476                         int delay;
477                         unsigned int nrspaces;
478                 } rss;
479 #endif
480                 struct {
481                         char *text;
482                         unsigned int show;
483                         unsigned int step;
484                         unsigned int start;
485                 } scroll;
486
487                 struct {
488                         char *left;
489                         char *seperation;
490                         char *right;
491                 } combine;
492
493                 struct local_mail_s local_mail;
494 #ifdef NVIDIA
495                 struct nvidia_s nvidia;
496 #endif /* NVIDIA */
497
498         } data;
499         int type;
500         int a, b;
501         long line;
502         unsigned int c, d, e;
503         float f;
504         char showaslog;
505         char global_mode;
506 };
507
508 /* text object list helpers */
509 int append_object(struct text_object *root, struct text_object *obj);
510
511 /* ifblock helpers
512  *
513  * Opaque is a pointer to the address of the ifblock stack's top object.
514  * Calling clients should pass the address of a defined void pointer which
515  * was initialised to NULL (empty stack).
516  * */
517 int obj_be_ifblock_if(void **opaque, struct text_object *);
518 int obj_be_ifblock_else(void **opaque, struct text_object *);
519 int obj_be_ifblock_endif(void **opaque, struct text_object *);
520 int ifblock_stack_empty(void **opaque);
521
522 #endif /* _TEXT_OBJECT_H */