2008-02-20 20:30:45 +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
|
|
|
*
|
2009-07-27 20:47:19 +00:00
|
|
|
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
|
|
|
*
|
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 */
|
|
|
|
#include "common.h" /* at least for struct dns_data */
|
|
|
|
#include <sys/utsname.h> /* struct uname_s */
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
2008-06-03 20:46:15 +00:00
|
|
|
#ifdef NVIDIA
|
|
|
|
#include "nvidia.h"
|
|
|
|
#endif
|
2008-06-15 18:38:33 +00:00
|
|
|
|
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
|
|
|
|
2006-11-30 20:46:34 +00:00
|
|
|
struct entropy_s {
|
|
|
|
unsigned int entropy_avail;
|
|
|
|
unsigned int poolsize;
|
|
|
|
};
|
|
|
|
|
2008-03-18 00:23:16 +00:00
|
|
|
struct usr_info {
|
|
|
|
char *names;
|
|
|
|
char *times;
|
|
|
|
char *terms;
|
|
|
|
int number;
|
|
|
|
};
|
|
|
|
|
2008-03-22 19:06:09 +00:00
|
|
|
struct gateway_info {
|
|
|
|
char *iface;
|
|
|
|
char *ip;
|
|
|
|
int count;
|
|
|
|
};
|
|
|
|
|
2008-06-21 20:37:58 +00:00
|
|
|
#ifdef X11
|
|
|
|
struct monitor_info {
|
|
|
|
int number;
|
|
|
|
int current;
|
|
|
|
};
|
|
|
|
|
2009-07-11 08:50:02 +00:00
|
|
|
struct desktop_info {
|
|
|
|
int current;
|
|
|
|
int number;
|
2009-07-14 14:57:51 +00:00
|
|
|
unsigned int nitems;
|
|
|
|
char *all_names;
|
2009-07-11 08:50:02 +00:00
|
|
|
char *name;
|
|
|
|
};
|
|
|
|
|
2008-06-21 20:37:58 +00:00
|
|
|
struct x11_info {
|
|
|
|
struct monitor_info monitor;
|
2009-07-11 08:50:02 +00:00
|
|
|
struct desktop_info desktop;
|
2008-06-21 20:37:58 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
enum {
|
|
|
|
INFO_CPU = 0,
|
|
|
|
INFO_MAIL = 1,
|
|
|
|
INFO_MEM = 2,
|
|
|
|
INFO_NET = 3,
|
2006-11-05 00:23:18 +00:00
|
|
|
INFO_PROCS = 4,
|
|
|
|
INFO_RUN_PROCS = 5,
|
|
|
|
INFO_UPTIME = 6,
|
|
|
|
INFO_BUFFERS = 7,
|
|
|
|
INFO_FS = 8,
|
2007-08-13 23:14:01 +00:00
|
|
|
INFO_SYSFS = 9,
|
2006-11-05 00:23:18 +00:00
|
|
|
INFO_MIXER = 10,
|
|
|
|
INFO_LOADAVG = 11,
|
|
|
|
INFO_UNAME = 12,
|
|
|
|
INFO_FREQ = 13,
|
2005-07-20 00:30:40 +00:00
|
|
|
#ifdef MPD
|
2006-11-05 00:23:18 +00:00
|
|
|
INFO_MPD = 14,
|
2005-07-20 00:30:40 +00:00
|
|
|
#endif
|
2006-11-05 00:23:18 +00:00
|
|
|
INFO_TOP = 15,
|
|
|
|
INFO_WIFI = 16,
|
|
|
|
INFO_DISKIO = 17,
|
|
|
|
INFO_I8K = 18,
|
2005-10-31 05:17:06 +00:00
|
|
|
#ifdef TCP_PORT_MONITOR
|
2008-02-20 20:30:45 +00:00
|
|
|
INFO_TCP_PORT_MONITOR = 19,
|
2005-10-31 05:17:06 +00:00
|
|
|
#endif
|
2006-11-03 20:54:52 +00:00
|
|
|
#ifdef AUDACIOUS
|
2006-11-05 00:23:18 +00:00
|
|
|
INFO_AUDACIOUS = 20,
|
2006-11-03 20:54:52 +00:00
|
|
|
#endif
|
2006-01-08 08:02:37 +00:00
|
|
|
#ifdef BMPX
|
2006-11-05 00:23:18 +00:00
|
|
|
INFO_BMPX = 21,
|
2006-01-07 07:01:22 +00:00
|
|
|
#endif
|
2006-03-25 21:21:07 +00:00
|
|
|
#ifdef XMMS2
|
2006-11-05 00:23:18 +00:00
|
|
|
INFO_XMMS2 = 22,
|
2006-03-25 21:21:07 +00:00
|
|
|
#endif
|
2006-11-30 20:46:34 +00:00
|
|
|
INFO_ENTROPY = 23,
|
2009-01-03 23:25:15 +00:00
|
|
|
#ifdef IBM
|
2008-03-18 00:23:16 +00:00
|
|
|
INFO_SMAPI = 25,
|
|
|
|
#endif
|
|
|
|
INFO_USERS = 26,
|
2008-03-22 22:58:26 +00:00
|
|
|
INFO_GW = 27,
|
2008-06-03 20:46:15 +00:00
|
|
|
#ifdef NVIDIA
|
2008-06-21 20:37:58 +00:00
|
|
|
INFO_NVIDIA = 28,
|
2008-06-03 20:46:15 +00:00
|
|
|
#endif
|
2008-06-21 20:37:58 +00:00
|
|
|
#ifdef X11
|
|
|
|
INFO_X11 = 29,
|
|
|
|
#endif
|
2008-09-24 06:59:45 +00:00
|
|
|
INFO_DNS = 30,
|
|
|
|
#ifdef MOC
|
2009-05-10 18:58:06 +00:00
|
|
|
INFO_MOC = 31,
|
|
|
|
#endif
|
|
|
|
#ifdef APCUPSD
|
|
|
|
INFO_APCUPSD = 32,
|
2008-09-24 06:59:45 +00:00
|
|
|
#endif
|
2009-07-06 22:20:12 +00:00
|
|
|
#ifdef WEATHER
|
|
|
|
INFO_WEATHER = 33,
|
|
|
|
#endif
|
2005-07-20 00:30:40 +00:00
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
struct information {
|
|
|
|
unsigned int mask;
|
|
|
|
|
|
|
|
struct utsname uname_s;
|
|
|
|
|
|
|
|
char freq[10];
|
|
|
|
|
|
|
|
double uptime;
|
|
|
|
|
|
|
|
/* memory information in kilobytes */
|
2009-07-09 18:12:52 +00:00
|
|
|
unsigned long long mem, memeasyfree, memfree, memmax, swap, swapfree, swapmax;
|
2006-11-15 03:28:37 +00:00
|
|
|
unsigned long long bufmem, buffers, cached;
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2005-11-27 06:56:35 +00:00
|
|
|
unsigned short procs;
|
|
|
|
unsigned short run_procs;
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2005-08-27 09:29:24 +00:00
|
|
|
float *cpu_usage;
|
2008-02-20 20:30:45 +00:00
|
|
|
/* struct cpu_stat cpu_summed; what the hell is this? */
|
2005-07-20 00:30:40 +00:00
|
|
|
unsigned int cpu_count;
|
2009-05-05 23:36:12 +00:00
|
|
|
int cpu_avg_samples;
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2009-05-05 23:36:12 +00:00
|
|
|
int net_avg_samples;
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2009-05-05 23:36:12 +00:00
|
|
|
int diskio_avg_samples;
|
2009-05-01 23:03:59 +00:00
|
|
|
|
2005-07-20 00:30:40 +00:00
|
|
|
float loadavg[3];
|
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
struct mail_s *mail;
|
2006-05-08 22:34:38 +00:00
|
|
|
int mail_running;
|
2006-03-25 21:21:07 +00:00
|
|
|
#ifdef XMMS2
|
|
|
|
struct xmms2_s xmms2;
|
|
|
|
#endif
|
2006-11-03 20:54:52 +00:00
|
|
|
#ifdef AUDACIOUS
|
2008-06-16 19:40:28 +00:00
|
|
|
AUDACIOUS_S audacious;
|
2006-11-03 20:54:52 +00:00
|
|
|
#endif
|
2005-12-30 09:44:40 +00:00
|
|
|
#ifdef BMPX
|
|
|
|
struct bmpx_s bmpx;
|
2005-07-20 00:30:40 +00:00
|
|
|
#endif
|
2008-03-18 00:23:16 +00:00
|
|
|
struct usr_info users;
|
2008-03-22 19:06:09 +00:00
|
|
|
struct gateway_info gw_info;
|
2008-03-22 22:58:26 +00:00
|
|
|
struct dns_data nameserver_info;
|
2005-07-25 00:22:16 +00:00
|
|
|
struct process *cpu[10];
|
|
|
|
struct process *memu[10];
|
2009-02-07 14:01:50 +00:00
|
|
|
struct process *time[10];
|
2009-06-12 17:08:44 +00:00
|
|
|
#ifdef IOSTATS
|
|
|
|
struct process *io[10];
|
|
|
|
#endif
|
2005-11-10 04:19:43 +00:00
|
|
|
struct process *first_process;
|
2005-07-20 00:30:40 +00:00
|
|
|
unsigned long looped;
|
2006-11-30 20:46:34 +00:00
|
|
|
struct entropy_s entropy;
|
2008-02-20 20:30:45 +00:00
|
|
|
double music_player_interval;
|
2007-10-17 20:31:27 +00:00
|
|
|
|
2008-06-21 20:37:58 +00:00
|
|
|
#ifdef X11
|
|
|
|
struct x11_info x11;
|
|
|
|
#endif
|
|
|
|
|
2009-05-10 18:58:06 +00:00
|
|
|
#ifdef APCUPSD
|
|
|
|
APCUPSD_S apcupsd;
|
|
|
|
#endif
|
|
|
|
|
2008-02-20 20:30:45 +00:00
|
|
|
short kflags; /* kernel settings, see enum KFLAG */
|
2005-07-20 00:30:40 +00:00
|
|
|
};
|
|
|
|
|
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 */
|
|
|
|
};
|
|
|
|
#define KFLAG_SETON(a) info.kflags |= a
|
2005-11-27 06:56:35 +00:00
|
|
|
#define KFLAG_SETOFF(a) info.kflags &= (~a)
|
|
|
|
#define KFLAG_FLIP(a) info.kflags ^= a
|
|
|
|
#define KFLAG_ISSET(a) info.kflags & a
|
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
/* defined in conky.c, needed by top.c */
|
2009-02-07 14:01:50 +00:00
|
|
|
extern int top_cpu, top_mem, top_time;
|
2009-06-12 17:08:44 +00:00
|
|
|
#ifdef IOSTATS
|
|
|
|
extern int top_io;
|
|
|
|
#endif
|
2005-08-08 01:18:52 +00:00
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
/* defined in conky.c, needed by top.c */
|
|
|
|
extern int cpu_separate;
|
2008-06-21 20:37:58 +00:00
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
/* 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
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
/* defined in users.c */
|
|
|
|
void update_users(void);
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
/* defined in conky.c */
|
2009-01-05 00:27:07 +00:00
|
|
|
extern double current_update_time, last_update_time, update_interval;
|
2005-07-20 00:30:40 +00:00
|
|
|
|
2009-02-18 05:00:23 +00:00
|
|
|
/* 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-07-08 08:09:06 +00:00
|
|
|
/* defined in conky.c
|
|
|
|
* evaluates 'text' and places the result in 'buffer'
|
|
|
|
*/
|
|
|
|
void evaluate(char *text, char *buffer);
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2009-05-31 14:48:16 +00:00
|
|
|
#ifdef X11
|
2009-02-22 16:53:30 +00:00
|
|
|
#define TO_X 1
|
2009-05-31 14:48:16 +00:00
|
|
|
#endif
|
2009-02-22 16:53:30 +00:00
|
|
|
#define TO_STDOUT 2
|
|
|
|
#define TO_STDERR 4
|
|
|
|
#define OVERWRITE_FILE 8
|
|
|
|
#define APPEND_FILE 16
|
|
|
|
enum x_initialiser_state {
|
|
|
|
NO = 0,
|
|
|
|
YES = 1,
|
|
|
|
NEVER = 2
|
|
|
|
};
|
|
|
|
extern int output_methods;
|
|
|
|
extern enum x_initialiser_state x_initialised;
|
|
|
|
|
2009-07-28 18:38:43 +00:00
|
|
|
void set_update_interval(double interval);
|
|
|
|
|
2009-05-25 04:33:47 +00:00
|
|
|
#define DEFAULT_TEXT_BUFFER_SIZE_S "##DEFAULT_TEXT_BUFFER_SIZE"
|
|
|
|
|
2009-07-27 11:34:20 +00:00
|
|
|
#define NOBATTERY 0
|
|
|
|
|
2009-02-22 16:53:30 +00:00
|
|
|
#endif /* _conky_h_ */
|