1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-24 11:55:43 +00:00

UTF-8, bug fixes, lots of goodies.

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@11 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2005-07-24 23:08:51 +00:00
parent 0019e23e33
commit 466dd6f5d4
9 changed files with 115 additions and 52 deletions

View File

@ -86,6 +86,9 @@ Roman Bogorodskiy <bogorodskiy at inbox dot ru>
Szymon Boniecki
Reads current LC_TIME
Walt Nelson <wnelsonjr at comcast dot net>
$freq fix
William DiPlacido <bimbasaari at yahoo dot com>
Frequency from /proc/cpuinfo
Some other SETI stuff

View File

@ -1,3 +1,10 @@
2005-07-24
* Conky now has UTF-8 support
* Fixed $freq for those with CPU scaling
* Fixed the problem with total_run_times
* Fixed alignment of bars and lines and stuff
* Reduced conky's memory usage (yay!)
2005-07-17
* Fixed a pile of bugs in configure script
* Added proper checking for headers in configure script

7
TODO
View File

@ -1,7 +0,0 @@
* look into utf8 support
* fix conky -i N stuff
* fix bars not being centred
* fix lines not being centred
* fix bug where memory stuff gets messed when mpd_host is defined
* fix bug with $freq

6
autogen.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
aclocal-1.9
autoheader-2.59
automake-1.9 -a
autoconf-2.59

2
configure vendored
View File

@ -6101,6 +6101,8 @@ _ACEOF
fi
echo "$as_me:$LINENO: checking for getloadavg" >&5
echo $ECHO_N "checking for getloadavg... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF

View File

@ -306,6 +306,20 @@ if test x$WANT_KSTAT = xyes; then
fi
fi
AC_DEFUN([AM_LANGINFO_CODESET],
[
AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
[AC_TRY_LINK([#include <langinfo.h>],
[char* cs = nl_langinfo(CODESET);],
am_cv_langinfo_codeset=yes,
am_cv_langinfo_codeset=no)
])
if test $am_cv_langinfo_codeset = yes; then
AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
fi
])
dnl
dnl Check getloadavg
dnl

51
conky.c
View File

