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