mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-23 19:39:06 +00:00
* More own_window fixes
* applied disk io patch (sf.net patch 1271691) * applied $freq fixes patch, adds new $freq_dyn (sf.net patch 1271633) * removed units from $freq* output * fix for graph config parsing git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@185 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
bc36a9500e
commit
cdb2b0d388
5
AUTHORS
5
AUTHORS
@ -65,6 +65,11 @@ Jeremy Burch <ascii021 at yahoo dot com>
|
||||
JL Farinacci
|
||||
pad_percents
|
||||
|
||||
Johannes Winkelmann <winkj at users dot sourceforge dot net>
|
||||
disk I/O on linux
|
||||
more consistent cpu freq handling on linux
|
||||
capitalize Hertz in cpu frequeny
|
||||
|
||||
jolapache <jolapache at free dot fr>
|
||||
maildir format
|
||||
|
||||
|
@ -1,5 +1,12 @@
|
||||
# $Id$
|
||||
|
||||
2005-08-25
|
||||
* More own_window fixes
|
||||
* applied disk io patch (sf.net patch 1271691)
|
||||
* applied $freq fixes patch, adds new $freq_dyn (sf.net patch 1271633)
|
||||
* removed units from $freq* output
|
||||
* fix for graph config parsing
|
||||
|
||||
2005-08-24
|
||||
* More configure and makefile updates
|
||||
* Added scale arg for net graphs
|
||||
|
81
README
81
README
@ -359,6 +359,15 @@ VARIABLES
|
||||
CPU usage graph, with optional colours in hex, minus the #.
|
||||
|
||||
|
||||
diskio Displays current disk IO.
|
||||
|
||||
|
||||
diskiograph (height),(width) (gradient colour 1) (gradient colour 2)
|
||||
(scale)
|
||||
Disk IO graph, colours defined in hex, minus the #. If scale is
|
||||
non-zero, it becomes the scale for the graph.
|
||||
|
||||
|
||||
downspeed net
|
||||
Download speed in kilobytes
|
||||
|
||||
@ -367,9 +376,9 @@ VARIABLES
|
||||
Download speed in kilobytes with one decimal
|
||||
|
||||
|
||||
downspeedgraph net, (height),(width) (gradient colour 1) (gradient
|
||||
downspeedgraph net, (height),(width) (gradient colour 1) (gradient
|
||||
colour 2) (scale)
|
||||
Download speed graph, colours defined in hex, minus the #. If
|
||||
Download speed graph, colours defined in hex, minus the #. If
|
||||
scale is non-zero, it becomes the scale for the graph.
|
||||
|
||||
|
||||
@ -378,13 +387,13 @@ VARIABLES
|
||||
|
||||
exec command
|
||||
Executes a shell command and displays the output in conky. warn-
|
||||
ing: this takes a lot more resources than other variables. I'd
|
||||
ing: this takes a lot more resources than other variables. I'd
|
||||
recommend coding wanted behaviour in C and posting a patch.
|
||||
|
||||
|
||||
execbar command
|
||||
Same as exec, except if the first value return is a value
|
||||
between 0-100, it will use that number for a bar. The size for
|
||||
Same as exec, except if the first value return is a value
|
||||
between 0-100, it will use that number for a bar. The size for
|
||||
the bar is currently fixed, but that may change in the future.
|
||||
|
||||
|
||||
@ -393,7 +402,7 @@ VARIABLES
|
||||
|
||||
|
||||
execi interval command
|
||||
Same as exec but with specific interval. Interval can't be less
|
||||
Same as exec but with specific interval. Interval can't be less
|
||||
than update_interval in configuration.
|
||||
|
||||
|
||||
@ -415,8 +424,20 @@ VARIABLES
|
||||
freq_g Returns CPU frequency in GHz
|
||||
|
||||
|
||||
freq_dyn
|
||||
Returns CPU frequency in MHz, but is calculated by counting to
|
||||
clock cycles to complete an instruction. Only available for
|
||||
x86/amd64.
|
||||
|
||||
|
||||
freq_dyn_g
|
||||
Returns CPU frequency in GHz, but is calculated by counting to
|
||||
clock cycles to complete an instruction. Only available for
|
||||
x86/amd64.
|
||||
|
||||
|
||||
fs_bar (height),(width) fs
|
||||
Bar that shows how much space is used on a file system. height
|
||||
Bar that shows how much space is used on a file system. height
|
||||
is the height in pixels. fs is any file on that file system.
|
||||
|
||||
|
||||
@ -441,25 +462,25 @@ VARIABLES
|
||||
|
||||
|
||||
i2c (dev), type, n
|
||||
I2C sensor from sysfs (Linux 2.6). dev may be omitted if you
|
||||
have only one I2C device. type is either in (or vol) meaning
|
||||
I2C sensor from sysfs (Linux 2.6). dev may be omitted if you
|
||||
have only one I2C device. type is either in (or vol) meaning
|
||||
voltage, fan meaning fan or temp/tempf (first in C, second in F)
|
||||
meaning temperature. n is number of the sensor. See
|
||||
meaning temperature. n is number of the sensor. See
|
||||
/sys/bus/i2c/devices/ on your local computer.
|
||||
|
||||
|
||||
if_running (process)
|
||||
if PROCESS is running, display everything if_running and the
|
||||
if PROCESS is running, display everything if_running and the
|
||||
matching $endif
|
||||
|
||||
|
||||
if_existing (file)
|
||||
if FILE exists, display everything between if_existing and the
|
||||
if FILE exists, display everything between if_existing and the
|
||||
matching $endif
|
||||
|
||||
|
||||
if_mounted (mountpoint)
|
||||
if MOUNTPOINT is mounted, display everything between if_mounted
|
||||
if MOUNTPOINT is mounted, display everything between if_mounted
|
||||
and the matching $endif
|
||||
|
||||
|
||||
@ -479,8 +500,8 @@ VARIABLES
|
||||
Machine, i686 for example
|
||||
|
||||
|
||||
mails Mail count in mail spool. You can use program like fetchmail to
|
||||
get mails from some server using your favourite protocol. See
|
||||
mails Mail count in mail spool. You can use program like fetchmail to
|
||||
get mails from some server using your favourite protocol. See
|
||||
also new_mails.
|
||||
|
||||
|
||||
@ -634,27 +655,27 @@ VARIABLES
|
||||
Move text over by N pixels. See also $voffset.
|
||||
|
||||
|
||||
tail logfile, lines interval> Displays last N lines of supplied text
|
||||
tail logfile, lines interval> Displays last N lines of supplied text
|
||||
text file. If interval is not supplied, Conky assumes 2x Conky's
|
||||
interval. Max of 30 lines. Max of 30 lines can be displayed.
|
||||
|
||||
|
||||
time (format)
|
||||
Local time, see man strftime to get more information about for-
|
||||
Local time, see man strftime to get more information about for-
|
||||
mat
|
||||
|
||||
|
||||
totaldown net
|
||||
Total download, overflows at 4 GB on Linux with 32-bit arch and
|
||||
there doesn't seem to be a way to know how many times it has
|
||||
Total download, overflows at 4 GB on Linux with 32-bit arch and
|
||||
there doesn't seem to be a way to know how many times it has
|
||||
already done that before conky has started.
|
||||
|
||||
|
||||
top type, num
|
||||
This takes arguments in the form:top (name) (number) Basically,
|
||||
processes are ranked from highest to lowest in terms of cpu
|
||||
usage, which is what (num) represents. The types are: "name",
|
||||
"pid", "cpu", and mem". There can be a max of 10 processes
|
||||
This takes arguments in the form:top (name) (number) Basically,
|
||||
processes are ranked from highest to lowest in terms of cpu
|
||||
usage, which is what (num) represents. The types are: "name",
|
||||
"pid", "cpu", and mem". There can be a max of 10 processes
|
||||
listed.
|
||||
|
||||
|
||||
@ -680,7 +701,7 @@ VARIABLES
|
||||
|
||||
upspeedgraph net, (height),(width) (gradient colour 1) (gradient colour
|
||||
2) (scale)
|
||||
Upload speed graph, colours defined in hex, minus the #. If
|
||||
Upload speed graph, colours defined in hex, minus the #. If
|
||||
scale is non-zero, it becomes the scale for the graph.
|
||||
|
||||
|
||||
@ -704,7 +725,7 @@ VARIABLES
|
||||
|
||||
|
||||
voffset (pixels)
|
||||
Change verticle offset by N pixels. Negative values will cause
|
||||
Change verticle offset by N pixels. Negative values will cause
|
||||
text to overlap. See also $offset.
|
||||
|
||||
|
||||
@ -722,11 +743,11 @@ FILES
|
||||
BUGS
|
||||
Drawing to root or some other desktop window directly doesn't work with
|
||||
all window managers. Especially doesn't work well with Gnome and it has
|
||||
been reported that it doesn't work with KDE either. Nautilus can be
|
||||
disabled from drawing to desktop with program gconf-editor. Uncheck
|
||||
show_desktop in /apps/nautilus/preferences/. There is -w switch in
|
||||
Conky to set some specific window id. You might find xwininfo -tree
|
||||
useful to find the window to draw to. You can also use -o argument
|
||||
been reported that it doesn't work with KDE either. Nautilus can be
|
||||
disabled from drawing to desktop with program gconf-editor. Uncheck
|
||||
show_desktop in /apps/nautilus/preferences/. There is -w switch in
|
||||
Conky to set some specific window id. You might find xwininfo -tree
|
||||
useful to find the window to draw to. You can also use -o argument
|
||||
which makes Conky to create its own window.
|
||||
|
||||
SEE ALSO
|
||||
|
@ -53,6 +53,12 @@ total_run_times 0
|
||||
# Create own window instead of using desktop (required in nautilus)
|
||||
own_window no
|
||||
|
||||
# Use pseudo transparency with own_window?
|
||||
own_window_transparent yes
|
||||
|
||||
# If own_window_transparent is set to no, you can set the background colour here
|
||||
own_window_colour hotpink
|
||||
|
||||
# Use double buffering (reduces flicker, may not work for everyone)
|
||||
double_buffer yes
|
||||
|
||||
|
@ -150,6 +150,25 @@
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>diskio</option></command>
|
||||
</term>
|
||||
<listitem>
|
||||
Displays current disk IO.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>diskiograph</option></command>
|
||||
<option>(height),(width) (gradient colour 1) (gradient colour 2) (scale)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Disk IO graph, colours defined in hex, minus the #. If scale is non-zero, it becomes the scale for the graph.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>downspeed</option></command>
|
||||
@ -277,6 +296,23 @@
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>freq_dyn</option></command>
|
||||
</term>
|
||||
<listitem>
|
||||
Returns CPU frequency in MHz, but is calculated by counting to clock cycles to complete an instruction. Only available for x86/amd64.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>freq_dyn_g</option></command>
|
||||
</term>
|
||||
<listitem>
|
||||
Returns CPU frequency in GHz, but is calculated by counting to clock cycles to complete an instruction. Only available for x86/amd64.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>fs_bar</option></command>
|
||||
|
110
src/conky.c
110
src/conky.c
@ -231,12 +231,12 @@ static int border_margin, border_width;
|
||||
static long default_fg_color, default_bg_color, default_out_color;
|
||||
|
||||
/* create own window or draw stuff to root? */
|
||||
static int own_window = 0;
|
||||
static int set_transparent = 0;
|
||||
static int background_colour = 0;
|
||||
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
static int own_window = 0;
|
||||
static int background_colour = 0;
|
||||
/* fixed size/pos is set if wm/user changes them */
|
||||
static int fixed_size = 0, fixed_pos = 0;
|
||||
#endif
|
||||
@ -261,7 +261,7 @@ static char original_text[] =
|
||||
"$hr\n"
|
||||
"${color grey}Uptime:$color $uptime\n"
|
||||
"${color grey}Frequency (in MHz):$color $freq\n"
|
||||
"${color grey}Frequency (in Ghz):$color $freq_g\n"
|
||||
"${color grey}Frequency (in GHz):$color $freq_g\n"
|
||||
"${color grey}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4}\n"
|
||||
"${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}\n"
|
||||
"${color grey}CPU Usage:$color $cpu% ${cpubar 4}\n"
|
||||
@ -511,7 +511,7 @@ inline void graph_append(struct special_t *graph, double f)
|
||||
}
|
||||
int i;
|
||||
if (graph->scaled) {
|
||||
graph->graph_scale = 0;
|
||||
graph->graph_scale = 1;
|
||||
}
|
||||
graph->graph[graph->graph_width - 1] = f; /* add new data */
|
||||
for (i = 0; i < graph->graph_width - 1; i++) { /* shift all the data by 1 */
|
||||
@ -563,23 +563,29 @@ static const char *scan_graph(const char *args, int *w, int *h, unsigned int *fi
|
||||
if (sscanf(args, "%d,%d %x %x", h, w, first_colour, last_colour) < 4) {
|
||||
*w = 0;
|
||||
*h = 25;
|
||||
if (sscanf(args, "%*s %x %x", first_colour, last_colour) < 3) {
|
||||
if (sscanf(args, "%*s %x %x %i", first_colour, last_colour, scale) < 3) {
|
||||
*w = 0;
|
||||
*h = 25;
|
||||
if (sscanf(args, "%x %x", first_colour, last_colour) < 2) {
|
||||
*first_colour = 0;
|
||||
*last_colour = 0;
|
||||
if (sscanf(args, "%d,%d", h, w) < 2) {
|
||||
*scale = 0;
|
||||
if (sscanf(args, "%*s %x %x", first_colour, last_colour) < 2) {
|
||||
*w = 0;
|
||||
*h = 25;
|
||||
if (sscanf(args, "%x %x %i", first_colour, last_colour, scale) < 3) {
|
||||
*first_colour = 0;
|
||||
*last_colour = 0;
|
||||
sscanf(args, "%*s %d,%d", h, w);
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*scale = 0;
|
||||
if (sscanf(args, "%x %x", first_colour, last_colour) < 2) {
|
||||
*first_colour = 0;
|
||||
*last_colour = 0;
|
||||
if (sscanf(args, "%d,%d %i", h, w, scale) < 3) {
|
||||
*first_colour = 0;
|
||||
*last_colour = 0;
|
||||
*scale = 0;
|
||||
if (sscanf(args, "%d,%d", h, w) < 2) {
|
||||
*first_colour = 0;
|
||||
*last_colour = 0;
|
||||
sscanf(args, "%*s %d,%d", h, w);
|
||||
}}}}}}}}}}} // haha
|
||||
return args;
|
||||
}
|
||||
|
||||
@ -709,6 +715,8 @@ enum text_object_type {
|
||||
OBJ_cpu,
|
||||
OBJ_cpubar,
|
||||
OBJ_cpugraph,
|
||||
OBJ_diskio,
|
||||
OBJ_diskiograph,
|
||||
OBJ_downspeed,
|
||||
OBJ_downspeedf,
|
||||
OBJ_downspeedgraph,
|
||||
@ -722,6 +730,8 @@ enum text_object_type {
|
||||
OBJ_execigraph,
|
||||
OBJ_freq,
|
||||
OBJ_freq_g,
|
||||
OBJ_freq_dyn,
|
||||
OBJ_freq_dyn_g,
|
||||
OBJ_fs_bar,
|
||||
OBJ_fs_bar_free,
|
||||
OBJ_fs_free,
|
||||
@ -826,6 +836,7 @@ struct text_object {
|
||||
struct net_stat *net;
|
||||
struct fs_stat *fs;
|
||||
unsigned char loadavg[3];
|
||||
unsigned int diskio;
|
||||
|
||||
struct {
|
||||
struct fs_stat *fs;
|
||||
@ -986,6 +997,8 @@ if (s[0] == '#') {
|
||||
END OBJ(acpiacadapter, 0)
|
||||
END OBJ(freq, 0);
|
||||
END OBJ(freq_g, 0);
|
||||
END OBJ(freq_dyn, 0);
|
||||
END OBJ(freq_dyn_g, 0);
|
||||
END OBJ(acpifan, 0);
|
||||
END OBJ(battery, 0);
|
||||
char bat[64];
|
||||
@ -1001,6 +1014,8 @@ if (s[0] == '#') {
|
||||
(void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
|
||||
END OBJ(cpugraph, INFO_CPU)
|
||||
(void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
|
||||
END OBJ(diskio, 0)
|
||||
END OBJ(diskiograph, 0) (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
|
||||
END OBJ(color, 0)
|
||||
#ifdef X11
|
||||
obj->data.l = arg ? get_x11_color(arg) : default_fg_color;
|
||||
@ -1629,12 +1644,19 @@ static void generate_text()
|
||||
i)+ 40) * 9.0 / 5 - 40));
|
||||
}
|
||||
OBJ(freq) {
|
||||
snprintf(p, n, "%.0fMhz", get_freq());
|
||||
snprintf(p, n, "%.0f", get_freq());
|
||||
}
|
||||
OBJ(freq_g) {
|
||||
float ghz = (float)(get_freq()/1000);
|
||||
//printf("%f\n", ghz);
|
||||
snprintf(p, n, "%'.2fGhz", ghz);
|
||||
snprintf(p, n, "%'.2f", ghz);
|
||||
}
|
||||
OBJ(freq_dyn) {
|
||||
snprintf(p, n, "%.0f", get_freq_dynamic());
|
||||
}
|
||||
OBJ(freq_dyn_g) {
|
||||
float ghz = (float)(get_freq_dynamic()/1000);
|
||||
snprintf(p, n, "%'.2f", ghz);
|
||||
}
|
||||
OBJ(adt746xcpu) {
|
||||
snprintf(p, n, "%s", get_adt746x_cpu());
|
||||
@ -1689,6 +1711,24 @@ static void generate_text()
|
||||
new_font(p, obj->data.s);
|
||||
}
|
||||
#endif /* X11 */
|
||||
OBJ(diskio) {
|
||||
int io = get_diskio();
|
||||
if (io > 1024) {
|
||||
snprintf(p, n, "%.1fM",
|
||||
(double)io/1024);
|
||||
} else if (io > 0) {
|
||||
snprintf(p, n, "%dK", io);
|
||||
} else {
|
||||
snprintf(p, n, "%d", io);
|
||||
}
|
||||
}
|
||||
OBJ(diskiograph) {
|
||||
int io = get_diskio();
|
||||
new_graph(p, obj->a,
|
||||
obj->b, obj->c, obj->d,
|
||||
(unsigned int) (io), obj->e, 1);
|
||||
}
|
||||
|
||||
OBJ(downspeed) {
|
||||
if (!use_spacer) {
|
||||
snprintf(p, n, "%d",
|
||||
@ -3147,7 +3187,7 @@ static void draw_line(char *s)
|
||||
j++;
|
||||
}
|
||||
XDrawLine(display, window.drawable, window.gc, cur_x + i + 2, by + h, cur_x + i + 2, by + h - specials[special_index].graph[j] * (h - 1) / specials[special_index].graph_scale); /* this is mugfugly, but it works */
|
||||
}
|
||||
}
|
||||
if (specials[special_index].
|
||||
height > cur_y_add
|
||||
&& specials[special_index].
|
||||
@ -3418,8 +3458,13 @@ static void main_loop()
|
||||
update_text();
|
||||
#ifdef X11
|
||||
}
|
||||
#ifdef OWN_WINDOW
|
||||
if (own_window) {
|
||||
set_transparent_background(window.window);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (need_to_update) {
|
||||
#ifdef OWN_WINDOW
|
||||
int wx = window.x, wy = window.y;
|
||||
@ -3446,8 +3491,7 @@ static void main_loop()
|
||||
window.window,
|
||||
window.width,
|
||||
window.height);
|
||||
set_transparent_background(window.window);
|
||||
}
|
||||
}
|
||||
|
||||
/* move window if it isn't in right position */
|
||||
if (!fixed_pos
|
||||
@ -3492,13 +3536,13 @@ static void main_loop()
|
||||
break;
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
case ReparentNotify:
|
||||
/* set background to ParentRelative for all parents */
|
||||
/*case ReparentNotify:
|
||||
set background to ParentRelative for all parents
|
||||
if (own_window) {
|
||||
set_transparent_background(window.
|
||||
window);
|
||||
window);
|
||||
}
|
||||
break;
|
||||
break;*/
|
||||
|
||||
case ConfigureNotify:
|
||||
if (own_window) {
|
||||
@ -3591,6 +3635,8 @@ static void main_loop()
|
||||
XDestroyRegion(region);
|
||||
region = XCreateRegion();
|
||||
}
|
||||
|
||||
|
||||
#endif /* X11 */
|
||||
|
||||
}
|
||||
@ -4352,7 +4398,9 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
#ifdef XDBE
|
||||
case 'b':
|
||||
use_xdbe = 1;
|
||||
if (!own_window) {
|
||||
use_xdbe = 1;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#endif /* X11 */
|
||||
@ -4428,8 +4476,12 @@ int main(int argc, char **argv)
|
||||
|
||||
#ifdef X11
|
||||
#ifdef OWN_WINDOW
|
||||
if (own_window && !fixed_pos)
|
||||
if (own_window && !fixed_pos) {
|
||||
XMoveWindow(display, window.window, window.x, window.y);
|
||||
}
|
||||
if (own_window) {
|
||||
set_transparent_background(window.window);
|
||||
}
|
||||
#endif
|
||||
|
||||
create_gc();
|
||||
|
@ -267,6 +267,7 @@ void update_cpu_usage(void);
|
||||
void update_total_processes(void);
|
||||
void update_running_processes(void);
|
||||
float get_freq();
|
||||
float get_freq_dynamic();
|
||||
void update_load_average();
|
||||
int open_i2c_sensor(const char *dev, const char *type, int n, int *div,
|
||||
char *devtype);
|
||||
@ -274,6 +275,7 @@ double get_i2c_info(int *fd, int arg, char *devtype, char *type);
|
||||
|
||||
char *get_adt746x_cpu(void);
|
||||
char *get_adt746x_fan(void);
|
||||
unsigned int get_diskio(void);
|
||||
|
||||
int open_acpi_temperature(const char *name);
|
||||
double get_acpi_temperature(int fd);
|
||||
|
@ -421,6 +421,12 @@ char *get_adt746x_fan()
|
||||
return "";
|
||||
}
|
||||
|
||||
float get_freq_dynamic()
|
||||
{
|
||||
/* TODO: implement */
|
||||
reeturn get_freq();
|
||||
}
|
||||
|
||||
float get_freq()
|
||||
{
|
||||
/* First, try to obtain CPU frequency via dev.cpu.0.freq sysctl
|
||||
|
88
src/linux.c
88
src/linux.c
@ -659,11 +659,9 @@ __inline__ unsigned long long int rdtsc()
|
||||
return x;
|
||||
}
|
||||
static char *buffer = NULL;
|
||||
#else
|
||||
static char *frequency;
|
||||
#endif
|
||||
|
||||
float get_freq()
|
||||
float get_freq_dynamic()
|
||||
{
|
||||
#if defined(__i386) || defined(__x86_64)
|
||||
if (buffer == NULL)
|
||||
@ -689,28 +687,53 @@ float get_freq()
|
||||
|
||||
return (cycles[1] - cycles[0]) / microseconds;
|
||||
#else
|
||||
return get_freq();
|
||||
#endif
|
||||
}
|
||||
|
||||
#define CPUFREQ_CURRENT "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"
|
||||
|
||||
static char *frequency;
|
||||
|
||||
float get_freq()
|
||||
{
|
||||
FILE *f;
|
||||
char s[1000];
|
||||
if (frequency == NULL) {
|
||||
frequency = (char *) malloc(100);
|
||||
assert(frequency != NULL);
|
||||
}
|
||||
//char frequency[10];
|
||||
f = fopen(CPUFREQ_CURRENT, "r");
|
||||
if (f) {
|
||||
/* if there's a cpufreq /sys node, read the current
|
||||
* frequency there from this node; divice by 1000 to
|
||||
* get MHz
|
||||
*/
|
||||
double freq = 0;
|
||||
if (fgets(s, 1000,f)) {
|
||||
s[strlen(s)-1] = '\0';
|
||||
freq = strtod(s, NULL);
|
||||
}
|
||||
fclose(f);
|
||||
return (freq/1000);
|
||||
}
|
||||
|
||||
f = fopen("/proc/cpuinfo", "r"); //open the CPU information file
|
||||
//if (!f)
|
||||
// return;
|
||||
if (!f)
|
||||
return 0;
|
||||
while (fgets(s, 1000, f) != NULL){ //read the file
|
||||
if (strncmp(s, "clock", 5) == 0) { //and search for the cpu mhz
|
||||
//printf("%s", strchr(s, ':')+2);
|
||||
#if defined(__i386) || defined(__x86_64)
|
||||
if (strncmp(s, "cpu MHz", 5) == 0) { //and search for the cpu mhz
|
||||
#else
|
||||
if (strncmp(s, "clock", 5) == 0) { // this is different on ppc for some reason
|
||||
#endif
|
||||
strcpy(frequency, strchr(s, ':') + 2); //copy just the number
|
||||
frequency[strlen(frequency) - 1] = '\0'; // strip \n
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
//printf("%s\n", frequency);
|
||||
return strtod(frequency, (char **)NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1063,3 +1086,48 @@ void update_top()
|
||||
show_nice_processes = 1;
|
||||
process_find_top(info.cpu, info.memu);
|
||||
}
|
||||
|
||||
unsigned int get_diskio()
|
||||
{
|
||||
static unsigned int last = 0;
|
||||
static FILE* fp;
|
||||
|
||||
char buf[512];
|
||||
int minor;
|
||||
unsigned int current = 0;
|
||||
unsigned int reads, writes = 0;
|
||||
|
||||
if (!fp) {
|
||||
fp = fopen("/proc/diskstats", "r");
|
||||
} else {
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
/* read reads and writes from all disks (minor = 0), including
|
||||
* cd-roms and floppies, and summ them up
|
||||
*/
|
||||
current = 0;
|
||||
while (!feof(fp)) {
|
||||
fgets(buf, 512, fp);
|
||||
sscanf(buf, "%*u %u %*s %*u %*u %u %*u %*u %*u %u",
|
||||
&minor, &reads, &writes);
|
||||
if (minor == 0) {
|
||||
current += reads + writes;
|
||||
}
|
||||
}
|
||||
|
||||
/* since the values in /proc/diststats are absolute, we have
|
||||
* to substract our last reading. The numbers stand for
|
||||
* "sectors read", and we therefore have to divide by two to
|
||||
* get KB */
|
||||
int tot = ((double)(current-last)/2);
|
||||
if (last == 0) {
|
||||
/* initial case: return zero since we don't have a
|
||||
* 'last' value yet; it's a safe assumption that if
|
||||
* last isn't zero, since it's counting from the start */
|
||||
tot = 0;
|
||||
}
|
||||
last = current;
|
||||
|
||||
return tot;
|
||||
}
|
||||
|
20
src/x11.c
20
src/x11.c
@ -145,12 +145,13 @@ static Window find_window_to_draw()
|
||||
}
|
||||
|
||||
/* sets background to ParentRelative for the Window and all parents */
|
||||
void set_transparent_background(Window win)
|
||||
inline void set_transparent_background(Window win)
|
||||
{
|
||||
static int colour_set = -1;
|
||||
if (set_transparent) {
|
||||
Window parent = win;
|
||||
unsigned int i;
|
||||
for (i = 0; i < 16 && parent != RootWindow(display, screen); i++) {
|
||||
for (i = 0; i < 50 && parent != RootWindow(display, screen); i++) {
|
||||
Window r, *children;
|
||||
unsigned int n;
|
||||
|
||||
@ -158,11 +159,12 @@ void set_transparent_background(Window win)
|
||||
|
||||
XQueryTree(display, parent, &r, &parent, &children, &n);
|
||||
XFree(children);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else if (colour_set != background_colour) {
|
||||
XSetWindowBackground(display, win, background_colour);
|
||||
colour_set = background_colour;
|
||||
}
|
||||
XClearWindow(display, win);
|
||||
//XClearWindow(display, win);
|
||||
}
|
||||
|
||||
#if defined OWN_WINDOW
|
||||
@ -198,7 +200,7 @@ void init_window(int own_window, int w, int h, int l, int set_trans, int back_co
|
||||
XSetClassHint(display, window.window,
|
||||
&class_hints);
|
||||
|
||||
set_transparent_background(window.window);
|
||||
/*set_transparent_background(window.window);*/
|
||||
|
||||
XStoreName(display, window.window, "conky");
|
||||
|
||||
@ -290,10 +292,10 @@ void init_window(int own_window, int w, int h, int l, int set_trans, int back_co
|
||||
|
||||
/*set_transparent_background(window.window); must be done after double buffer stuff? */
|
||||
#ifdef OWN_WINDOW
|
||||
if (own_window) {
|
||||
set_transparent_background(window.window);
|
||||
/*if (own_window) {
|
||||
set_transparent_background(window.window);
|
||||
XClearWindow(display, window.window);
|
||||
}
|
||||
}*/
|
||||
#endif
|
||||
|
||||
XSelectInput(display, window.window, ExposureMask
|
||||
|
Loading…
Reference in New Issue
Block a user