@ -264,7 +264,7 @@ static void new_bar(char *buf, int w, int h, int usage)
static const char *scan_bar(const char *args, int *w, int *h)
{
*w = 0; /* zero width means all space that is available */
*h = 4;
*h = 6;
/* bar's argument is either height or height,width */
if (args) {
int n = 0;
@ -2136,13 +2136,10 @@ static void draw_string(const char *s)
i2=0;
for(i2=0;i2<(8-(1+pos)%8) && added <= max;i2++)
{
//printf("pos thinger %i added %i max %i\n",(8-(1+pos)%8), added, max);
//printf("adding tab to: %s\n", s);
tmpstring2[pos+i2] = ' ';
added++;
}
pos += i2;
//printf("not adding tab to: %s\n", s);
}
else
{
@ -2150,10 +2147,6 @@ static void draw_string(const char *s)
tmpstring2[pos] = tmpstring1[i];
pos++;
}
/* else {
tmpstring2[pos] = ' ';
pos++;
}*/
}
}
s = tmpstring2;
@ -2169,9 +2162,8 @@ static void draw_string(const char *s)
c2.color.green = c.green;
c2.color.blue = c.blue;
c2.color.alpha = font_alpha;
//printf("at: %i, %i\nstring: %s", cur_x, cur_y, s);
XftDrawString8(window.xftdraw, &c2, xftfont,
cur_x, cur_y, (XftChar8 *) s, strlen(s));
XftDrawStringUtf8(window.xftdraw, &c2, xftfont,
cur_x, cur_y, (XftChar8 *) s, strlen(s));
} else
#endif
{
@ -2220,8 +2212,8 @@ static void draw_line(char *s)
JoinMiter);
XDrawLine(display, window.drawable,
window.gc, cur_x,
cur_y - mid, cur_x + w,
cur_y - mid);
cur_y - mid/2, cur_x + w,
cur_y - mid/2);
}
break;
@ -2245,8 +2237,8 @@ static void draw_line(char *s)
ss, 2);
XDrawLine(display, window.drawable,
window.gc, cur_x,
cur_y - mid, cur_x + w,
cur_y - mid);
cur_y - mid/2, cur_x + w,
cur_y - mid/2);
}
break;
@ -2258,7 +2250,7 @@ static void draw_line(char *s)
specials[special_index].arg;
int by =
cur_y - (font_ascent() +
h) / 2 + 1;
h) / 2 - 1;
w = specials[special_index].width;
if (w == 0)
w = text_start_x +
@ -2456,8 +2448,8 @@ static void update_text()
static void main_loop()
{
Region region = XCreateRegion();
info.looped = 0;
while (total_run_times == 0 || info.looped < total_run_times) {
info.looped = -1;
while (total_run_times == 0 || info.looped < total_run_times-1) {
info.looped++;
XFlush(display);
@ -2828,7 +2820,7 @@ static void set_default_configurations(void)
info.net_avg_samples = 2;
info.memmax = 0;
#ifdef MPD
info.mpd.host = "localhost";
strcpy(info.mpd.host, "localhost");
info.mpd.port = 6600;
info.mpd.status = "Checking status...";
#endif
@ -3001,11 +2993,10 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, a) == 0)
#ifdef MPD
CONF("mpd_host") {
if (value)
info.
strcpy(info.
mpd.
host
=
value;
, value);
else
CONF_ERR}
CONF("mpd_port") {
@ -3384,6 +3375,20 @@ else
int main(int argc, char **argv) {
/* handle command line parameters that don't change configs */
char *s;
int utf8_mode = 0;
if (((s = getenv("LC_ALL")) && *s) ||
((s = getenv("LC_CTYPE")) && *s) ||
((s = getenv("LANG")) && *s)) {
if (strstr(s, "UTF-8"))
utf8_mode = 1;
}
if (!setlocale(LC_CTYPE, "")) {
fprintf(stderr, "Can't set the specified locale! "
"Check LANG, LC_CTYPE, LC_ALL.\n");
return 1;
}
while
(1)
{
@ -3465,7 +3470,7 @@ else
}
/* initalize X BEFORE we load config. (we need to so that 'screen' is set) */
init_X11
();
();
tmpstring1 = (char*)malloc(2*TEXT_BUFFER_SIZE);
tmpstring2 = (char*)malloc(2*TEXT_BUFFER_SIZE);

View File

@ -6,6 +6,9 @@
#include <sys/utsname.h>
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <langinfo.h>
#include <wchar.h>
#if defined(HAVE_CAIRO_H) && defined(HAVE_CAIRO_XLIB_H) && defined(WANT_CAIRO)
#define CAIRO
@ -20,7 +23,7 @@
#define TOP_PID 3
#define TOP_MEM 4
#define TEXT_BUFFER_SIZE (1024*4)
#define TEXT_BUFFER_SIZE 1024
#ifdef METAR
#include <metar.h>
@ -66,7 +69,7 @@ struct mpd_s {
char *status;
int volume;
unsigned int port;
char *host;
char host[128];
float progress;
int bitrate;
};

70
linux.c
View File

@ -628,31 +628,61 @@ char *get_adt746x_cpu()
return adt746x_cpu_state;
}
static char *frequency;
/* Thanks to "Walt Nelson" <wnelsonjr@comcast.net> */
/***********************************************************************/
/*
* $Id$
* This file is part of x86info.
* (C) 2001 Dave Jones.
*
* Licensed under the terms of the GNU GPL License version 2.
*
* Estimate CPU MHz routine by Andrea Arcangeli <andrea@suse.de>
* Small changes by David Sterba <sterd9am@ss1000.ms.mff.cuni.cz>
*
*/
__inline__ unsigned long long int rdtsc()
{
unsigned long long int x;
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
return x;
}
static char *buffer = NULL;
char *get_freq()
{
FILE *f;
char s[1000];
if (frequency == NULL) {
frequency = (char *) malloc(100);
assert(frequency != NULL);
}
//char frequency[10];
f = fopen("/proc/cpuinfo", "r"); //open the CPU information file
//if (!f)
// return;
while (fgets(s, 1000, f) != NULL) //read the file
if (strncmp(s, "cpu M", 5) == 0) { //and search for the cpu mhz
//printf("%s", strchr(s, ':')+2);
strcpy(frequency, strchr(s, ':') + 2); //copy just the number
frequency[strlen(frequency) - 1] = '\0'; // strip \n
break;
}
fclose(f);
return frequency;
if (buffer == NULL)
buffer = malloc(64);
struct timezone tz;
struct timeval tvstart, tvstop;
unsigned long long cycles[2]; /* gotta be 64 bit */
unsigned int microseconds; /* total time taken */
memset(&tz, 0, sizeof(tz));
/* get this function in cached memory */
gettimeofday(&tvstart, &tz);
cycles[0] = rdtsc();
gettimeofday(&tvstart, &tz);
/* we don't trust that this is any specific length of time */
usleep(100);
cycles[1] = rdtsc();
gettimeofday(&tvstop, &tz);
microseconds = ((tvstop.tv_sec-tvstart.tv_sec)*1000000) +
(tvstop.tv_usec-tvstart.tv_usec);
sprintf(buffer, "%lldMHz",
(cycles[1]-cycles[0])/microseconds);
return buffer;
}
#define ACPI_FAN_DIR "/proc/acpi/fan/"
static char *acpi_fan_state;