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