mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-25 04:06:03 +00:00
tztime patch
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@677 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
1c0acf9f50
commit
16e8431a25
3
AUTHORS
3
AUTHORS
@ -34,6 +34,9 @@ dan-h <dan-h at users dot sourceforge dot net>
|
|||||||
David McCabe
|
David McCabe
|
||||||
utime
|
utime
|
||||||
|
|
||||||
|
Ram Yalamanchili
|
||||||
|
tztime
|
||||||
|
|
||||||
Daniel Thiele <dthiele at gmx dot net>
|
Daniel Thiele <dthiele at gmx dot net>
|
||||||
APM support for FreeBSD
|
APM support for FreeBSD
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
2006-07-13
|
||||||
|
* Added tztime patch to show time in arbitrary time zones (thanks Ram
|
||||||
|
Yalamanchili)
|
||||||
|
|
||||||
2006-06-07
|
2006-06-07
|
||||||
* Small battery fix (thanks Nexox, sf.net patch 1500014)
|
* Small battery fix (thanks Nexox, sf.net patch 1500014)
|
||||||
* Fixed order of variables/objects in docs (thanks Peter Tarjan)
|
* Fixed order of variables/objects in docs (thanks Peter Tarjan)
|
||||||
|
@ -889,6 +889,10 @@ Displays last N lines of supplied text text file. If interval is not supplied, C
|
|||||||
\fBtime\fR \fB(format)\fR
|
\fBtime\fR \fB(format)\fR
|
||||||
Local time, see man strftime to get more information about format
|
Local time, see man strftime to get more information about format
|
||||||
|
|
||||||
|
.TP
|
||||||
|
\fBtztime\fR \fB(timezone) (format)\fR
|
||||||
|
Local time for specified timezone, see man strftime to get more information about format. The timezone argument is specified in similar fashion as TZ environment variable. For hints, look in /usr/share/zoneinfo. e.g. US/Pacific, Europe/Zurich, etc.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
\fBtotaldown\fR \fBnet\fR
|
\fBtotaldown\fR \fBnet\fR
|
||||||
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.
|
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.
|
||||||
|
@ -1194,6 +1194,26 @@
|
|||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command><option>utime</option></command>
|
||||||
|
<option>(format)</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
Display time in UTC (universal coordinate time).
|
||||||
|
<para></para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command><option>tztime</option></command>
|
||||||
|
<option>(timezone) (format)</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
Local time for specified timezone, see man strftime to get more information about format. The timezone argument is specified in similar fashion as TZ environment variable. For hints, look in /usr/share/zoneinfo. e.g. US/Pacific, Europe/Zurich, etc.
|
||||||
|
<para></para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command><option>totaldown</option></command>
|
<command><option>totaldown</option></command>
|
||||||
|
47
src/conky.c
47
src/conky.c
@ -934,6 +934,7 @@ enum text_object_type {
|
|||||||
OBJ_text,
|
OBJ_text,
|
||||||
OBJ_time,
|
OBJ_time,
|
||||||
OBJ_utime,
|
OBJ_utime,
|
||||||
|
OBJ_tztime,
|
||||||
OBJ_totaldown,
|
OBJ_totaldown,
|
||||||
OBJ_totalup,
|
OBJ_totalup,
|
||||||
OBJ_updates,
|
OBJ_updates,
|
||||||
@ -1050,6 +1051,12 @@ struct text_object {
|
|||||||
unsigned char loadavg[3];
|
unsigned char loadavg[3];
|
||||||
unsigned int cpu_index;
|
unsigned int cpu_index;
|
||||||
struct mail_s *mail;
|
struct mail_s *mail;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
char *tz; /* timezone variable */
|
||||||
|
char *fmt; /* time display formatting */
|
||||||
|
} tztime;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct fs_stat *fs;
|
struct fs_stat *fs;
|
||||||
int w, h;
|
int w, h;
|
||||||
@ -1707,6 +1714,12 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
|
|||||||
free(objs[i].data.s);
|
free(objs[i].data.s);
|
||||||
break;
|
break;
|
||||||
case OBJ_utime:
|
case OBJ_utime:
|
||||||
|
free(objs[i].data.s);
|
||||||
|
break;
|
||||||
|
case OBJ_tztime:
|
||||||
|
free(objs[i].data.tztime.tz);
|
||||||
|
free(objs[i].data.tztime.fmt);
|
||||||
|
break;
|
||||||
case OBJ_imap:
|
case OBJ_imap:
|
||||||
free(info.mail);
|
free(info.mail);
|
||||||
break;
|
break;
|
||||||
@ -2651,6 +2664,21 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
|
|||||||
obj->data.i2c.devtype);
|
obj->data.i2c.devtype);
|
||||||
END OBJ(time, 0) obj->data.s = strdup(arg ? arg : "%F %T");
|
END OBJ(time, 0) obj->data.s = strdup(arg ? arg : "%F %T");
|
||||||
END OBJ(utime, 0) obj->data.s = strdup(arg ? arg : "%F %T");
|
END OBJ(utime, 0) obj->data.s = strdup(arg ? arg : "%F %T");
|
||||||
|
END OBJ(tztime, 0)
|
||||||
|
char buf1[256], buf2[256], *fmt, *tz;
|
||||||
|
fmt = tz = NULL;
|
||||||
|
if (arg) {
|
||||||
|
int nArgs = sscanf(arg, "%255s %255[^\n]", buf1, buf2);
|
||||||
|
switch (nArgs) {
|
||||||
|
case 2:
|
||||||
|
tz = buf1;
|
||||||
|
case 1:
|
||||||
|
fmt = buf2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
obj->data.tztime.fmt = strdup(fmt ? fmt : "%F %T");
|
||||||
|
obj->data.tztime.tz = tz ? strdup(tz) : NULL;
|
||||||
#ifdef HAVE_ICONV
|
#ifdef HAVE_ICONV
|
||||||
END OBJ(iconv_start, 0)
|
END OBJ(iconv_start, 0)
|
||||||
if (iconv_converting) {
|
if (iconv_converting) {
|
||||||
@ -4102,6 +4130,25 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
|
|||||||
struct tm *tm = gmtime(&t);
|
struct tm *tm = gmtime(&t);
|
||||||
strftime(p, p_max_size, obj->data.s, tm);
|
strftime(p, p_max_size, obj->data.s, tm);
|
||||||
}
|
}
|
||||||
|
OBJ(tztime) {
|
||||||
|
char* oldTZ = NULL;
|
||||||
|
if (obj->data.tztime.tz) {
|
||||||
|
oldTZ = getenv("TZ");
|
||||||
|
setenv("TZ", obj->data.tztime.tz, 1);
|
||||||
|
tzset();
|
||||||
|
}
|
||||||
|
time_t t = time(NULL);
|
||||||
|
struct tm *tm = localtime(&t);
|
||||||
|
setlocale(LC_TIME, "");
|
||||||
|
strftime(p, p_max_size, obj->data.tztime.fmt, tm);
|
||||||
|
if (oldTZ) {
|
||||||
|
setenv("TZ", oldTZ, 1);
|
||||||
|
tzset();
|
||||||
|
} else {
|
||||||
|
unsetenv("TZ");
|
||||||
|
}
|
||||||
|
// Needless to free oldTZ since getenv gives ptr to static data
|
||||||
|
}
|
||||||
OBJ(totaldown) {
|
OBJ(totaldown) {
|
||||||
human_readable(obj->data.net->recv, p,
|
human_readable(obj->data.net->recv, p,
|
||||||
255);
|
255);
|
||||||
|
Loading…
Reference in New Issue
Block a user