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