mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
Patch to add $battery_short variable.
This commit is contained in:
parent
b4cd98868f
commit
b516e19440
@ -1,3 +1,6 @@
|
||||
2009-02-17
|
||||
* Added $battery_short patch, sf.net id #2300911 (thanks Swoog)
|
||||
|
||||
2009-02-15
|
||||
* Added out_to_x
|
||||
|
||||
|
8
README
8
README
@ -583,6 +583,14 @@ conky(1) conky(1)
|
||||
is BAT0).
|
||||
|
||||
|
||||
1mbattery_short (num)0m
|
||||
Battery status and remaining percentage capacity of ACPI or APM
|
||||
battery. ACPI battery number can be given as argument (default
|
||||
is BAT0). This mode display a short status, which means that C
|
||||
is displayed instead of charging and D is displayed instead of
|
||||
discharging.
|
||||
|
||||
|
||||
1mbattery_bar (height),(width) (num)0m
|
||||
Battery percentage remaining of ACPI battery in a bar. ACPI bat‐
|
||||
tery number can be given as argument (default is BAT0).
|
||||
|
@ -529,6 +529,11 @@ The current volume fetched from Audacious
|
||||
\fB\*(T<\fBbattery\fR\*(T>\fR \*(T<\fB(num)\fR\*(T>
|
||||
Battery status and remaining percentage capacity of ACPI or APM battery. ACPI battery number can be given as argument (default is BAT0).
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBbattery_short\fR\*(T>\fR \*(T<\fB(num)\fR\*(T>
|
||||
Battery status and remaining percentage capacity of ACPI or APM battery. ACPI battery number can be given as argument (default is BAT0).
|
||||
This mode display a short status, which means that C is displayed instead of charging and D is displayed instead of discharging.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBbattery_bar\fR\*(T>\fR \*(T<\fB(height),(width) (num)\fR\*(T>
|
||||
Battery percentage remaining of ACPI battery in a bar. ACPI battery number can be given as argument (default is BAT0).
|
||||
|
@ -251,6 +251,17 @@
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>battery_short</option></command>
|
||||
<option>(num)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Battery status and remaining percentage capacity of ACPI or APM battery. ACPI battery number can be given as argument (default is BAT0).
|
||||
This mode display a short status, which means that C is displayed instead of charging and D is displayed instead of discharging.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>battery_bar</option></command>
|
||||
|
@ -92,5 +92,6 @@ void get_acpi_fan(char *, size_t);
|
||||
void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item);
|
||||
int get_battery_perct(const char *bat);
|
||||
int get_battery_perct_bar(const char *bat);
|
||||
void get_battery_short_status(char *buf, unsigned int n, const char *bat);
|
||||
|
||||
#endif /* _COMMON_H */
|
||||
|
15
src/conky.c
15
src/conky.c
@ -1438,6 +1438,9 @@ static void free_text_objects(struct text_object *root)
|
||||
case OBJ_battery:
|
||||
free(data.s);
|
||||
break;
|
||||
case OBJ_battery_short:
|
||||
free(data.s);
|
||||
break;
|
||||
case OBJ_battery_time:
|
||||
free(data.s);
|
||||
break;
|
||||
@ -1733,6 +1736,15 @@ static struct text_object *construct_text_object(const char *s,
|
||||
END OBJ(battery, 0)
|
||||
char bat[64];
|
||||
|
||||
if (arg) {
|
||||
sscanf(arg, "%63s", bat);
|
||||
} else {
|
||||
strcpy(bat, "BAT0");
|
||||
}
|
||||
obj->data.s = strndup(bat, text_buffer_size);
|
||||
END OBJ(battery_short, 0)
|
||||
char bat[64];
|
||||
|
||||
if (arg) {
|
||||
sscanf(arg, "%63s", bat);
|
||||
} else {
|
||||
@ -3834,6 +3846,9 @@ static void generate_text_internal(char *p, int p_max_size,
|
||||
OBJ(battery_bar) {
|
||||
new_bar(p, obj->a, obj->b, get_battery_perct_bar(obj->data.s));
|
||||
}
|
||||
OBJ(battery_short) {
|
||||
get_battery_short_status(p, p_max_size, obj->data.s);
|
||||
}
|
||||
#endif /* __OpenBSD__ */
|
||||
|
||||
OBJ(buffers) {
|
||||
|
12
src/linux.c
12
src/linux.c
@ -1842,6 +1842,18 @@ void set_return_value(char *buffer, unsigned int n, int item, int idx)
|
||||
}
|
||||
}
|
||||
|
||||
void get_battery_short_status(char *buffer, unsigned int n, const char *bat)
|
||||
{
|
||||
get_battery_stuff(buffer, n, bat, BATTERY_STATUS);
|
||||
if (0 == strncmp("charging", buffer, 8)) {
|
||||
buffer[0] = 'C';
|
||||
memmove(buffer + 1, buffer + 8, n - 8);
|
||||
} else if (0 == strncmp("discharging", buffer, 11)) {
|
||||
buffer[0] = 'D';
|
||||
memmove(buffer + 1, buffer + 11, n - 11);
|
||||
}
|
||||
}
|
||||
|
||||
int get_battery_perct(const char *bat)
|
||||
{
|
||||
static int rep = 0;
|
||||
|
@ -56,6 +56,7 @@ enum text_object_type {
|
||||
OBJ_battery_time,
|
||||
OBJ_battery_percent,
|
||||
OBJ_battery_bar,
|
||||
OBJ_battery_short,
|
||||
#endif /* !__OpenBSD__ */
|
||||
OBJ_buffers,
|
||||
OBJ_cached,
|
||||
|
Loading…
Reference in New Issue
Block a user