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