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