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