2009-07-28 21:44:22 +00:00
|
|
|
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
2009-09-12 10:50:51 +00:00
|
|
|
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
2009-07-28 21:44:22 +00:00
|
|
|
*
|
|
|
|
* Conky, a system monitor, based on torsmo
|
2005-08-05 01:06:17 +00:00
|
|
|
*
|
2007-08-10 19:53:44 +00:00
|
|
|
* Any original torsmo code is licensed under the BSD license
|
|
|
|
*
|
|
|
|
* All code written since the fork of torsmo is licensed under the GPL
|
|
|
|
*
|
|
|
|
* Please see COPYING for details
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
2009-03-30 04:55:30 +00:00
|
|
|
* Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
|
2008-02-20 20:30:45 +00:00
|
|
|
* (see AUTHORS)
|
2007-08-10 19:53:44 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2008-02-20 20:30:45 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-08-05 01:06:17 +00:00
|
|
|
*
|
2008-03-18 00:23:16 +00:00
|
|
|
*/
|
2005-08-05 01:06:17 +00:00
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
#ifndef _conky_h_
|
|
|
|
#define _conky_h_
|
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
#include "config.h" /* defines */
|
2009-08-07 07:24:24 +00:00
|
|
|
#include "common.h" /* at least for struct dns_data */
|
|
|
|
#include <sys/utsname.h> /* struct uname_s */
|
2009-08-08 00:49:28 +00:00
|
|
|
#include <arpa/inet.h>
|
2008-12-15 21:40:24 +00:00
|
|
|
|
2005-08-23 06:10:25 +00:00
|
|
|
#if defined(HAS_MCHECK_H)
|
2005-08-12 04:34:06 +00:00
|
|
|
#include <mcheck.h>
|
2005-08-23 06:10:25 +00:00
|
|
|
#endif /* HAS_MCHECK_H */
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2008-06-25 21:06:54 +00:00
|
|
|
#undef EQUAL
|
|
|
|
#undef FALSE
|
|
|
|
#undef TRUE
|
2008-06-21 20:37:58 +00:00
|
|
|
#define EQUAL 0 //returnvalue of strcmp-variants when strings are equal
|
2008-06-25 21:06:54 +00:00
|
|
|
#define FALSE 0
|
|
|
|
#define TRUE 1
|
2008-06-21 20:37:58 +00:00
|
|
|
|
2009-05-17 11:38:51 +00:00
|
|
|
#define DEFAULT_BAR_WIDTH_NO_X 10
|
2008-02-20 20:30:45 +00:00
|
|
|
|
2008-03-29 11:35:02 +00:00
|
|
|
#if !defined(__GNUC__)
|
|
|
|
# define __attribute__(x) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
2008-04-02 19:46:09 +00:00
|
|
|
#ifndef HAVE_STRNDUP
|
|
|
|
// use our own strndup() if it's not available
|
|
|
|
char *strndup(const char *s, size_t n);
|
|
|
|
#endif /* HAVE_STRNDUP */
|
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
/* headers of optional features
|
|
|
|
* include them here, so we don't need to run the check
|
|
|
|
* in every code file optionally using the feature
|
|
|
|
*/
|
|
|
|
|
2009-10-12 21:00:06 +00:00
|
|
|
/* forward define to make gcc happy */
|
|
|
|
struct text_object;
|
|
|
|
|
2006-11-03 20:54:52 +00:00
|
|
|
#ifdef AUDACIOUS
|
|
|
|
#include "audacious.h"
|
|
|
|
#endif
|
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
#ifdef BMPX
|
|
|
|
#include "bmpx.h"
|
2007-05-06 12:17:13 +00:00
|
|
|
#endif
|
|
|
|
|
2008-06-28 20:14:04 +00:00
|
|
|
#ifdef EVE
|
|
|
|
#include "eve.h"
|
|
|
|
#endif
|
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
#ifdef HDDTEMP
|
|
|
|
#include "hddtemp.h"
|
|
|
|
#endif /* HDDTEMP */
|
|
|
|
|
|
|
|
#ifdef MOC
|
|
|
|
#include "moc.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MPD
|
|
|
|
#include "mpd.h"
|
2008-03-18 00:23:16 +00:00
|
|
|
#endif
|
|
|
|
|
2009-07-20 05:43:36 +00:00
|
|
|
#ifdef HAVE_CURL
|
|
|
|
#include "ccurl_thread.h"
|
|
|
|
#endif /* HAVE_CURL */
|
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
#ifdef RSS
|
|
|
|
#include "rss.h"
|
2009-07-20 05:43:36 +00:00
|
|
|
#endif /* RSS */
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2009-07-20 19:17:44 +00:00
|
|
|
#ifdef XOAP
|
|
|
|
#ifndef WEATHER
|
|
|
|
#error "WEATHER needs to be defined if XOAP is defined"
|
|
|
|
#endif /* WEATHER */
|
|
|
|
#endif /* XOAP */
|
|
|
|
|
2009-07-06 22:20:12 +00:00
|
|
|
#ifdef WEATHER
|
|
|
|
#include "weather.h"
|
2009-07-20 05:43:36 +00:00
|
|
|
#endif /* WEATHER */
|
2009-07-06 22:20:12 +00:00
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
#ifdef TCP_PORT_MONITOR
|
|
|
|
#include "tcp-portmon.h"
|
2008-09-24 06:59:45 +00:00
|
|
|
#endif
|
|
|
|
|
2006-03-25 21:21:07 +00:00
|
|
|
#ifdef XMMS2
|
2008-06-14 18:41:12 +00:00
|
|
|
#include "xmms2.h"
|
2006-03-25 21:21:07 +00:00
|
|
|
#endif
|
|
|
|
|
2009-01-03 23:00:52 +00:00
|
|
|
#ifdef IBM
|
|
|
|
#include "ibm.h"
|
2009-01-03 23:25:15 +00:00
|
|
|
#include "smapi.h"
|
2009-01-03 23:00:52 +00:00
|
|
|
#endif
|
|
|
|
|
2009-05-10 18:58:06 +00:00
|
|
|
#ifdef APCUPSD
|
|
|
|
#include "apcupsd.h"
|
|
|
|
#endif
|
|
|
|
|
2009-05-04 19:13:51 +00:00
|
|
|
/* sony support */
|
|
|
|
#include "sony.h"
|
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
/* A size for temporary, static buffers to use when
|
|
|
|
* one doesn't know what to choose. Defaults to 256. */
|
|
|
|
extern unsigned int text_buffer_size;
|
2005-12-30 09:44:40 +00:00
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
struct usr_info {
|
|
|
|
char *names;
|
|
|
|
char *times;
|
2009-11-13 15:30:04 +00:00
|
|
|
char *ctime;
|
2009-08-07 07:24:24 +00:00
|
|
|
char *terms;
|
|
|
|
int number;
|
|
|
|
};
|
|
|
|
|
2008-06-21 20:37:58 +00:00
|
|
|
#ifdef X11
|
2009-08-07 07:24:24 +00:00
|
|
|
struct monitor_info {
|
|
|
|
int number;
|
|
|
|
int current;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct desktop_info {
|
|
|
|
int current;
|
|
|
|
int number;
|
|
|
|
unsigned int nitems;
|
|
|
|
char *all_names;
|
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct x11_info {
|
|
|
|
struct monitor_info monitor;
|
|
|
|
struct desktop_info desktop;
|
|
|
|
};
|
|
|
|
|
2009-08-05 22:46:51 +00:00
|
|
|
int get_stippled_borders(void);
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2009-08-05 22:46:51 +00:00
|
|
|
#endif /* X11 */
|
|
|
|
|
|
|
|
/* defined in conky.c */
|
|
|
|
extern long default_fg_color, default_bg_color, default_out_color;
|
|
|
|
extern long color0, color1, color2, color3, color4, color5, color6, color7,
|
|
|
|
color8, color9;
|
|
|
|
void set_current_text_color(long colour);
|
|
|
|
long get_current_text_color(void);
|
|
|
|
|
|
|
|
void set_updatereset(int);
|
|
|
|
int get_updatereset(void);
|
2009-11-29 18:48:24 +00:00
|
|
|
int get_total_updates(void);
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2009-10-04 14:53:21 +00:00
|
|
|
int percent_print(char *, int, unsigned);
|
|
|
|
void human_readable(long long, char *, int);
|
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
struct conftree {
|
|
|
|
char* string;
|
|
|
|
struct conftree* horz_next;
|
|
|
|
struct conftree* vert_next;
|
|
|
|
struct conftree* back;
|
|
|
|
};
|
|
|
|
|
|
|
|
char load_config_file(const char *);
|
|
|
|
|
2009-08-05 22:46:51 +00:00
|
|
|
char *get_global_text(void);
|
|
|
|
extern long global_text_lines;
|
|
|
|
|
|
|
|
//adds newstring to to the tree unless you can already see it when travelling back.
|
|
|
|
//if it's possible to attach it then it returns a pointer to the leaf, else it returns NULL
|
|
|
|
struct conftree* conftree_add(struct conftree* previous, const char* newstring);
|
|
|
|
|
|
|
|
extern struct conftree *currentconffile;
|
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
#define MAX_TEMPLATES 10
|
|
|
|
char **get_templates(void);
|
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
/* get_battery_stuff() item selector
|
|
|
|
* needed by conky.c, linux.c and freebsd.c */
|
2006-12-12 23:21:14 +00:00
|
|
|
enum {
|
|
|
|
BATTERY_STATUS,
|
|
|
|
BATTERY_TIME
|
|
|
|
};
|
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
/* if_up strictness selector
|
|
|
|
* needed by conky.c and linux.c (and potentially others) */
|
2008-05-30 11:30:58 +00:00
|
|
|
enum {
|
|
|
|
IFUP_UP,
|
|
|
|
IFUP_LINK,
|
|
|
|
IFUP_ADDR
|
|
|
|
} ifup_strictness;
|
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
struct information {
|
|
|
|
unsigned int mask;
|
|
|
|
|
|
|
|
struct utsname uname_s;
|
|
|
|
|
|
|
|
char freq[10];
|
|
|
|
|
|
|
|
double uptime;
|
|
|
|
|
|
|
|
/* memory information in kilobytes */
|
|
|
|
unsigned long long mem, memeasyfree, memfree, memmax, swap, swapfree, swapmax;
|
|
|
|
unsigned long long bufmem, buffers, cached;
|
|
|
|
|
|
|
|
unsigned short procs;
|
|
|
|
unsigned short run_procs;
|
2009-11-07 17:14:04 +00:00
|
|
|
unsigned short threads;
|
2009-11-15 16:42:59 +00:00
|
|
|
unsigned short run_threads;
|
2009-08-07 07:24:24 +00:00
|
|
|
|
|
|
|
float *cpu_usage;
|
|
|
|
/* struct cpu_stat cpu_summed; what the hell is this? */
|
2009-10-17 14:55:12 +00:00
|
|
|
int cpu_count;
|
2009-08-07 07:24:24 +00:00
|
|
|
int cpu_avg_samples;
|
|
|
|
|
|
|
|
int net_avg_samples;
|
|
|
|
|
|
|
|
int diskio_avg_samples;
|
|
|
|
|
|
|
|
float loadavg[3];
|
|
|
|
|
|
|
|
#ifdef XMMS2
|
|
|
|
struct xmms2_s xmms2;
|
|
|
|
#endif
|
|
|
|
#ifdef AUDACIOUS
|
|
|
|
AUDACIOUS_S audacious;
|
|
|
|
#endif
|
|
|
|
#ifdef BMPX
|
|
|
|
struct bmpx_s bmpx;
|
|
|
|
#endif
|
|
|
|
struct usr_info users;
|
|
|
|
struct process *cpu[10];
|
|
|
|
struct process *memu[10];
|
|
|
|
struct process *time[10];
|
|
|
|
#ifdef IOSTATS
|
|
|
|
struct process *io[10];
|
|
|
|
#endif
|
|
|
|
struct process *first_process;
|
|
|
|
unsigned long looped;
|
|
|
|
double music_player_interval;
|
|
|
|
|
|
|
|
#ifdef X11
|
|
|
|
struct x11_info x11;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef APCUPSD
|
|
|
|
APCUPSD_S apcupsd;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
short kflags; /* kernel settings, see enum KFLAG */
|
|
|
|
};
|
|
|
|
|
2009-07-28 18:38:43 +00:00
|
|
|
#ifdef HAVE_LUA
|
|
|
|
#include "llua.h"
|
|
|
|
#endif /* HAVE_LUA */
|
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
/* needed by linux.c and top.c -> outsource somewhere */
|
2005-11-27 06:56:35 +00:00
|
|
|
enum {
|
2008-02-20 20:30:45 +00:00
|
|
|
/* set to true if kernel uses "long" format for /proc/stats */
|
|
|
|
KFLAG_IS_LONGSTAT = 0x01,
|
|
|
|
/* set to true if kernel shows # of threads for the proc value
|
|
|
|
* in sysinfo() call */
|
|
|
|
KFLAG_PROC_IS_THREADS = 0x02
|
|
|
|
/* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
|
|
|
|
/* KFLAG_NEXT_ONE = 0x04 */
|
|
|
|
};
|
2009-08-07 07:24:24 +00:00
|
|
|
#define KFLAG_SETON(a) info.kflags |= a
|
|
|
|
#define KFLAG_SETOFF(a) info.kflags &= (~a)
|
|
|
|
#define KFLAG_FLIP(a) info.kflags ^= a
|
|
|
|
#define KFLAG_ISSET(a) info.kflags & a
|
|
|
|
|
|
|
|
/* defined in conky.c, needed by top.c */
|
|
|
|
extern int top_cpu, top_mem, top_time;
|
|
|
|
#ifdef IOSTATS
|
|
|
|
extern int top_io;
|
|
|
|
#endif
|
2009-09-03 21:13:14 +00:00
|
|
|
extern int top_running;
|
2009-08-07 07:24:24 +00:00
|
|
|
|
|
|
|
/* defined in conky.c, needed by top.c */
|
|
|
|
extern int cpu_separate;
|
|
|
|
|
|
|
|
/* struct that has all info to be shared between
|
|
|
|
* instances of the same text object */
|
|
|
|
extern struct information info;
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
/* defined in conky.c */
|
|
|
|
extern double current_update_time, last_update_time, update_interval;
|
|
|
|
|
|
|
|
/* defined in conky.c */
|
|
|
|
int spaced_print(char *, int, const char *, int, ...)
|
|
|
|
__attribute__((format(printf, 3, 5)));
|
2009-05-20 04:49:42 +00:00
|
|
|
extern int inotify_fd;
|
2009-02-18 05:00:23 +00:00
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
/* defined in conky.c
|
2009-11-16 01:15:13 +00:00
|
|
|
* evaluates 'text' and places the result in 'p' of max length 'p_max_size'
|
2009-08-07 07:24:24 +00:00
|
|
|
*/
|
2009-11-16 01:15:13 +00:00
|
|
|
void evaluate(const char *text, char *p, int p_max_size);
|
2009-08-07 07:24:24 +00:00
|
|
|
|
|
|
|
/* maximum size of config TEXT buffer, i.e. below TEXT line. */
|
|
|
|
extern unsigned int max_user_text;
|
|
|
|
|
|
|
|
/* path to config file */
|
|
|
|
extern char *current_config;
|
|
|
|
|
|
|
|
#ifdef X11
|
|
|
|
#define TO_X 1
|
|
|
|
#endif /* X11 */
|
|
|
|
#define TO_STDOUT 2
|
|
|
|
#define TO_STDERR 4
|
|
|
|
#define OVERWRITE_FILE 8
|
|
|
|
#define APPEND_FILE 16
|
|
|
|
#ifdef NCURSES
|
|
|
|
#define TO_NCURSES 32
|
|
|
|
#endif /* NCURSES */
|
|
|
|
enum x_initialiser_state {
|
|
|
|
NO = 0,
|
|
|
|
YES = 1,
|
|
|
|
NEVER = 2
|
|
|
|
};
|
|
|
|
extern int output_methods;
|
|
|
|
extern enum x_initialiser_state x_initialised;
|
|
|
|
|
|
|
|
void set_update_interval(double interval);
|
|
|
|
|
|
|
|
#define DEFAULT_TEXT_BUFFER_SIZE_S "##DEFAULT_TEXT_BUFFER_SIZE"
|
|
|
|
|
2009-07-27 11:34:20 +00:00
|
|
|
#define NOBATTERY 0
|
|
|
|
|
2009-08-03 18:57:22 +00:00
|
|
|
/* to get rid of 'unused variable' warnings */
|
2009-08-03 19:34:47 +00:00
|
|
|
#define UNUSED(a) (void)a
|
2009-08-03 19:48:18 +00:00
|
|
|
#define UNUSED_ATTR __attribute__ ((unused))
|
2009-08-03 18:56:41 +00:00
|
|
|
|
2009-11-29 19:43:46 +00:00
|
|
|
void parse_conky_vars(struct text_object *, const char *, char *, int);
|
2009-10-15 19:51:21 +00:00
|
|
|
|
2009-11-29 19:43:46 +00:00
|
|
|
void generate_text_internal(char *, int, struct text_object);
|
2009-02-22 16:53:30 +00:00
|
|
|
#endif /* _conky_h_ */
|