1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2 * vim: ts=4 sw=4 noet ai cindent syntax=c
4 * Conky, a system monitor, based on torsmo
6 * Any original torsmo code is licensed under the BSD license
8 * All code written since the fork of torsmo is licensed under the GPL
10 * Please see COPYING for details
12 * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
13 * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
15 * All rights reserved.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 #include "config.h" /* defines */
35 #include "common.h" /* at least for struct dns_data */
36 #include <sys/utsname.h> /* struct uname_s */
37 #include <arpa/inet.h>
39 #if defined(HAS_MCHECK_H)
41 #endif /* HAS_MCHECK_H */
46 #define EQUAL 0 //returnvalue of strcmp-variants when strings are equal
50 #define DEFAULT_BAR_WIDTH_NO_X 10
52 #if !defined(__GNUC__)
53 # define __attribute__(x) /* nothing */
57 // use our own strndup() if it's not available
58 char *strndup(const char *s, size_t n);
59 #endif /* HAVE_STRNDUP */
61 /* headers of optional features
62 * include them here, so we don't need to run the check
63 * in every code file optionally using the feature
66 /* forward define to make gcc happy */
70 #include "audacious.h"
94 #include "ccurl_thread.h"
95 #endif /* HAVE_CURL */
103 #error "WEATHER needs to be defined if XOAP is defined"
111 #ifdef TCP_PORT_MONITOR
112 #include "tcp-portmon.h"
131 #include <dbus/dbus.h>
132 #include <dbus/dbus-glib.h>
134 #include <mce/mode-names.h>
137 DBusConnection* conn;//session bus
138 DBusConnection* conn2;//system bus
140 DBusMessageIter args;
144 /* A size for temporary, static buffers to use when
145 * one doesn't know what to choose. Defaults to 256. */
146 extern unsigned int text_buffer_size;
157 struct monitor_info {
162 struct desktop_info {
171 struct monitor_info monitor;
172 struct desktop_info desktop;
175 int get_stippled_borders(void);
179 /* defined in conky.c */
180 extern long default_fg_color, default_bg_color, default_out_color;
181 extern long color0, color1, color2, color3, color4, color5, color6, color7,
183 void set_current_text_color(long colour);
184 long get_current_text_color(void);
186 void set_updatereset(int);
187 int get_updatereset(void);
189 int percent_print(char *, int, unsigned);
190 void human_readable(long long, char *, int);
194 struct conftree* horz_next;
195 struct conftree* vert_next;
196 struct conftree* back;
199 char load_config_file(const char *);
201 char *get_global_text(void);
202 extern long global_text_lines;
204 //adds newstring to to the tree unless you can already see it when travelling back.
205 //if it's possible to attach it then it returns a pointer to the leaf, else it returns NULL
206 struct conftree* conftree_add(struct conftree* previous, const char* newstring);
208 extern struct conftree *currentconffile;
210 #define MAX_TEMPLATES 10
211 char **get_templates(void);
213 /* get_xxxxx_stuff() item selector
214 * needed by conky.c, linux.c and freebsd.c */
222 DBUS_HAL_BATTERY_CHRG_STATUS,
223 DBUS_HAL_BATTERY_PERCENT,
224 DBUS_HAL_BATTERY_VOLTS_CURRENT
227 /* if_up strictness selector
228 * needed by conky.c and linux.c (and potentially others) */
238 struct utsname uname_s;
244 /* memory information in kilobytes */
245 unsigned long long mem, memeasyfree, memfree, memmax, swap, swapfree, swapmax;
246 unsigned long long bufmem, buffers, cached;
248 unsigned short procs;
249 unsigned short run_procs;
250 unsigned short threads;
251 unsigned short run_threads;
254 /* struct cpu_stat cpu_summed; what the hell is this? */
260 int diskio_avg_samples;
265 struct xmms2_s xmms2;
268 AUDACIOUS_S audacious;
273 struct usr_info users;
274 struct process *cpu[10];
275 struct process *memu[10];
276 struct process *time[10];
278 struct process *io[10];
280 struct process *first_process;
281 unsigned long looped;
282 double music_player_interval;
292 short kflags; /* kernel settings, see enum KFLAG */
297 #endif /* HAVE_LUA */
299 /* needed by linux.c and top.c -> outsource somewhere */
301 /* set to true if kernel uses "long" format for /proc/stats */
302 KFLAG_IS_LONGSTAT = 0x01,
303 /* set to true if kernel shows # of threads for the proc value
304 * in sysinfo() call */
305 KFLAG_PROC_IS_THREADS = 0x02
306 /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
307 /* KFLAG_NEXT_ONE = 0x04 */
309 #define KFLAG_SETON(a) info.kflags |= a
310 #define KFLAG_SETOFF(a) info.kflags &= (~a)
311 #define KFLAG_FLIP(a) info.kflags ^= a
312 #define KFLAG_ISSET(a) info.kflags & a
314 /* defined in conky.c, needed by top.c */
315 extern int top_cpu, top_mem, top_time;
319 extern int top_running;
321 /* defined in conky.c, needed by top.c */
322 extern int cpu_separate;
324 /* struct that has all info to be shared between
325 * instances of the same text object */
326 extern struct information info;
328 /* defined in users.c */
329 int update_users(void);
330 void update_user_time(char *tty);
332 /* defined in conky.c */
333 extern double current_update_time, last_update_time, update_interval;
334 extern int update_heartbeat_min, update_heartbeat_max, update_heartbeat_battery_skip, update_skips_when_sleeping;
335 /* defined in conky.c */
336 int spaced_print(char *, int, const char *, int, ...)
337 __attribute__((format(printf, 3, 5)));
338 extern int inotify_fd;
340 /* defined in conky.c
341 * evaluates 'text' and places the result in 'p' of max length 'p_max_size'
343 void evaluate(const char *text, char *p, int p_max_size);
345 /* maximum size of config TEXT buffer, i.e. below TEXT line. */
346 extern unsigned int max_user_text;
348 /* path to config file */
349 extern char *current_config;
356 #define OVERWRITE_FILE 8
357 #define APPEND_FILE 16
359 #define TO_NCURSES 32
361 enum x_initialiser_state {
366 extern int output_methods;
367 extern enum x_initialiser_state x_initialised;
369 void set_update_interval(double interval);
371 #define DEFAULT_TEXT_BUFFER_SIZE_S "##DEFAULT_TEXT_BUFFER_SIZE"
375 /* to get rid of 'unused variable' warnings */
376 #define UNUSED(a) (void)a
377 #define UNUSED_ATTR __attribute__ ((unused))
379 void parse_conky_vars(struct text_object *, const char *,
380 char *, int, struct information *);
382 void generate_text_internal(char *, int, struct text_object,
383 struct information *);
384 #endif /* _conky_h_ */