mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
parent
d7838b87bf
commit
043cf686c6
3
.gitignore
vendored
3
.gitignore
vendored
@ -12,7 +12,6 @@ config.status
|
||||
config.sub
|
||||
configure
|
||||
configure.ac
|
||||
compile
|
||||
depcomp
|
||||
install-sh
|
||||
libtool
|
||||
@ -31,8 +30,6 @@ src/build.h
|
||||
src/config.h
|
||||
src/defconfig.h
|
||||
src/*.o
|
||||
lua/.deps/
|
||||
lua/.libs/
|
||||
conky-*.tar.*
|
||||
doc/*.html
|
||||
doc/*.mxml
|
||||
|
@ -152,13 +152,6 @@ conky_SOURCES = \
|
||||
conky.h \
|
||||
core.c \
|
||||
core.h \
|
||||
obj_create.c \
|
||||
obj_create.h \
|
||||
obj_display.c \
|
||||
obj_display.h \
|
||||
obj_destroy.c \
|
||||
obj_destroy.h \
|
||||
structs.h \
|
||||
$(freebsd) \
|
||||
fs.c \
|
||||
$(hddtemp) \
|
||||
|
@ -28,9 +28,7 @@
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
*
|
||||
*/
|
||||
|
||||
#include "conky.h"
|
||||
#include "core.h"
|
||||
#include "logging.h"
|
||||
#ifdef X11
|
||||
#include "x11.h"
|
||||
@ -40,46 +38,49 @@
|
||||
#define CONST_8_TO_5_BITS 0.12156862745098
|
||||
#define CONST_8_TO_6_BITS 0.247058823529412
|
||||
|
||||
static void set_up_gradient(conky_context *ctx)
|
||||
static short colour_depth = 0;
|
||||
static long redmask, greenmask, bluemask;
|
||||
|
||||
static void set_up_gradient(void)
|
||||
{
|
||||
int i;
|
||||
#ifdef X11
|
||||
if (ctx->output_methods & TO_X) {
|
||||
ctx->colour_depth = DisplayPlanes(display, screen);
|
||||
if (output_methods & TO_X) {
|
||||
colour_depth = DisplayPlanes(display, screen);
|
||||
} else
|
||||
#endif /* X11 */
|
||||
{
|
||||
ctx->colour_depth = 16;
|
||||
colour_depth = 16;
|
||||
}
|
||||
if (ctx->colour_depth != 24 && ctx->colour_depth != 16) {
|
||||
if (colour_depth != 24 && colour_depth != 16) {
|
||||
NORM_ERR("using non-standard colour depth, gradients may look like a "
|
||||
"lolly-pop");
|
||||
}
|
||||
|
||||
ctx->redmask = 0;
|
||||
ctx->greenmask = 0;
|
||||
ctx->bluemask = 0;
|
||||
for (i = (ctx->colour_depth / 3) - 1; i >= 0; i--) {
|
||||
ctx->redmask |= 1 << i;
|
||||
ctx->greenmask |= 1 << i;
|
||||
ctx->bluemask |= 1 << i;
|
||||
redmask = 0;
|
||||
greenmask = 0;
|
||||
bluemask = 0;
|
||||
for (i = (colour_depth / 3) - 1; i >= 0; i--) {
|
||||
redmask |= 1 << i;
|
||||
greenmask |= 1 << i;
|
||||
bluemask |= 1 << i;
|
||||
}
|
||||
if (ctx->colour_depth % 3 == 1) {
|
||||
ctx->greenmask |= 1 << (ctx->colour_depth / 3);
|
||||
if (colour_depth % 3 == 1) {
|
||||
greenmask |= 1 << (colour_depth / 3);
|
||||
}
|
||||
ctx->redmask = ctx->redmask << (2 * ctx->colour_depth / 3 + ctx->colour_depth % 3);
|
||||
ctx->greenmask = ctx->greenmask << (ctx->colour_depth / 3);
|
||||
redmask = redmask << (2 * colour_depth / 3 + colour_depth % 3);
|
||||
greenmask = greenmask << (colour_depth / 3);
|
||||
}
|
||||
|
||||
/* adjust colour values depending on colour depth */
|
||||
unsigned int adjust_colours(conky_context *ctx, unsigned int colour)
|
||||
unsigned int adjust_colours(unsigned int colour)
|
||||
{
|
||||
double r, g, b;
|
||||
|
||||
if (ctx->colour_depth == 0) {
|
||||
set_up_gradient(ctx);
|
||||
if (colour_depth == 0) {
|
||||
set_up_gradient();
|
||||
}
|
||||
if (ctx->colour_depth == 16) {
|
||||
if (colour_depth == 16) {
|
||||
r = (colour & 0xff0000) >> 16;
|
||||
g = (colour & 0xff00) >> 8;
|
||||
b = colour & 0xff;
|
||||
@ -91,25 +92,25 @@ unsigned int adjust_colours(conky_context *ctx, unsigned int colour)
|
||||
}
|
||||
|
||||
/* this function returns the next colour between two colours for a gradient */
|
||||
unsigned long *do_gradient(conky_context *ctx, int width, unsigned long first_colour, unsigned long last_colour)
|
||||
unsigned long *do_gradient(int width, unsigned long first_colour, unsigned long last_colour)
|
||||
{
|
||||
int red1, green1, blue1; // first colour
|
||||
int red2, green2, blue2; // last colour
|
||||
int reddiff, greendiff, bluediff; // difference
|
||||
short redshift = (2 * ctx->colour_depth / 3 + ctx->colour_depth % 3);
|
||||
short greenshift = (ctx->colour_depth / 3);
|
||||
short redshift = (2 * colour_depth / 3 + colour_depth % 3);
|
||||
short greenshift = (colour_depth / 3);
|
||||
unsigned long *colours = malloc(width * sizeof(unsigned long));
|
||||
int i;
|
||||
|
||||
if (ctx->colour_depth == 0) {
|
||||
set_up_gradient(ctx);
|
||||
if (colour_depth == 0) {
|
||||
set_up_gradient();
|
||||
}
|
||||
red1 = (first_colour & ctx->redmask) >> redshift;
|
||||
green1 = (first_colour & ctx->greenmask) >> greenshift;
|
||||
blue1 = first_colour & ctx->bluemask;
|
||||
red2 = (last_colour & ctx->redmask) >> redshift;
|
||||
green2 = (last_colour & ctx->greenmask) >> greenshift;
|
||||
blue2 = last_colour & ctx->bluemask;
|
||||
red1 = (first_colour & redmask) >> redshift;
|
||||
green1 = (first_colour & greenmask) >> greenshift;
|
||||
blue1 = first_colour & bluemask;
|
||||
red2 = (last_colour & redmask) >> redshift;
|
||||
green2 = (last_colour & greenmask) >> greenshift;
|
||||
blue2 = last_colour & bluemask;
|
||||
reddiff = abs(red1 - red2);
|
||||
greendiff = abs(green1 - green2);
|
||||
bluediff = abs(blue1 - blue2);
|
||||
@ -149,14 +150,14 @@ unsigned long *do_gradient(conky_context *ctx, int width, unsigned long first_co
|
||||
if (blue3 < 0) {
|
||||
blue3 = 0;
|
||||
}
|
||||
if (red3 > ctx->bluemask) {
|
||||
red3 = ctx->bluemask;
|
||||
if (red3 > bluemask) {
|
||||
red3 = bluemask;
|
||||
}
|
||||
if (green3 > ctx->bluemask) {
|
||||
green3 = ctx->bluemask;
|
||||
if (green3 > bluemask) {
|
||||
green3 = bluemask;
|
||||
}
|
||||
if (blue3 > ctx->bluemask) {
|
||||
blue3 = ctx->bluemask;
|
||||
if (blue3 > bluemask) {
|
||||
blue3 = bluemask;
|
||||
}
|
||||
colours[i] = (red3 << redshift) | (green3 << greenshift) | blue3;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
#ifndef _COLOURS_H
|
||||
#define _COLOURS_H
|
||||
|
||||
unsigned int adjust_colours(conky_context *ctx, unsigned int);
|
||||
unsigned long *do_gradient(conky_context *ctx, int, unsigned long, unsigned long);
|
||||
unsigned int adjust_colours(unsigned int);
|
||||
unsigned long *do_gradient(int, unsigned long, unsigned long);
|
||||
|
||||
#endif /* _COLOURS_H */
|
||||
|
58
src/common.c
58
src/common.c
@ -30,7 +30,7 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "conky.h"
|
||||
#include "fs.h"
|
||||
#include "logging.h"
|
||||
#include <ctype.h>
|
||||
@ -84,9 +84,9 @@ char *strndup(const char *s, size_t n)
|
||||
}
|
||||
#endif /* HAVE_STRNDUP */
|
||||
|
||||
void update_uname(conky_context *ctx)
|
||||
void update_uname(void)
|
||||
{
|
||||
uname(&ctx->info.uname_s);
|
||||
uname(&info.uname_s);
|
||||
}
|
||||
|
||||
double get_time(void)
|
||||
@ -111,7 +111,7 @@ void to_real_path(char *dest, const char *source)
|
||||
NORM_ERR("$HOME environment variable doesn't exist");
|
||||
strncpy(dest, source, DEFAULT_TEXT_BUFFER_SIZE);
|
||||
}
|
||||
} else if (dest != source) { //see changelog 2009-06-29 if you doubt that this check is necessary
|
||||
} else if (dest != source) { //see changelog 2009-06-29 if you doubt that this check is necessary
|
||||
strncpy(dest, source, DEFAULT_TEXT_BUFFER_SIZE);
|
||||
}
|
||||
}
|
||||
@ -299,10 +299,10 @@ END_TRUE:
|
||||
return 1;
|
||||
}
|
||||
|
||||
void free_dns_data(conky_context *ctx)
|
||||
void free_dns_data(void)
|
||||
{
|
||||
int i;
|
||||
struct dns_data *data = &ctx->info.nameserver_info;
|
||||
struct dns_data *data = &info.nameserver_info;
|
||||
for (i = 0; i < data->nscount; i++)
|
||||
free(data->ns_list[i]);
|
||||
if (data->ns_list)
|
||||
@ -312,20 +312,20 @@ void free_dns_data(conky_context *ctx)
|
||||
|
||||
//static double last_dns_update;
|
||||
|
||||
static void update_dns_data(conky_context *ctx)
|
||||
static void update_dns_data(void)
|
||||
{
|
||||
FILE *fp;
|
||||
char line[256];
|
||||
struct dns_data *data = &ctx->info.nameserver_info;
|
||||
struct dns_data *data = &info.nameserver_info;
|
||||
|
||||
/* maybe updating too often causes higher load because of /etc lying on a real FS
|
||||
if (ctx->current_update_time - last_dns_update < 10.0)
|
||||
if (current_update_time - last_dns_update < 10.0)
|
||||
return;
|
||||
else
|
||||
last_dns_update = ctx->current_update_time;
|
||||
last_dns_update = current_update_time;
|
||||
*/
|
||||
|
||||
free_dns_data(ctx);
|
||||
free_dns_data();
|
||||
|
||||
if ((fp = fopen("/etc/resolv.conf", "r")) == NULL)
|
||||
return;
|
||||
@ -383,15 +383,21 @@ void format_seconds_short(char *buf, unsigned int n, long seconds)
|
||||
}
|
||||
}
|
||||
|
||||
#define NEED(a) ((need_mask & (1ULL << a)) && ((ctx->info.mask & (1ULL << a)) == 0))
|
||||
static double last_meminfo_update;
|
||||
static double last_fs_update;
|
||||
|
||||
void update_stuff(conky_context *ctx)
|
||||
unsigned long long need_mask;
|
||||
int no_buffers;
|
||||
|
||||
#define NEED(a) ((need_mask & (1ULL << a)) && ((info.mask & (1ULL << a)) == 0))
|
||||
|
||||
void update_stuff(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
ctx->info.mask = 0;
|
||||
info.mask = 0;
|
||||
|
||||
if (ctx->no_buffers) {
|
||||
if (no_buffers) {
|
||||
need_mask |= 1 << INFO_BUFFERS;
|
||||
}
|
||||
|
||||
@ -449,7 +455,7 @@ void update_stuff(conky_context *ctx)
|
||||
|
||||
#ifdef MOC
|
||||
if (NEED(INFO_MOC)) {
|
||||
run_moc_thread(ctx->info.music_player_interval * 100000);
|
||||
run_moc_thread(info.music_player_interval * 100000);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -476,17 +482,17 @@ void update_stuff(conky_context *ctx)
|
||||
}
|
||||
|
||||
if ((NEED(INFO_MEM) || NEED(INFO_BUFFERS) || NEED(INFO_TOP))
|
||||
&& ctx->current_update_time - ctx->last_meminfo_update > 6.9) {
|
||||
&& current_update_time - last_meminfo_update > 6.9) {
|
||||
update_meminfo();
|
||||
if (ctx->no_buffers) {
|
||||
ctx->info.mem -= ctx->info.bufmem;
|
||||
ctx->info.memeasyfree += ctx->info.bufmem;
|
||||
if (no_buffers) {
|
||||
info.mem -= info.bufmem;
|
||||
info.memeasyfree += info.bufmem;
|
||||
}
|
||||
ctx->last_meminfo_update = ctx->current_update_time;
|
||||
last_meminfo_update = current_update_time;
|
||||
}
|
||||
|
||||
|
||||
#ifdef X11
|
||||
if (NEED(INFO_X11) && ctx->x_initialised == YES) {
|
||||
if (NEED(INFO_X11) && x_initialised == YES) {
|
||||
update_x11info();
|
||||
}
|
||||
#endif
|
||||
@ -496,9 +502,9 @@ void update_stuff(conky_context *ctx)
|
||||
}
|
||||
|
||||
/* update_fs_stat() won't do anything if there aren't fs -things */
|
||||
if (NEED(INFO_FS) && ctx->current_update_time - ctx->last_fs_update > 12.9) {
|
||||
if (NEED(INFO_FS) && current_update_time - last_fs_update > 12.9) {
|
||||
update_fs_stats();
|
||||
ctx->last_fs_update = ctx->current_update_time;
|
||||
last_fs_update = current_update_time;
|
||||
}
|
||||
#ifdef TCP_PORT_MONITOR
|
||||
if (NEED(INFO_TCP_PORT_MONITOR)) {
|
||||
@ -517,7 +523,7 @@ void update_stuff(conky_context *ctx)
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
if (NEED(INFO_DNS)) {
|
||||
update_dns_data(ctx);
|
||||
update_dns_data();
|
||||
}
|
||||
#ifdef APCUPSD
|
||||
if (NEED(INFO_APCUPSD)) {
|
||||
|
13
src/common.h
13
src/common.h
@ -3,8 +3,6 @@
|
||||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
#include "structs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -18,10 +16,10 @@ void update_meminfo(void);
|
||||
void update_net_stats(void);
|
||||
void update_cpu_usage(void);
|
||||
void update_total_processes(void);
|
||||
void update_uname(conky_context *ctx);
|
||||
void update_uname(void);
|
||||
void update_running_processes(void);
|
||||
void update_i8k(void);
|
||||
void update_stuff(conky_context *ctx);
|
||||
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 */
|
||||
@ -54,7 +52,11 @@ unsigned int round_to_int(float);
|
||||
extern unsigned long long need_mask;
|
||||
extern int no_buffers;
|
||||
|
||||
void free_dns_data(conky_context *ctx);
|
||||
struct dns_data {
|
||||
int nscount;
|
||||
char **ns_list;
|
||||
};
|
||||
void free_dns_data(void);
|
||||
|
||||
struct net_stat {
|
||||
char *dev;
|
||||
@ -76,7 +78,6 @@ struct net_stat {
|
||||
char ap[18];
|
||||
};
|
||||
void clear_net_stats(void);
|
||||
void clear_cpu_stats(void);
|
||||
struct net_stat *get_net_stat(const char *dev, void *free_at_crash1, void *free_at_crash2);
|
||||
int interface_up(const char *dev);
|
||||
|
||||
|
6008
src/conky.c
6008
src/conky.c
File diff suppressed because it is too large
Load Diff
177
src/conky.h
177
src/conky.h
@ -33,6 +33,8 @@
|
||||
#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>
|
||||
@ -131,8 +133,45 @@ char *strndup(const char *s, size_t n);
|
||||
* 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;
|
||||
};
|
||||
|
||||
struct usr_info {
|
||||
char *names;
|
||||
char *times;
|
||||
char *terms;
|
||||
int number;
|
||||
};
|
||||
|
||||
struct gateway_info {
|
||||
char *iface;
|
||||
char *ip;
|
||||
int count;
|
||||
};
|
||||
|
||||
#ifdef X11
|
||||
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;
|
||||
};
|
||||
|
||||
int get_stippled_borders(void);
|
||||
|
||||
#endif /* X11 */
|
||||
|
||||
/* defined in conky.c */
|
||||
@ -145,6 +184,15 @@ long get_current_text_color(void);
|
||||
void set_updatereset(int);
|
||||
int get_updatereset(void);
|
||||
|
||||
struct conftree {
|
||||
char* string;
|
||||
struct conftree* horz_next;
|
||||
struct conftree* vert_next;
|
||||
struct conftree* back;
|
||||
};
|
||||
|
||||
char load_config_file(const char *);
|
||||
|
||||
char *get_global_text(void);
|
||||
extern long global_text_lines;
|
||||
|
||||
@ -154,6 +202,9 @@ struct conftree* conftree_add(struct conftree* previous, const char* newstring);
|
||||
|
||||
extern struct conftree *currentconffile;
|
||||
|
||||
#define MAX_TEMPLATES 10
|
||||
char **get_templates(void);
|
||||
|
||||
enum {
|
||||
INFO_CPU = 0,
|
||||
INFO_MAIL = 1,
|
||||
@ -227,6 +278,69 @@ enum {
|
||||
IFUP_ADDR
|
||||
} ifup_strictness;
|
||||
|
||||
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;
|
||||
|
||||
float *cpu_usage;
|
||||
/* struct cpu_stat cpu_summed; what the hell is this? */
|
||||
unsigned int cpu_count;
|
||||
int cpu_avg_samples;
|
||||
|
||||
int net_avg_samples;
|
||||
|
||||
int diskio_avg_samples;
|
||||
|
||||
float loadavg[3];
|
||||
|
||||
struct mail_s *mail;
|
||||
int mail_running;
|
||||
#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 gateway_info gw_info;
|
||||
struct dns_data nameserver_info;
|
||||
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;
|
||||
struct entropy_s entropy;
|
||||
double music_player_interval;
|
||||
|
||||
#ifdef X11
|
||||
struct x11_info x11;
|
||||
#endif
|
||||
|
||||
#ifdef APCUPSD
|
||||
APCUPSD_S apcupsd;
|
||||
#endif
|
||||
|
||||
short kflags; /* kernel settings, see enum KFLAG */
|
||||
};
|
||||
|
||||
#ifdef HAVE_LUA
|
||||
#include "llua.h"
|
||||
#endif /* HAVE_LUA */
|
||||
@ -241,16 +355,71 @@ enum {
|
||||
/* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
|
||||
/* KFLAG_NEXT_ONE = 0x04 */
|
||||
};
|
||||
#define KFLAG_SETON(a) ctx->info.kflags |= a
|
||||
#define KFLAG_SETOFF(a) ctx->info.kflags &= (~a)
|
||||
#define KFLAG_FLIP(a) ctx->info.kflags ^= a
|
||||
#define KFLAG_ISSET(a) ctx->info.kflags & a
|
||||
#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
|
||||
|
||||
/* 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;
|
||||
|
||||
/* defined in users.c */
|
||||
void update_users(void);
|
||||
|
||||
/* 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)));
|
||||
extern int inotify_fd;
|
||||
|
||||
/* defined in conky.c
|
||||
* evaluates 'text' and places the result in 'buffer'
|
||||
*/
|
||||
void evaluate(const 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;
|
||||
|
||||
/* just a wrapper for read_exec() defined in conky.c */
|
||||
void do_read_exec(const char *data, char *buf, const int size);
|
||||
|
||||
#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"
|
||||
|
||||
#define NOBATTERY 0
|
||||
|
||||
/* to get rid of 'unused variable' warnings */
|
||||
|
5627
src/core.c
5627
src/core.c
File diff suppressed because it is too large
Load Diff
55
src/core.h
55
src/core.h
@ -32,50 +32,25 @@
|
||||
#ifndef _CONKY_CORE_H_
|
||||
#define _CONKY_CORE_H_
|
||||
|
||||
#include "config.h" /* defines */
|
||||
#include "conky.h"
|
||||
|
||||
/* alignments */
|
||||
enum alignment {
|
||||
TOP_LEFT = 1,
|
||||
TOP_RIGHT,
|
||||
TOP_MIDDLE,
|
||||
BOTTOM_LEFT,
|
||||
BOTTOM_RIGHT,
|
||||
BOTTOM_MIDDLE,
|
||||
MIDDLE_LEFT,
|
||||
MIDDLE_RIGHT,
|
||||
NONE
|
||||
};
|
||||
struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
line, void **ifblock_opaque, void *free_at_crash);
|
||||
|
||||
size_t remove_comments(char *string);
|
||||
|
||||
int extract_variable_text_internal(struct text_object *retval, const char *const_p);
|
||||
|
||||
void free_text_objects(struct text_object *root, int internal);
|
||||
|
||||
#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 */
|
||||
|
||||
void read_exec(const char *data, char *buf, const int size);
|
||||
void set_default_configurations(conky_context *ctx);
|
||||
void set_update_interval(double interval);
|
||||
|
||||
/* update_text() generates new text and clears old text area */
|
||||
void update_text(conky_context *ctx);
|
||||
void update_text_area(conky_context *ctx);
|
||||
void draw_stuff(conky_context *ctx);
|
||||
char load_config_file(conky_context *ctx, const char *f);
|
||||
void extract_variable_text(conky_context *ctx, const char *p);
|
||||
|
||||
#ifdef X11
|
||||
void clear_text(conky_context *ctx, int exposures);
|
||||
enum alignment string_to_alignment(const char *s);
|
||||
void load_config_file_x11(conky_context *ctx, const char *);
|
||||
void X11_create_window(conky_context *ctx);
|
||||
void scan_mixer_bar(const char *arg, int *a, int *w, int *h);
|
||||
#endif /* X11 */
|
||||
|
||||
void convert_escapes(char *buf);
|
||||
#ifdef HAVE_ICONV
|
||||
void set_iconv_converting(char i);
|
||||
void set_iconv_selected(long i);
|
||||
void iconv_convert(size_t a, char *buff_in, char *p, size_t p_max_size);
|
||||
#endif /* HAVE_ICONV */
|
||||
|
||||
#endif /* _CONKY_CORE_H_ */
|
||||
|
41
src/fonts.h
41
src/fonts.h
@ -32,28 +32,45 @@
|
||||
|
||||
#include "x11.h"
|
||||
|
||||
/* for fonts */
|
||||
struct font_list {
|
||||
|
||||
char name[DEFAULT_TEXT_BUFFER_SIZE];
|
||||
int num;
|
||||
XFontStruct *font;
|
||||
|
||||
#ifdef XFT
|
||||
XftFont *xftfont;
|
||||
int font_alpha;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef XFT
|
||||
|
||||
#define font_height() (use_xft ? (fonts[ctx->selected_font].xftfont->ascent + \
|
||||
fonts[ctx->selected_font].xftfont->descent) \
|
||||
: (fonts[ctx->selected_font].font->max_bounds.ascent + \
|
||||
fonts[ctx->selected_font].font->max_bounds.descent))
|
||||
#define font_ascent() (use_xft ? fonts[ctx->selected_font].xftfont->ascent \
|
||||
: fonts[ctx->selected_font].font->max_bounds.ascent)
|
||||
#define font_descent() (use_xft ? fonts[ctx->selected_font].xftfont->descent \
|
||||
: fonts[ctx->selected_font].font->max_bounds.descent)
|
||||
#define font_height() (use_xft ? (fonts[selected_font].xftfont->ascent + \
|
||||
fonts[selected_font].xftfont->descent) \
|
||||
: (fonts[selected_font].font->max_bounds.ascent + \
|
||||
fonts[selected_font].font->max_bounds.descent))
|
||||
#define font_ascent() (use_xft ? fonts[selected_font].xftfont->ascent \
|
||||
: fonts[selected_font].font->max_bounds.ascent)
|
||||
#define font_descent() (use_xft ? fonts[selected_font].xftfont->descent \
|
||||
: fonts[selected_font].font->max_bounds.descent)
|
||||
|
||||
#else
|
||||
|
||||
#define font_height() (fonts[ctx->selected_font].font->max_bounds.ascent + \
|
||||
fonts[ctx->selected_font].font->max_bounds.descent)
|
||||
#define font_ascent() fonts[ctx->selected_font].font->max_bounds.ascent
|
||||
#define font_descent() fonts[ctx->selected_font].font->max_bounds.descent
|
||||
#define font_height() (fonts[selected_font].font->max_bounds.ascent + \
|
||||
fonts[selected_font].font->max_bounds.descent)
|
||||
#define font_ascent() fonts[selected_font].font->max_bounds.ascent
|
||||
#define font_descent() fonts[selected_font].font->max_bounds.descent
|
||||
|
||||
#endif
|
||||
|
||||
#define MAX_FONTS 256
|
||||
|
||||
/* direct access to registered fonts (FIXME: bad encapsulation) */
|
||||
extern struct font_list *fonts;
|
||||
extern int selected_font;
|
||||
extern int font_count;
|
||||
|
||||
void setup_fonts(void);
|
||||
void set_font(void);
|
||||
|
@ -964,8 +964,12 @@ void get_battery_short_status(char *buffer, unsigned int n, const char *bat)
|
||||
}
|
||||
}
|
||||
|
||||
/* empty stubs so conky links */
|
||||
void update_entropy(void) {}
|
||||
void free_all_processes(void) {}
|
||||
void clear_cpu_stats(void) {}
|
||||
void update_entropy(void)
|
||||
{
|
||||
/* Not applicable for FreeBSD as it uses the yarrow prng. */
|
||||
}
|
||||
|
||||
/* empty stub so conky links */
|
||||
void free_all_processes(void)
|
||||
{
|
||||
}
|
||||
|
11
src/linux.c
11
src/linux.c
@ -610,16 +610,6 @@ void get_cpu_count(void)
|
||||
#define TMPL_LONGSTAT "%*s %llu %llu %llu %llu %llu %llu %llu %llu"
|
||||
#define TMPL_SHORTSTAT "%*s %llu %llu %llu %llu"
|
||||
|
||||
static void *global_cpu = 0;
|
||||
|
||||
void clear_cpu_stats(void)
|
||||
{
|
||||
if (global_cpu) {
|
||||
free(global_cpu);
|
||||
global_cpu = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline static void update_stat(void)
|
||||
{
|
||||
FILE *stat_fp;
|
||||
@ -631,6 +621,7 @@ inline static void update_stat(void)
|
||||
double curtmp;
|
||||
const char *stat_template = NULL;
|
||||
unsigned int malloc_cpu_size = 0;
|
||||
extern void* global_cpu;
|
||||
|
||||
/* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */
|
||||
if (!cpu_setup || !info.cpu_usage) {
|
||||
|
@ -494,18 +494,18 @@ void llua_update_window_table(int text_start_x, int text_start_y, int text_width
|
||||
}
|
||||
#endif /* X11 */
|
||||
|
||||
void llua_setup_info(conky_context *ctx, double u_interval)
|
||||
void llua_setup_info(struct information *i, double u_interval)
|
||||
{
|
||||
if (!lua_L) return;
|
||||
lua_newtable(lua_L);
|
||||
|
||||
llua_set_number("update_interval", u_interval);
|
||||
llua_set_number("uptime", ctx->info.uptime);
|
||||
llua_set_number("uptime", i->uptime);
|
||||
|
||||
lua_setglobal(lua_L, "conky_info");
|
||||
}
|
||||
|
||||
void llua_update_info(conky_context *ctx, double u_interval)
|
||||
void llua_update_info(struct information *i, double u_interval)
|
||||
{
|
||||
if (!lua_L) return;
|
||||
|
||||
@ -517,7 +517,7 @@ void llua_update_info(conky_context *ctx, double u_interval)
|
||||
}
|
||||
|
||||
llua_set_number("update_interval", u_interval);
|
||||
llua_set_number("uptime", ctx->info.uptime);
|
||||
llua_set_number("uptime", i->uptime);
|
||||
|
||||
lua_setglobal(lua_L, "conky_info");
|
||||
}
|
||||
|
@ -24,12 +24,12 @@
|
||||
#ifndef LUA_H_
|
||||
#define LUA_H_
|
||||
|
||||
#include "structs.h"
|
||||
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef X11
|
||||
#include "x11.h"
|
||||
#endif /* X11 */
|
||||
@ -68,7 +68,7 @@ void llua_setup_window_table(int text_start_x, int text_start_y, int text_width,
|
||||
void llua_update_window_table(int text_start_x, int text_start_y, int text_width, int text_height);
|
||||
#endif /* X11 */
|
||||
|
||||
void llua_setup_info(conky_context *ctx, double u_interval);
|
||||
void llua_update_info(conky_context *ctx, double u_interval);
|
||||
void llua_setup_info(struct information *i, double u_interval);
|
||||
void llua_update_info(struct information *i, double u_interval);
|
||||
|
||||
#endif /* LUA_H_*/
|
||||
|
2555
src/obj_create.c
2555
src/obj_create.c
File diff suppressed because it is too large
Load Diff
@ -1,56 +0,0 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
*
|
||||
* 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-2009 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/>.
|
||||
*
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CONKY_OBJ_CREATE_H_
|
||||
#define _CONKY_OBJ_CREATE_H_
|
||||
|
||||
#include "conky.h"
|
||||
|
||||
struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
line, void **ifblock_opaque, void *free_at_crash);
|
||||
|
||||
size_t remove_comments(char *string);
|
||||
|
||||
int extract_variable_text_internal(struct text_object *retval, const char *const_p);
|
||||
|
||||
void free_text_objects(struct text_object *root, int internal);
|
||||
|
||||
#ifdef X11
|
||||
void scan_mixer_bar(const char *arg, int *a, int *w, int *h);
|
||||
#endif /* X11 */
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
void set_iconv_converting(char i);
|
||||
void set_iconv_selected(long i);
|
||||
void iconv_convert(size_t a, char *buff_in, char *p, size_t p_max_size);
|
||||
#endif /* HAVE_ICONV */
|
||||
|
||||
#endif /* _CONKY_OBJ_CREATE_H_ */
|
@ -1,479 +0,0 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
*
|
||||
* 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-2009 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/>.
|
||||
*
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
*
|
||||
*/
|
||||
|
||||
/* local headers */
|
||||
#include "obj_destroy.h"
|
||||
|
||||
/*
|
||||
* Frees the list of text objects root points to. When internal = 1, it won't
|
||||
* free global objects.
|
||||
*/
|
||||
void free_text_objects(struct text_object *root, int internal)
|
||||
{
|
||||
struct text_object *obj;
|
||||
|
||||
if (!root->prev) {
|
||||
return;
|
||||
}
|
||||
|
||||
#define data obj->data
|
||||
for (obj = root->prev; obj; obj = root->prev) {
|
||||
root->prev = obj->prev;
|
||||
switch (obj->type) {
|
||||
#ifndef __OpenBSD__
|
||||
case OBJ_acpitemp:
|
||||
close(data.i);
|
||||
break;
|
||||
#endif /* !__OpenBSD__ */
|
||||
#ifdef __linux__
|
||||
case OBJ_i2c:
|
||||
case OBJ_platform:
|
||||
case OBJ_hwmon:
|
||||
close(data.sysfs.fd);
|
||||
break;
|
||||
#endif /* __linux__ */
|
||||
case OBJ_read_tcp:
|
||||
free(data.read_tcp.host);
|
||||
break;
|
||||
case OBJ_time:
|
||||
case OBJ_utime:
|
||||
free(data.s);
|
||||
break;
|
||||
case OBJ_tztime:
|
||||
free(data.tztime.tz);
|
||||
free(data.tztime.fmt);
|
||||
break;
|
||||
case OBJ_mboxscan:
|
||||
free(data.mboxscan.args);
|
||||
free(data.mboxscan.output);
|
||||
break;
|
||||
case OBJ_mails:
|
||||
case OBJ_new_mails:
|
||||
case OBJ_seen_mails:
|
||||
case OBJ_unseen_mails:
|
||||
case OBJ_flagged_mails:
|
||||
case OBJ_unflagged_mails:
|
||||
case OBJ_forwarded_mails:
|
||||
case OBJ_unforwarded_mails:
|
||||
case OBJ_replied_mails:
|
||||
case OBJ_unreplied_mails:
|
||||
case OBJ_draft_mails:
|
||||
case OBJ_trashed_mails:
|
||||
free(data.local_mail.mbox);
|
||||
break;
|
||||
case OBJ_imap_unseen:
|
||||
if (!obj->char_b) {
|
||||
free(data.mail);
|
||||
}
|
||||
break;
|
||||
case OBJ_imap_messages:
|
||||
if (!obj->char_b) {
|
||||
free(data.mail);
|
||||
}
|
||||
break;
|
||||
case OBJ_pop3_unseen:
|
||||
if (!obj->char_b) {
|
||||
free(data.mail);
|
||||
}
|
||||
break;
|
||||
case OBJ_pop3_used:
|
||||
if (!obj->char_b) {
|
||||
free(data.mail);
|
||||
}
|
||||
break;
|
||||
case OBJ_if_empty:
|
||||
case OBJ_if_match:
|
||||
free_text_objects(obj->sub, 1);
|
||||
free(obj->sub);
|
||||
/* fall through */
|
||||
case OBJ_if_existing:
|
||||
case OBJ_if_mounted:
|
||||
case OBJ_if_running:
|
||||
free(data.ifblock.s);
|
||||
free(data.ifblock.str);
|
||||
break;
|
||||
case OBJ_head:
|
||||
case OBJ_tail:
|
||||
free(data.headtail.logfile);
|
||||
if(data.headtail.buffer) {
|
||||
free(data.headtail.buffer);
|
||||
}
|
||||
break;
|
||||
case OBJ_text:
|
||||
case OBJ_font:
|
||||
case OBJ_image:
|
||||
case OBJ_eval:
|
||||
case OBJ_exec:
|
||||
case OBJ_execbar:
|
||||
#ifdef X11
|
||||
case OBJ_execgauge:
|
||||
case OBJ_execgraph:
|
||||
#endif
|
||||
case OBJ_execp:
|
||||
free(data.s);
|
||||
break;
|
||||
#ifdef HAVE_ICONV
|
||||
case OBJ_iconv_start:
|
||||
free_iconv();
|
||||
break;
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
case OBJ_disk_protect:
|
||||
free(data.s);
|
||||
break;
|
||||
case OBJ_if_gw:
|
||||
free(data.ifblock.s);
|
||||
free(data.ifblock.str);
|
||||
case OBJ_gw_iface:
|
||||
case OBJ_gw_ip:
|
||||
if (info.gw_info.iface) {
|
||||
free(info.gw_info.iface);
|
||||
info.gw_info.iface = 0;
|
||||
}
|
||||
if (info.gw_info.ip) {
|
||||
free(info.gw_info.ip);
|
||||
info.gw_info.ip = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_ioscheduler:
|
||||
if(data.s)
|
||||
free(data.s);
|
||||
break;
|
||||
#endif
|
||||
#if (defined(__FreeBSD__) || defined(__linux__))
|
||||
case OBJ_if_up:
|
||||
free(data.ifblock.s);
|
||||
free(data.ifblock.str);
|
||||
break;
|
||||
#endif
|
||||
#ifdef XMMS2
|
||||
case OBJ_xmms2_artist:
|
||||
if (info.xmms2.artist) {
|
||||
free(info.xmms2.artist);
|
||||
info.xmms2.artist = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_xmms2_album:
|
||||
if (info.xmms2.album) {
|
||||
free(info.xmms2.album);
|
||||
info.xmms2.album = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_xmms2_title:
|
||||
if (info.xmms2.title) {
|
||||
free(info.xmms2.title);
|
||||
info.xmms2.title = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_xmms2_genre:
|
||||
if (info.xmms2.genre) {
|
||||
free(info.xmms2.genre);
|
||||
info.xmms2.genre = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_xmms2_comment:
|
||||
if (info.xmms2.comment) {
|
||||
free(info.xmms2.comment);
|
||||
info.xmms2.comment = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_xmms2_url:
|
||||
if (info.xmms2.url) {
|
||||
free(info.xmms2.url);
|
||||
info.xmms2.url = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_xmms2_date:
|
||||
if (info.xmms2.date) {
|
||||
free(info.xmms2.date);
|
||||
info.xmms2.date = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_xmms2_status:
|
||||
if (info.xmms2.status) {
|
||||
free(info.xmms2.status);
|
||||
info.xmms2.status = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_xmms2_playlist:
|
||||
if (info.xmms2.playlist) {
|
||||
free(info.xmms2.playlist);
|
||||
info.xmms2.playlist = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_xmms2_smart:
|
||||
if (info.xmms2.artist) {
|
||||
free(info.xmms2.artist);
|
||||
info.xmms2.artist = 0;
|
||||
}
|
||||
if (info.xmms2.title) {
|
||||
free(info.xmms2.title);
|
||||
info.xmms2.title = 0;
|
||||
}
|
||||
if (info.xmms2.url) {
|
||||
free(info.xmms2.url);
|
||||
info.xmms2.url = 0;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef BMPX
|
||||
case OBJ_bmpx_title:
|
||||
case OBJ_bmpx_artist:
|
||||
case OBJ_bmpx_album:
|
||||
case OBJ_bmpx_track:
|
||||
case OBJ_bmpx_uri:
|
||||
case OBJ_bmpx_bitrate:
|
||||
break;
|
||||
#endif
|
||||
#ifdef EVE
|
||||
case OBJ_eve:
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_CURL
|
||||
case OBJ_curl:
|
||||
free(data.curl.uri);
|
||||
break;
|
||||
#endif
|
||||
#ifdef RSS
|
||||
case OBJ_rss:
|
||||
free(data.rss.uri);
|
||||
free(data.rss.action);
|
||||
break;
|
||||
#endif
|
||||
#ifdef WEATHER
|
||||
case OBJ_weather:
|
||||
free(data.weather.uri);
|
||||
free(data.weather.data_type);
|
||||
break;
|
||||
#endif
|
||||
#ifdef XOAP
|
||||
case OBJ_weather_forecast:
|
||||
free(data.weather_forecast.uri);
|
||||
free(data.weather_forecast.data_type);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_LUA
|
||||
case OBJ_lua:
|
||||
case OBJ_lua_parse:
|
||||
case OBJ_lua_bar:
|
||||
#ifdef X11
|
||||
case OBJ_lua_graph:
|
||||
case OBJ_lua_gauge:
|
||||
#endif /* X11 */
|
||||
free(data.s);
|
||||
break;
|
||||
#endif /* HAVE_LUA */
|
||||
case OBJ_pre_exec:
|
||||
break;
|
||||
#ifndef __OpenBSD__
|
||||
case OBJ_battery:
|
||||
free(data.s);
|
||||
break;
|
||||
case OBJ_battery_short:
|
||||
free(data.s);
|
||||
break;
|
||||
case OBJ_battery_time:
|
||||
free(data.s);
|
||||
break;
|
||||
#endif /* !__OpenBSD__ */
|
||||
case OBJ_execpi:
|
||||
case OBJ_execi:
|
||||
case OBJ_execibar:
|
||||
#ifdef X11
|
||||
case OBJ_execigraph:
|
||||
case OBJ_execigauge:
|
||||
#endif /* X11 */
|
||||
free(data.execi.cmd);
|
||||
free(data.execi.buffer);
|
||||
break;
|
||||
case OBJ_texeci:
|
||||
if (data.texeci.p_timed_thread) timed_thread_destroy(data.texeci.p_timed_thread, &data.texeci.p_timed_thread);
|
||||
free(data.texeci.cmd);
|
||||
free(data.texeci.buffer);
|
||||
break;
|
||||
case OBJ_nameserver:
|
||||
free_dns_data();
|
||||
break;
|
||||
case OBJ_top:
|
||||
case OBJ_top_mem:
|
||||
case OBJ_top_time:
|
||||
#ifdef IOSTATS
|
||||
case OBJ_top_io:
|
||||
#endif
|
||||
if (info.first_process && !internal) {
|
||||
free_all_processes();
|
||||
info.first_process = NULL;
|
||||
}
|
||||
if (data.top.s) free(data.top.s);
|
||||
break;
|
||||
#ifdef HDDTEMP
|
||||
case OBJ_hddtemp:
|
||||
free(data.hddtemp.dev);
|
||||
free(data.hddtemp.addr);
|
||||
if (data.hddtemp.temp)
|
||||
free(data.hddtemp.temp);
|
||||
break;
|
||||
#endif /* HDDTEMP */
|
||||
case OBJ_entropy_avail:
|
||||
case OBJ_entropy_perc:
|
||||
case OBJ_entropy_poolsize:
|
||||
case OBJ_entropy_bar:
|
||||
break;
|
||||
case OBJ_user_names:
|
||||
if (info.users.names) {
|
||||
free(info.users.names);
|
||||
info.users.names = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_user_terms:
|
||||
if (info.users.terms) {
|
||||
free(info.users.terms);
|
||||
info.users.terms = 0;
|
||||
}
|
||||
break;
|
||||
case OBJ_user_times:
|
||||
if (info.users.times) {
|
||||
free(info.users.times);
|
||||
info.users.times = 0;
|
||||
}
|
||||
break;
|
||||
#ifdef IBM
|
||||
case OBJ_smapi:
|
||||
case OBJ_smapi_bat_perc:
|
||||
case OBJ_smapi_bat_temp:
|
||||
case OBJ_smapi_bat_power:
|
||||
free(data.s);
|
||||
break;
|
||||
case OBJ_if_smapi_bat_installed:
|
||||
free(data.ifblock.s);
|
||||
free(data.ifblock.str);
|
||||
break;
|
||||
#endif /* IBM */
|
||||
#ifdef NVIDIA
|
||||
case OBJ_nvidia:
|
||||
break;
|
||||
#endif /* NVIDIA */
|
||||
#ifdef MPD
|
||||
case OBJ_mpd_title:
|
||||
case OBJ_mpd_artist:
|
||||
case OBJ_mpd_album:
|
||||
case OBJ_mpd_random:
|
||||
case OBJ_mpd_repeat:
|
||||
case OBJ_mpd_vol:
|
||||
case OBJ_mpd_bitrate:
|
||||
case OBJ_mpd_status:
|
||||
case OBJ_mpd_bar:
|
||||
case OBJ_mpd_elapsed:
|
||||
case OBJ_mpd_length:
|
||||
case OBJ_mpd_track:
|
||||
case OBJ_mpd_name:
|
||||
case OBJ_mpd_file:
|
||||
case OBJ_mpd_percent:
|
||||
case OBJ_mpd_smart:
|
||||
case OBJ_if_mpd_playing:
|
||||
free_mpd();
|
||||
break;
|
||||
#endif /* MPD */
|
||||
#ifdef MOC
|
||||
case OBJ_moc_state:
|
||||
case OBJ_moc_file:
|
||||
case OBJ_moc_title:
|
||||
case OBJ_moc_artist:
|
||||
case OBJ_moc_song:
|
||||
case OBJ_moc_album:
|
||||
case OBJ_moc_totaltime:
|
||||
case OBJ_moc_timeleft:
|
||||
case OBJ_moc_curtime:
|
||||
case OBJ_moc_bitrate:
|
||||
case OBJ_moc_rate:
|
||||
free_moc();
|
||||
break;
|
||||
#endif /* MOC */
|
||||
case OBJ_include:
|
||||
case OBJ_blink:
|
||||
case OBJ_to_bytes:
|
||||
if(obj->sub) {
|
||||
free_text_objects(obj->sub, 1);
|
||||
free(obj->sub);
|
||||
}
|
||||
break;
|
||||
case OBJ_scroll:
|
||||
free(data.scroll.text);
|
||||
free_text_objects(obj->sub, 1);
|
||||
free(obj->sub);
|
||||
break;
|
||||
case OBJ_combine:
|
||||
free(data.combine.left);
|
||||
free(data.combine.seperation);
|
||||
free(data.combine.right);
|
||||
free_text_objects(obj->sub, 1);
|
||||
free(obj->sub);
|
||||
break;
|
||||
#ifdef APCUPSD
|
||||
case OBJ_apcupsd:
|
||||
case OBJ_apcupsd_name:
|
||||
case OBJ_apcupsd_model:
|
||||
case OBJ_apcupsd_upsmode:
|
||||
case OBJ_apcupsd_cable:
|
||||
case OBJ_apcupsd_status:
|
||||
case OBJ_apcupsd_linev:
|
||||
case OBJ_apcupsd_load:
|
||||
case OBJ_apcupsd_loadbar:
|
||||
#ifdef X11
|
||||
case OBJ_apcupsd_loadgraph:
|
||||
case OBJ_apcupsd_loadgauge:
|
||||
#endif /* X11 */
|
||||
case OBJ_apcupsd_charge:
|
||||
case OBJ_apcupsd_timeleft:
|
||||
case OBJ_apcupsd_temp:
|
||||
case OBJ_apcupsd_lastxfer:
|
||||
break;
|
||||
#endif /* APCUPSD */
|
||||
#ifdef X11
|
||||
case OBJ_desktop:
|
||||
case OBJ_desktop_number:
|
||||
case OBJ_desktop_name:
|
||||
if(info.x11.desktop.name) {
|
||||
free(info.x11.desktop.name);
|
||||
info.x11.desktop.name = NULL;
|
||||
}
|
||||
if(info.x11.desktop.all_names) {
|
||||
free(info.x11.desktop.all_names);
|
||||
info.x11.desktop.all_names = NULL;
|
||||
}
|
||||
break;
|
||||
#endif /* X11 */
|
||||
}
|
||||
free(obj);
|
||||
}
|
||||
#undef data
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
*
|
||||
* 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-2009 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/>.
|
||||
*
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CONKY_OBJ_DESTROY_H_
|
||||
#define _CONKY_OBJ_DESTROY_H_
|
||||
|
||||
#include "conky.h"
|
||||
#include "text_object.h"
|
||||
|
||||
void free_text_objects(struct text_object *root, int internal);
|
||||
|
||||
#endif /* _CONKY_OBJ_DESTROY_H_ */
|
2577
src/obj_display.c
2577
src/obj_display.c
File diff suppressed because it is too large
Load Diff
@ -1,41 +0,0 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
*
|
||||
* 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-2009 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/>.
|
||||
*
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CONKY_OBJ_DISPLAY_H_
|
||||
#define _CONKY_OBJ_DISPLAY_H_
|
||||
|
||||
#include "conky.h"
|
||||
#include "text_object.h"
|
||||
|
||||
void generate_text_internal(char *p, int p_max_size, struct text_object root,
|
||||
struct information *cur);
|
||||
|
||||
#endif /* _CONKY_OBJ_DISPLAY_H_ */
|
@ -31,6 +31,8 @@
|
||||
|
||||
/* special stuff in text_buffer */
|
||||
|
||||
#define SPECIAL_CHAR '\x01'
|
||||
|
||||
#define MAX_GRAPH_DEPTH 512
|
||||
|
||||
// don't use spaces in LOGGRAPH or NORMGRAPH if you change them
|
||||
|
335
src/structs.h
335
src/structs.h
@ -1,335 +0,0 @@
|
||||
/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
|
||||
*
|
||||
* 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-2009 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/>.
|
||||
*
|
||||
* vim: ts=4 sw=4 noet ai cindent syntax=c
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CONKY_STRUCTS_H_
|
||||
#define _CONKY_STRUCTS_H_
|
||||
|
||||
#include "config.h" /* defines */
|
||||
|
||||
#include <sys/utsname.h> /* struct uname_s */
|
||||
#include <stdio.h> /* FILE */
|
||||
|
||||
#ifdef X11
|
||||
#include "x11.h"
|
||||
#endif /* X11 */
|
||||
|
||||
#ifdef APCUPSD
|
||||
#include "apcupsd.h"
|
||||
#endif
|
||||
|
||||
#define MAX_TEMPLATES 10
|
||||
|
||||
struct entropy_s {
|
||||
unsigned int entropy_avail;
|
||||
unsigned int poolsize;
|
||||
};
|
||||
|
||||
struct usr_info {
|
||||
char *names;
|
||||
char *times;
|
||||
char *terms;
|
||||
int number;
|
||||
};
|
||||
|
||||
struct gateway_info {
|
||||
char *iface;
|
||||
char *ip;
|
||||
int count;
|
||||
};
|
||||
|
||||
#ifdef X11
|
||||
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;
|
||||
};
|
||||
|
||||
#endif /* X11 */
|
||||
|
||||
struct dns_data {
|
||||
int nscount;
|
||||
char **ns_list;
|
||||
};
|
||||
|
||||
struct conftree {
|
||||
char* string;
|
||||
struct conftree* horz_next;
|
||||
struct conftree* vert_next;
|
||||
struct conftree* back;
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
float *cpu_usage;
|
||||
/* struct cpu_stat cpu_summed; what the hell is this? */
|
||||
unsigned int cpu_count;
|
||||
int cpu_avg_samples;
|
||||
|
||||
int net_avg_samples;
|
||||
|
||||
int diskio_avg_samples;
|
||||
|
||||
float loadavg[3];
|
||||
|
||||
struct mail_s *mail;
|
||||
int mail_running;
|
||||
#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 gateway_info gw_info;
|
||||
struct dns_data nameserver_info;
|
||||
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;
|
||||
struct entropy_s entropy;
|
||||
double music_player_interval;
|
||||
|
||||
#ifdef X11
|
||||
struct x11_info x11;
|
||||
#endif
|
||||
|
||||
#ifdef APCUPSD
|
||||
APCUPSD_S apcupsd;
|
||||
#endif
|
||||
|
||||
short kflags; /* kernel settings, see enum KFLAG */
|
||||
};
|
||||
|
||||
enum x_initialiser_state {
|
||||
NO = 0,
|
||||
YES = 1,
|
||||
NEVER = 2
|
||||
};
|
||||
|
||||
#ifdef X11
|
||||
/* for fonts, used in fonts.c, core.c, etc */
|
||||
struct font_list {
|
||||
|
||||
char name[DEFAULT_TEXT_BUFFER_SIZE];
|
||||
int num;
|
||||
XFontStruct *font;
|
||||
|
||||
#ifdef XFT
|
||||
XftFont *xftfont;
|
||||
int font_alpha;
|
||||
#endif
|
||||
};
|
||||
#endif /* X11 */
|
||||
|
||||
typedef struct _conky_context_s {
|
||||
/* variables holding various config settings */
|
||||
int short_units;
|
||||
int format_human_readable;
|
||||
int cpu_separate;
|
||||
enum {
|
||||
NO_SPACER = 0,
|
||||
LEFT_SPACER,
|
||||
RIGHT_SPACER
|
||||
} use_spacer;
|
||||
int top_cpu, top_mem, top_time;
|
||||
#ifdef IOSTATS
|
||||
int top_io;
|
||||
#endif /* IOSTATS */
|
||||
unsigned int top_name_width;
|
||||
int output_methods;
|
||||
int extra_newline;
|
||||
enum x_initialiser_state x_initialised;
|
||||
/* Update interval */
|
||||
double update_interval;
|
||||
double update_interval_old;
|
||||
double update_interval_bat;
|
||||
|
||||
double current_update_time, next_update_time, last_update_time;
|
||||
|
||||
/* struct that has all info to be shared between
|
||||
* instances of the same text object */
|
||||
struct information info;
|
||||
|
||||
/* path to config file */
|
||||
char *current_config;
|
||||
|
||||
/* set to 1 if you want all text to be in uppercase */
|
||||
unsigned int stuff_in_uppercase;
|
||||
|
||||
/* Run how many times? */
|
||||
unsigned long total_run_times;
|
||||
|
||||
/* fork? */
|
||||
int fork_to_background;
|
||||
|
||||
int cpu_avg_samples, net_avg_samples, diskio_avg_samples;
|
||||
|
||||
/* filenames for output */
|
||||
char *overwrite_file; FILE *overwrite_fpointer;
|
||||
char *append_file; FILE *append_fpointer;
|
||||
|
||||
#ifdef X11
|
||||
/* display to connect to */
|
||||
char *disp;
|
||||
|
||||
int show_graph_scale;
|
||||
int show_graph_range;
|
||||
|
||||
/* Position on the screen */
|
||||
int text_alignment;
|
||||
int gap_x, gap_y;
|
||||
|
||||
/* border */
|
||||
int draw_borders;
|
||||
int draw_graph_borders;
|
||||
int stippled_borders;
|
||||
|
||||
int draw_shades, draw_outline;
|
||||
|
||||
long default_fg_color, default_bg_color, default_out_color;
|
||||
|
||||
/* create own window or draw stuff to root? */
|
||||
int set_transparent;
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
int own_window;
|
||||
int background_colour;
|
||||
|
||||
/* fixed size/pos is set if wm/user changes them */
|
||||
int fixed_size, fixed_pos;
|
||||
#endif
|
||||
|
||||
int minimum_width, minimum_height;
|
||||
int maximum_width;
|
||||
|
||||
int selected_font;
|
||||
int last_font_height;
|
||||
|
||||
/* text size */
|
||||
int text_start_x, text_start_y; /* text start position in window */
|
||||
int text_width, text_height;
|
||||
|
||||
conky_window window;
|
||||
|
||||
#endif /* X11 */
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
int sensor_device;
|
||||
#endif
|
||||
|
||||
long color0, color1, color2, color3, color4, color5, color6, color7, color8,
|
||||
color9;
|
||||
|
||||
char *template[MAX_TEMPLATES];
|
||||
|
||||
/* maximum size of config TEXT buffer, i.e. below TEXT line. */
|
||||
unsigned int max_user_text;
|
||||
|
||||
/* maximum size of individual text buffers, ie $exec buffer size */
|
||||
unsigned int text_buffer_size;
|
||||
|
||||
/* UTF-8 */
|
||||
int utf8_mode;
|
||||
|
||||
/* no buffers in used memory? */
|
||||
int no_buffers;
|
||||
|
||||
/* pad percentages to decimals? */
|
||||
int pad_percents0;
|
||||
|
||||
char *global_text;
|
||||
|
||||
long global_text_lines;
|
||||
|
||||
int total_updates;
|
||||
int updatereset;
|
||||
|
||||
int need_to_update;
|
||||
|
||||
/* formatted text to render on screen, generated in generate_text(), drawn
|
||||
* in draw_stuff() */
|
||||
char *text_buffer;
|
||||
|
||||
char **xargv;
|
||||
int xargc;
|
||||
|
||||
/* used in colours.c */
|
||||
short colour_depth;
|
||||
long redmask, greenmask, bluemask;
|
||||
|
||||
|
||||
struct font_list *fonts;
|
||||
int font_count;
|
||||
|
||||
/* used in common.c */
|
||||
double last_meminfo_update;
|
||||
double last_fs_update;
|
||||
|
||||
unsigned long long need_mask;
|
||||
|
||||
/* two strings for internal use */
|
||||
char *tmpstring1, *tmpstring2;
|
||||
} conky_context;
|
||||
|
||||
#endif /* _CONKY_STRUCTS_H_ */
|
@ -43,9 +43,6 @@
|
||||
#include "nvidia.h" /* nvidia_s */
|
||||
#endif
|
||||
|
||||
#define SPECIAL_CHAR '\x01'
|
||||
#define SECRIT_MULTILINE_CHAR '\x02'
|
||||
|
||||
enum text_object_type {
|
||||
OBJ_read_tcp,
|
||||
OBJ_addr,
|
||||
|
@ -63,6 +63,9 @@ static int background_colour;
|
||||
/* workarea from _NET_WORKAREA, this is where window / text is aligned */
|
||||
int workarea[4];
|
||||
|
||||
/* Window stuff */
|
||||
struct conky_window window;
|
||||
|
||||
/* local prototypes */
|
||||
static void update_workarea(void);
|
||||
static Window find_desktop_window(Window *p_root, Window *p_desktop);
|
||||
|
16
src/x11.h
16
src/x11.h
@ -16,10 +16,6 @@
|
||||
#include <X11/extensions/Xdbe.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XDAMAGE
|
||||
#include <X11/extensions/Xdamage.h>
|
||||
#endif /* HAVE_XDAMAGE */
|
||||
|
||||
#define ATOM(a) XInternAtom(display, #a, False)
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
@ -44,7 +40,7 @@ enum _window_hints {
|
||||
#define TEST_HINT(mask, hint) (mask & (1 << hint))
|
||||
#endif
|
||||
|
||||
typedef struct _conky_window_s {
|
||||
struct conky_window {
|
||||
Window root, window, desktop;
|
||||
Drawable drawable;
|
||||
Visual *visual;
|
||||
@ -69,13 +65,7 @@ typedef struct _conky_window_s {
|
||||
unsigned int type;
|
||||
unsigned long hints;
|
||||
#endif
|
||||
Region region;
|
||||
#ifdef HAVE_XDAMAGE
|
||||
Damage damage;
|
||||
XserverRegion region2, part;
|
||||
int event_base, error_base;
|
||||
#endif
|
||||
} conky_window;
|
||||
};
|
||||
|
||||
#ifdef HAVE_XDBE
|
||||
extern int use_xdbe;
|
||||
@ -92,6 +82,8 @@ extern int screen;
|
||||
|
||||
extern int workarea[4];
|
||||
|
||||
extern struct conky_window window;
|
||||
|
||||
void init_X11(const char*);
|
||||
void init_window(int use_own_window, int width, int height, int set_trans,
|
||||
int back_colour, char **argv, int argc);
|
||||
|
Loading…
Reference in New Issue
Block a user