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