mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-25 12:10:03 +00:00
here comes the big header include rewrite
Some statics are now defined by configure.ac.in, conky.h got a lot smaller, which I see as a positive sign. This patch should not change any functionality, just change what's defined where. Some features I did/could not test are probably broken, also compiling for any other OS surely won't complete now. Though I think fixing these problems is as easy as including some missing headers. I've done compile checks with the following configure options: ./configure --enable-eve --enable-rss --enable-smapi --enable-wlan --enable-debug --enable-testing So what needs to be tested is: - audacious - BMPx - xmms2 - nvidia
This commit is contained in:
parent
ec174bedf2
commit
9a85812e06
@ -249,7 +249,7 @@ dnl EVE Skill Monitor
|
||||
dnl
|
||||
|
||||
AC_ARG_ENABLE([eve],
|
||||
EC_HELP_STRING([--enable-eve], [Eve-Online skill monitor @<:@default=no@:>@]),
|
||||
AC_HELP_STRING([--enable-eve], [Eve-Online skill monitor @<:@default=no@:>@]),
|
||||
[want_eve="$enableval"], [want_eve=no])
|
||||
|
||||
AM_CONDITIONAL(BUILD_EVE, test x$want_eve = xyes)
|
||||
@ -552,6 +552,9 @@ dnl
|
||||
|
||||
AC_DEFINE(DEFAULTNETDEV, "eth0", [Default networkdevice])
|
||||
AC_DEFINE(CONFIG_FILE, "$HOME/.conkyrc", [Configfile of the user])
|
||||
AC_DEFINE(MAX_SPECIALS_DEFAULT, 512, [Default maximum number of special things, e.g. fonts, offsets, aligns, etc.])
|
||||
AC_DEFINE(MAX_USER_TEXT_DEFAULT, 16384, [Default maximum size of config TEXT buffer, i.e. below TEXT line.])
|
||||
AC_DEFINE(DEFAULT_TEXT_BUFFER_SIZE, 256, [Default size used for temporary, static text buffers])
|
||||
|
||||
dnl
|
||||
dnl Some functions
|
||||
@ -656,7 +659,7 @@ AC_ARG_ENABLE([debug],
|
||||
|
||||
if test "x$want_debug" = "xyes" -a $ac_cv_c_compiler_gnu != no; then
|
||||
CFLAGS="$CFLAGS -g3"
|
||||
AC_DEFINE([DEBUG], [], [Define for debugging])
|
||||
AC_DEFINE([DEBUG], 1, [Define for debugging])
|
||||
fi
|
||||
|
||||
dnl
|
||||
|
@ -123,6 +123,7 @@ conky_SOURCES = \
|
||||
fs.c \
|
||||
$(hddtemp) \
|
||||
$(linux) \
|
||||
logging.h \
|
||||
$(nvidia) \
|
||||
mail.c \
|
||||
mixer.c \
|
||||
|
@ -17,9 +17,10 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
|
||||
* USA. */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include "config.h"
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "audacious.h"
|
||||
|
||||
#include <glib.h>
|
||||
#ifndef AUDACIOUS_LEGACY
|
||||
@ -50,9 +51,6 @@
|
||||
xmms_remote_get_playlist_length(x)
|
||||
#endif
|
||||
|
||||
#include "conky.h"
|
||||
#include "audacious.h"
|
||||
|
||||
/* access to this item array is synchronized */
|
||||
static audacious_t audacious_items;
|
||||
|
||||
|
@ -24,11 +24,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <bmp/dbus.hh>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include "conky.h"
|
||||
|
||||
#define DBUS_TYPE_G_STRING_VALUE_HASHTABLE \
|
||||
(dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
|
||||
|
||||
|
18
src/common.c
18
src/common.c
@ -25,12 +25,27 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "conky.h"
|
||||
#include "fs.h"
|
||||
#include "logging.h"
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <pthread.h>
|
||||
|
||||
/* check for OS and include appropriate headers */
|
||||
#if defined(__linux__)
|
||||
#include "linux.h"
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#include "freebsd.h"
|
||||
#elif defined(__OpenBSD__)
|
||||
#include "openbsd.h"
|
||||
#endif
|
||||
|
||||
/* OS specific prototypes to be implemented by linux.c & Co. */
|
||||
void update_entropy(void);
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
// use our own strndup() if it's not available
|
||||
char *strndup(const char *s, size_t n)
|
||||
@ -183,7 +198,7 @@ void free_dns_data(void)
|
||||
|
||||
//static double last_dns_update;
|
||||
|
||||
void update_dns_data(void)
|
||||
static void update_dns_data(void)
|
||||
{
|
||||
FILE *fp;
|
||||
char line[256];
|
||||
@ -258,6 +273,7 @@ static double last_meminfo_update;
|
||||
static double last_fs_update;
|
||||
|
||||
unsigned long long need_mask;
|
||||
int no_buffers;
|
||||
|
||||
#define NEED(a) ((need_mask & (1 << a)) && ((info.mask & (1 << a)) == 0))
|
||||
|
||||
|
53
src/common.h
53
src/common.h
@ -1,5 +1,8 @@
|
||||
#ifndef COMMON_H_
|
||||
#define COMMON_H_
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
int check_mount(char *s);
|
||||
void update_diskio(void);
|
||||
@ -9,8 +12,10 @@ void update_meminfo(void);
|
||||
void update_net_stats(void);
|
||||
void update_cpu_usage(void);
|
||||
void update_total_processes(void);
|
||||
void update_uname(void);
|
||||
void update_running_processes(void);
|
||||
void update_i8k(void);
|
||||
void update_stuff(void);
|
||||
char get_freq(char *, size_t, const char *, int, unsigned int);
|
||||
void get_freq_dynamic(char *, size_t, const char *, int);
|
||||
char get_voltage(char *, size_t, const char *, int, unsigned int); /* ptarjan */
|
||||
@ -19,6 +24,48 @@ void update_top(void);
|
||||
void free_all_processes(void);
|
||||
struct process *get_first_process(void);
|
||||
void get_cpu_count(void);
|
||||
double get_time(void);
|
||||
|
||||
FILE *open_file(const char *, int *);
|
||||
void variable_substitute(const char *s, char *dest, unsigned int n);
|
||||
|
||||
void format_seconds(char *buf, unsigned int n, long t);
|
||||
void format_seconds_short(char *buf, unsigned int n, long t);
|
||||
|
||||
#ifdef X11
|
||||
void update_x11info(void);
|
||||
#endif
|
||||
|
||||
int round_to_int(float);
|
||||
|
||||
extern unsigned long long need_mask;
|
||||
extern int no_buffers;
|
||||
|
||||
struct dns_data {
|
||||
int nscount;
|
||||
char **ns_list;
|
||||
};
|
||||
void free_dns_data(void);
|
||||
|
||||
struct net_stat {
|
||||
const char *dev;
|
||||
int up;
|
||||
long long last_read_recv, last_read_trans;
|
||||
long long recv, trans;
|
||||
double recv_speed, trans_speed;
|
||||
struct sockaddr addr;
|
||||
char* addrs;
|
||||
double net_rec[15], net_trans[15];
|
||||
// wireless extensions
|
||||
char essid[32];
|
||||
char bitrate[16];
|
||||
char mode[16];
|
||||
int link_qual;
|
||||
int link_qual_max;
|
||||
char ap[18];
|
||||
};
|
||||
void clear_net_stats(void);
|
||||
struct net_stat *get_net_stat(const char *);
|
||||
|
||||
int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
|
||||
int *divisor, char *devtype);
|
||||
@ -44,4 +91,4 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item);
|
||||
int get_battery_perct(const char *bat);
|
||||
int get_battery_perct_bar(const char *bat);
|
||||
|
||||
#endif /*COMMON_H_*/
|
||||
#endif /* _COMMON_H */
|
||||
|
68
src/conky.c
68
src/conky.c
@ -25,8 +25,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "text_object.h"
|
||||
#include "conky.h"
|
||||
#include "common.h"
|
||||
#include <stdarg.h>
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
@ -40,6 +42,7 @@
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#ifdef X11
|
||||
#include "x11.h"
|
||||
#include <X11/Xutil.h>
|
||||
#ifdef HAVE_XDAMAGE
|
||||
#include <X11/extensions/Xdamage.h>
|
||||
@ -55,6 +58,35 @@
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
|
||||
/* local headers */
|
||||
#include "build.h"
|
||||
#include "diskio.h"
|
||||
#include "fs.h"
|
||||
#include "logging.h"
|
||||
#include "mixer.h"
|
||||
#include "mail.h"
|
||||
#include "mboxscan.h"
|
||||
#include "temphelper.h"
|
||||
#include "top.h"
|
||||
|
||||
/* check for OS and include appropriate headers */
|
||||
#if defined(__linux__)
|
||||
#include "linux.h"
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#include "freebsd.h"
|
||||
#elif defined(__OpenBSD__)
|
||||
#include "openbsd.h"
|
||||
#endif
|
||||
|
||||
/* FIXME: apm_getinfo is unused here. maybe it's meant for common.c */
|
||||
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
|
||||
|| defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
|
||||
int apm_getinfo(int fd, apm_info_t aip);
|
||||
char *get_apm_adapter(void);
|
||||
char *get_apm_battery_life(void);
|
||||
char *get_apm_battery_time(void);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
@ -66,10 +98,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "build.h"
|
||||
|
||||
#include "temphelper.h"
|
||||
|
||||
#ifndef S_ISSOCK
|
||||
#define S_ISSOCK(x) ((x & S_IFMT) == S_IFSOCK)
|
||||
#endif
|
||||
@ -81,10 +109,30 @@
|
||||
//#define SIGNAL_BLOCKING
|
||||
#undef SIGNAL_BLOCKING
|
||||
|
||||
/* debugging level */
|
||||
/* debugging level, used by logging.h */
|
||||
int global_debug_level = 0;
|
||||
|
||||
/* two strings for internal use */
|
||||
static char *tmpstring1, *tmpstring2;
|
||||
|
||||
/* variables holding various config settings */
|
||||
int short_units;
|
||||
int cpu_separate;
|
||||
static int use_spacer;
|
||||
int top_cpu, top_mem;
|
||||
#define TO_X 1
|
||||
#define TO_STDOUT 2
|
||||
static int output_methods;
|
||||
static volatile int g_signal_pending;
|
||||
/* Update interval */
|
||||
static double update_interval;
|
||||
|
||||
|
||||
/* prototypes for internally used functions */
|
||||
static void signal_handler(int);
|
||||
static void print_version(void) __attribute__((noreturn));
|
||||
static void reload_config(void);
|
||||
static void clean_up(void);
|
||||
|
||||
static void print_version(void)
|
||||
{
|
||||
@ -339,6 +387,10 @@ static void load_fonts(void)
|
||||
|
||||
#endif /* X11 */
|
||||
|
||||
/* struct that has all info to be shared between
|
||||
* instances of the same text object */
|
||||
struct information info;
|
||||
|
||||
/* default config file */
|
||||
static char *current_config;
|
||||
|
||||
@ -6931,7 +6983,7 @@ static void main_loop(void)
|
||||
static void load_config_file(const char *);
|
||||
|
||||
/* reload the config file */
|
||||
void reload_config(void)
|
||||
static void reload_config(void)
|
||||
{
|
||||
timed_thread_destroy_registered_threads();
|
||||
|
||||
@ -7034,7 +7086,7 @@ void reload_config(void)
|
||||
}
|
||||
}
|
||||
|
||||
void clean_up(void)
|
||||
static void clean_up(void)
|
||||
{
|
||||
timed_thread_destroy_registered_threads();
|
||||
|
||||
@ -8399,7 +8451,7 @@ int main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void signal_handler(int sig)
|
||||
static void signal_handler(int sig)
|
||||
{
|
||||
/* signal handler is light as a feather, as it should be.
|
||||
* we will poll g_signal_pending with each loop of conky
|
||||
|
285
src/conky.h
285
src/conky.h
@ -28,6 +28,10 @@
|
||||
#ifndef _conky_h_
|
||||
#define _conky_h_
|
||||
|
||||
#include "config.h" /* defines */
|
||||
#include "common.h" /* at least for struct dns_data */
|
||||
#include <sys/utsname.h> /* struct uname_s */
|
||||
|
||||
#if defined(HAS_MCHECK_H)
|
||||
#include <mcheck.h>
|
||||
#endif /* HAS_MCHECK_H */
|
||||
@ -39,161 +43,20 @@
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
#include "config.h"
|
||||
#include <sys/utsname.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <langinfo.h>
|
||||
#include <wchar.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#if !defined(__GNUC__)
|
||||
# define __attribute__(x) /* nothing */
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#include "freebsd.h"
|
||||
#endif /* __FreeBSD__ || __FreeBSD_kernel__ */
|
||||
|
||||
#if defined(__OpenBSD__)
|
||||
#include "openbsd.h"
|
||||
#endif /* __OpenBSD__ */
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
// use our own strndup() if it's not available
|
||||
char *strndup(const char *s, size_t n);
|
||||
#endif /* HAVE_STRNDUP */
|
||||
|
||||
#ifdef AUDACIOUS
|
||||
#include "audacious.h"
|
||||
#endif
|
||||
|
||||
#ifdef XMMS2
|
||||
#include <xmmsclient/xmmsclient.h>
|
||||
#endif
|
||||
|
||||
#ifdef RSS
|
||||
#include "rss.h"
|
||||
#endif
|
||||
|
||||
#ifdef EVE
|
||||
#include "eve.h"
|
||||
#endif
|
||||
|
||||
#ifdef SMAPI
|
||||
#include "smapi.h"
|
||||
#endif
|
||||
|
||||
#ifdef NVIDIA
|
||||
#include "nvidia.h"
|
||||
#endif
|
||||
|
||||
#include "mboxscan.h"
|
||||
#include "timed_thread.h"
|
||||
#include "top.h"
|
||||
|
||||
#define DEFAULT_TEXT_BUFFER_SIZE 256
|
||||
extern unsigned int text_buffer_size;
|
||||
|
||||
/* maximum number of special things, e.g. fonts, offsets, aligns, etc. */
|
||||
#define MAX_SPECIALS_DEFAULT 512
|
||||
|
||||
/* maximum size of config TEXT buffer, i.e. below TEXT line. */
|
||||
#define MAX_USER_TEXT_DEFAULT 16384
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#define ERR(...) { \
|
||||
fprintf(stderr, PACKAGE_NAME": "); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
}
|
||||
|
||||
/* critical error */
|
||||
#define CRIT_ERR(...) \
|
||||
{ ERR(__VA_ARGS__); exit(EXIT_FAILURE); }
|
||||
|
||||
/* debugging output */
|
||||
extern int global_debug_level;
|
||||
#define __DBGP(level, ...) \
|
||||
if (global_debug_level > level) { \
|
||||
fprintf(stderr, "DEBUG(%d) [" __FILE__ ":%d]: ", level, __LINE__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
}
|
||||
#define DBGP(...) __DBGP(0, __VA_ARGS__)
|
||||
#define DBGP2(...) __DBGP(1, __VA_ARGS__)
|
||||
|
||||
struct net_stat {
|
||||
const char *dev;
|
||||
int up;
|
||||
long long last_read_recv, last_read_trans;
|
||||
long long recv, trans;
|
||||
double recv_speed, trans_speed;
|
||||
struct sockaddr addr;
|
||||
char* addrs;
|
||||
double net_rec[15], net_trans[15];
|
||||
// wireless extensions
|
||||
char essid[32];
|
||||
char bitrate[16];
|
||||
char mode[16];
|
||||
int link_qual;
|
||||
int link_qual_max;
|
||||
char ap[18];
|
||||
};
|
||||
|
||||
struct dns_data {
|
||||
int nscount;
|
||||
char **ns_list;
|
||||
};
|
||||
|
||||
struct fs_stat {
|
||||
char path[DEFAULT_TEXT_BUFFER_SIZE];
|
||||
char type[DEFAULT_TEXT_BUFFER_SIZE];
|
||||
long long size;
|
||||
long long avail;
|
||||
long long free;
|
||||
char set;
|
||||
};
|
||||
|
||||
#include "diskio.h"
|
||||
|
||||
struct mail_s { // for imap and pop3
|
||||
unsigned long unseen;
|
||||
unsigned long messages;
|
||||
unsigned long used;
|
||||
unsigned long quota;
|
||||
unsigned long port;
|
||||
unsigned int retries;
|
||||
float interval;
|
||||
double last_update;
|
||||
char host[128];
|
||||
char user[128];
|
||||
char pass[128];
|
||||
char command[1024];
|
||||
char folder[128];
|
||||
timed_thread *p_timed_thread;
|
||||
char secure;
|
||||
};
|
||||
|
||||
/* struct cpu_stat {
|
||||
unsigned int user, nice, system, idle, iowait, irq, softirq;
|
||||
int cpu_avg_samples;
|
||||
}; */
|
||||
|
||||
#ifdef MPD
|
||||
#include "mpd.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOC
|
||||
#include "moc.h"
|
||||
#endif
|
||||
|
||||
#ifdef XMMS2
|
||||
#include "xmms2.h"
|
||||
#endif
|
||||
/* headers of optional features
|
||||
* include them here, so we don't need to run the check
|
||||
* in every code file optionally using the feature
|
||||
*/
|
||||
|
||||
#ifdef AUDACIOUS
|
||||
#include "audacious.h"
|
||||
@ -203,7 +66,46 @@ struct mail_s { // for imap and pop3
|
||||
#include "bmpx.h"
|
||||
#endif
|
||||
|
||||
void update_entropy(void);
|
||||
#ifdef EVE
|
||||
#include "eve.h"
|
||||
#endif
|
||||
|
||||
#ifdef HDDTEMP
|
||||
#include "hddtemp.h"
|
||||
#endif /* HDDTEMP */
|
||||
|
||||
#ifdef MOC
|
||||
#include "moc.h"
|
||||
#endif
|
||||
|
||||
#ifdef MPD
|
||||
#include "mpd.h"
|
||||
#endif
|
||||
|
||||
#ifdef NVIDIA
|
||||
#include "nvidia.h"
|
||||
#endif
|
||||
|
||||
#ifdef RSS
|
||||
#include "rss.h"
|
||||
#endif
|
||||
|
||||
#ifdef SMAPI
|
||||
#include "smapi.h"
|
||||
#endif
|
||||
|
||||
#ifdef TCP_PORT_MONITOR
|
||||
#include "tcp-portmon.h"
|
||||
#endif
|
||||
|
||||
#ifdef XMMS2
|
||||
#include "xmms2.h"
|
||||
#endif
|
||||
|
||||
/* 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;
|
||||
|
||||
struct entropy_s {
|
||||
unsigned int entropy_avail;
|
||||
unsigned int poolsize;
|
||||
@ -233,10 +135,6 @@ struct x11_info {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef TCP_PORT_MONITOR
|
||||
#include "tcp-portmon.h"
|
||||
#endif
|
||||
|
||||
enum {
|
||||
INFO_CPU = 0,
|
||||
INFO_MAIL = 1,
|
||||
@ -292,24 +190,21 @@ enum {
|
||||
#endif
|
||||
};
|
||||
|
||||
/* get_battery_stuff() item selector */
|
||||
/* get_battery_stuff() item selector
|
||||
* needed by conky.c, linux.c and freebsd.c */
|
||||
enum {
|
||||
BATTERY_STATUS,
|
||||
BATTERY_TIME
|
||||
};
|
||||
|
||||
/* if_up strictness selector */
|
||||
/* if_up strictness selector
|
||||
* needed by conky.c and linux.c (and potentially others) */
|
||||
enum {
|
||||
IFUP_UP,
|
||||
IFUP_LINK,
|
||||
IFUP_ADDR
|
||||
} ifup_strictness;
|
||||
|
||||
/* Update interval */
|
||||
double update_interval;
|
||||
|
||||
volatile int g_signal_pending;
|
||||
|
||||
struct information {
|
||||
unsigned int mask;
|
||||
|
||||
@ -377,6 +272,7 @@ struct information {
|
||||
unsigned int diskio_write_value;
|
||||
};
|
||||
|
||||
/* needed by linux.c and top.c -> outsource somewhere */
|
||||
enum {
|
||||
/* set to true if kernel uses "long" format for /proc/stats */
|
||||
KFLAG_IS_LONGSTAT = 0x01,
|
||||
@ -386,84 +282,27 @@ enum {
|
||||
/* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
|
||||
/* KFLAG_NEXT_ONE = 0x04 */
|
||||
};
|
||||
|
||||
#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
|
||||
|
||||
#define TO_X 1
|
||||
#define TO_STDOUT 2
|
||||
int output_methods;
|
||||
|
||||
int top_cpu;
|
||||
int top_mem;
|
||||
|
||||
int use_spacer;
|
||||
/* defined in conky.c, needed by top.c */
|
||||
extern int top_cpu, top_mem;
|
||||
|
||||
enum spacer_opts { NO_SPACER = 0, LEFT_SPACER, RIGHT_SPACER };
|
||||
|
||||
char *tmpstring1;
|
||||
char *tmpstring2;
|
||||
/* defined in conky.c, needed by top.c */
|
||||
extern int cpu_separate;
|
||||
|
||||
#ifdef X11
|
||||
#include "x11.h"
|
||||
#endif /* X11 */
|
||||
/* struct that has all info to be shared between
|
||||
* instances of the same text object */
|
||||
extern struct information info;
|
||||
|
||||
int cpu_separate;
|
||||
int short_units;
|
||||
|
||||
/* struct that has all info */
|
||||
struct information info;
|
||||
|
||||
void signal_handler(int);
|
||||
void reload_config(void);
|
||||
void clean_up(void);
|
||||
|
||||
void update_uname(void);
|
||||
double get_time(void);
|
||||
FILE *open_file(const char *file, int *reported);
|
||||
void variable_substitute(const char *s, char *dest, unsigned int n);
|
||||
void format_seconds(char *buf, unsigned int n, long t);
|
||||
void format_seconds_short(char *buf, unsigned int n, long t);
|
||||
struct net_stat *get_net_stat(const char *dev);
|
||||
void clear_net_stats(void);
|
||||
void free_dns_data(void);
|
||||
void update_dns_data(void);
|
||||
/* defined in users.c */
|
||||
void update_users(void);
|
||||
|
||||
#ifdef X11
|
||||
void update_x11info(void);
|
||||
#endif
|
||||
|
||||
void update_stuff(void);
|
||||
|
||||
int round_to_int(float f);
|
||||
|
||||
extern unsigned long long need_mask;
|
||||
|
||||
/* defined in conky.c */
|
||||
extern double current_update_time, last_update_time;
|
||||
|
||||
extern int no_buffers;
|
||||
|
||||
#if defined(__linux__)
|
||||
#include "linux.h"
|
||||
#endif
|
||||
|
||||
#include "fs.h"
|
||||
#include "mixer.h"
|
||||
#include "mail.h"
|
||||
|
||||
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
|
||||
|| defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
|
||||
int apm_getinfo(int fd, apm_info_t aip);
|
||||
char *get_apm_adapter(void);
|
||||
char *get_apm_battery_life(void);
|
||||
char *get_apm_battery_time(void);
|
||||
#endif
|
||||
|
||||
#ifdef HDDTEMP
|
||||
#include "hddtemp.h"
|
||||
#endif /* HDDTEMP */
|
||||
|
||||
#endif
|
||||
|
@ -26,7 +26,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "config.h"
|
||||
#include "conky.h" /* text_buffer_size */
|
||||
#include "logging.h"
|
||||
#include "diskio.h"
|
||||
#include "common.h"
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
/* The following ifdefs were adapted from gkrellm */
|
||||
#include <linux/major.h>
|
||||
|
2
src/fs.c
2
src/fs.c
@ -26,6 +26,8 @@
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "fs.h"
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
18
src/fs.h
18
src/fs.h
@ -1,8 +1,20 @@
|
||||
#ifndef FS_H_
|
||||
#define FS_H_
|
||||
#ifndef _FS_H
|
||||
#define _FS_H
|
||||
|
||||
#include "conky.h" /* DEFAULT_TEXT_BUFFER_SIZE */
|
||||
|
||||
/* needed here and by fs.c */
|
||||
struct fs_stat {
|
||||
char path[DEFAULT_TEXT_BUFFER_SIZE];
|
||||
char type[DEFAULT_TEXT_BUFFER_SIZE];
|
||||
long long size;
|
||||
long long avail;
|
||||
long long free;
|
||||
char set;
|
||||
};
|
||||
|
||||
void update_fs_stats(void);
|
||||
struct fs_stat *prepare_fs_stat(const char *path);
|
||||
void clear_fs_stats(void);
|
||||
|
||||
#endif /*FS_H_*/
|
||||
#endif /* _FS_H */
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -27,6 +27,9 @@
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "common.h"
|
||||
#include "linux.h"
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef LINUX_H_
|
||||
#define LINUX_H_
|
||||
#ifndef _LINUX_H
|
||||
#define _LINUX_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@ -38,4 +38,4 @@ void update_gateway_info(void);
|
||||
enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME };
|
||||
void get_powerbook_batt_info(char *, size_t, int);
|
||||
|
||||
#endif /*LINUX_H_*/
|
||||
#endif /* _LINUX_H */
|
||||
|
51
src/logging.h
Normal file
51
src/logging.h
Normal file
@ -0,0 +1,51 @@
|
||||
/* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* 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
|
||||
* Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* (see AUTHORS)
|
||||
* 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifndef _LOGGING_H
|
||||
#define _LOGGING_H
|
||||
|
||||
#define ERR(...) { \
|
||||
fprintf(stderr, PACKAGE_NAME": "); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
}
|
||||
|
||||
/* critical error */
|
||||
#define CRIT_ERR(...) \
|
||||
{ ERR(__VA_ARGS__); exit(EXIT_FAILURE); }
|
||||
|
||||
/* debugging output */
|
||||
extern int global_debug_level;
|
||||
#define __DBGP(level, ...) \
|
||||
if (global_debug_level > level) { \
|
||||
fprintf(stderr, "DEBUG(%d) [" __FILE__ ":%d]: ", level, __LINE__); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
fprintf(stderr, "\n"); \
|
||||
}
|
||||
#define DBGP(...) __DBGP(0, __VA_ARGS__)
|
||||
#define DBGP2(...) __DBGP(1, __VA_ARGS__)
|
||||
|
||||
#endif /* _LOGGING_H */
|
17
src/mail.c
17
src/mail.c
@ -25,8 +25,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "conky.h"
|
||||
#include "common.h"
|
||||
#include "logging.h"
|
||||
#include "mail.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
@ -34,6 +44,13 @@
|
||||
#include <errno.h>
|
||||
#include <termios.h>
|
||||
|
||||
/* MAX() is defined by a header included from conky.h
|
||||
* maybe once this is not true anymore, so have an alternative
|
||||
* waiting to drop in.
|
||||
*
|
||||
* #define MAX(a, b) ((a > b) ? a : b)
|
||||
*/
|
||||
|
||||
char *current_mail_spool;
|
||||
|
||||
void update_mail_count(struct local_mail_s *mail)
|
||||
|
26
src/mail.h
26
src/mail.h
@ -1,8 +1,28 @@
|
||||
#ifndef _MAIL_H_
|
||||
#define _MAIL_H_
|
||||
#ifndef _MAIL_H
|
||||
#define _MAIL_H
|
||||
|
||||
#include "timed_thread.h"
|
||||
|
||||
extern char *current_mail_spool;
|
||||
|
||||
struct mail_s { // for imap and pop3
|
||||
unsigned long unseen;
|
||||
unsigned long messages;
|
||||
unsigned long used;
|
||||
unsigned long quota;
|
||||
unsigned long port;
|
||||
unsigned int retries;
|
||||
float interval;
|
||||
double last_update;
|
||||
char host[128];
|
||||
char user[128];
|
||||
char pass[128];
|
||||
char command[1024];
|
||||
char folder[128];
|
||||
timed_thread *p_timed_thread;
|
||||
char secure;
|
||||
};
|
||||
|
||||
struct local_mail_s {
|
||||
char *box;
|
||||
int mail_count;
|
||||
@ -21,4 +41,4 @@ struct mail_s *parse_mail_args(char type, const char *arg);
|
||||
void *imap_thread(void *arg);
|
||||
void *pop3_thread(void *arg);
|
||||
|
||||
#endif /* _MAIL_H_ */
|
||||
#endif /* _MAIL_H */
|
||||
|
@ -26,6 +26,8 @@
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "mail.h"
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "moc.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
|
||||
void init_mpd_stats(struct mpd_s *mpd)
|
||||
{
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "prss.h"
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
@ -18,8 +18,15 @@
|
||||
* USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include "conky.h" /* text_buffer_size, PACKAGE_NAME, maybe more */
|
||||
#include "smapi.h"
|
||||
#include "logging.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define SYS_SMAPI_PATH "/sys/devices/platform/smapi"
|
||||
|
||||
|
@ -19,11 +19,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SMAPI_H
|
||||
#define SMAPI_H
|
||||
|
||||
#include "conky.h"
|
||||
#include <sys/stat.h>
|
||||
#ifndef _SMAPI_H
|
||||
#define _SMAPI_H
|
||||
|
||||
int smapi_bat_installed(int);
|
||||
|
||||
@ -37,4 +34,4 @@ char *smapi_get_bat_str(int, const char *);
|
||||
int smapi_get_bat_int(int, const char *);
|
||||
char *smapi_get_bat_val(const char *);
|
||||
|
||||
#endif /* SMAPI_H */
|
||||
#endif /* _SMAPI_H */
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
/* doesn't work, feel free to finish this */
|
||||
#include "conky.h"
|
||||
#include "common.h"
|
||||
#include <kstat.h>
|
||||
|
||||
static kstat_ctl_t *kstat;
|
||||
|
@ -18,6 +18,7 @@
|
||||
*
|
||||
*/
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "tcp-portmon.h"
|
||||
#include "libtcp-portmon.h"
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
*
|
||||
*/
|
||||
#include "text_object.h"
|
||||
#include "conky.h" /* not as worse: only for the printing macros */
|
||||
#include "logging.h"
|
||||
|
||||
/* text_object_list
|
||||
*
|
||||
|
@ -35,6 +35,7 @@
|
||||
#endif
|
||||
|
||||
#include "mail.h" /* local_mail_s */
|
||||
#include "fs.h" /* struct fs_stat */
|
||||
|
||||
#ifdef NVIDIA
|
||||
#include "nvidia.h" /* nvidia_s */
|
||||
|
12
src/x11.c
12
src/x11.c
@ -25,25 +25,26 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "common.h"
|
||||
|
||||
#ifdef X11
|
||||
#include "x11.h"
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xmd.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#ifdef XFT
|
||||
#include <X11/Xft/Xft.h>
|
||||
int use_xft = 0;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XDBE
|
||||
int use_xdbe;
|
||||
#endif
|
||||
|
||||
#ifdef XFT
|
||||
int use_xft = 0;
|
||||
#endif
|
||||
|
||||
/* some basic X11 stuff */
|
||||
Display *display;
|
||||
int display_width;
|
||||
@ -560,4 +561,3 @@ void update_x11info(void)
|
||||
current_info->x11.monitor.number = XScreenCount(display);
|
||||
current_info->x11.monitor.current = XDefaultScreen(display);
|
||||
}
|
||||
#endif /* X11 */
|
||||
|
Loading…
Reference in New Issue
Block a user