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