mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 12:27:52 +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
|
2009-02-15
|
||||||
* Added out_to_x
|
* Added out_to_x
|
||||||
|
|
||||||
|
8
README
8
README
@ -583,6 +583,14 @@ conky(1) conky(1)
|
|||||||
is BAT0).
|
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
|
1mbattery_bar (height),(width) (num)0m
|
||||||
Battery percentage remaining of ACPI battery in a bar. ACPI bat‐
|
Battery percentage remaining of ACPI battery in a bar. ACPI bat‐
|
||||||
tery number can be given as argument (default is BAT0).
|
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>
|
\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).
|
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
|
.TP
|
||||||
\fB\*(T<\fBbattery_bar\fR\*(T>\fR \*(T<\fB(height),(width) (num)\fR\*(T>
|
\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).
|
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>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</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>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command><option>battery_bar</option></command>
|
<command><option>battery_bar</option></command>
|
||||||
@ -2026,19 +2037,19 @@
|
|||||||
The following list shows sample usage of the templates defined above,
|
The following list shows sample usage of the templates defined above,
|
||||||
with the equivalent syntax when not using any template at all:
|
with the equivalent syntax when not using any template at all:
|
||||||
<table>
|
<table>
|
||||||
<tgroup cols="2">
|
<tgroup cols="2">
|
||||||
<thead>
|
<thead>
|
||||||
<row rowsep="1"><entry>using template</entry><entry>same without template</entry></row>
|
<row rowsep="1"><entry>using template</entry><entry>same without template</entry></row>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<row><entry>${template0 node name}</entry><entry>$nodename</entry></row>
|
<row><entry>${template0 node name}</entry><entry>$nodename</entry></row>
|
||||||
<row><entry>${template1 root /}</entry><entry>root: ${fs_free /} / ${fs_size /}</entry></row>
|
<row><entry>${template1 root /}</entry><entry>root: ${fs_free /} / ${fs_size /}</entry></row>
|
||||||
<row>
|
<row>
|
||||||
<entry><programlisting>${template1 ${template2\ disk\ root} /}</programlisting></entry>
|
<entry><programlisting>${template1 ${template2\ disk\ root} /}</programlisting></entry>
|
||||||
<entry><programlisting>disk root: ${fs_free /} / ${fs_size /}</programlisting></entry>
|
<entry><programlisting>disk root: ${fs_free /} / ${fs_size /}</programlisting></entry>
|
||||||
</row>
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</table>
|
</table>
|
||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -2503,8 +2514,8 @@
|
|||||||
Prints the song name in either the form "artist - title" or file name, depending on whats available
|
Prints the song name in either the form "artist - title" or file name, depending on whats available
|
||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command><option>if_xmms2_connected</option></command>
|
<command><option>if_xmms2_connected</option></command>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -2518,7 +2529,7 @@
|
|||||||
<option>api_userid api_key character_id</option>
|
<option>api_userid api_key character_id</option>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
Fetches your currently training skill from the Eve Online API servers (http://www.eve-online.com/) and displays the skill along with the remaining training time.
|
Fetches your currently training skill from the Eve Online API servers (http://www.eve-online.com/) and displays the skill along with the remaining training time.
|
||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@ -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);
|
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(const char *bat);
|
||||||
int get_battery_perct_bar(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 */
|
#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:
|
case OBJ_battery:
|
||||||
free(data.s);
|
free(data.s);
|
||||||
break;
|
break;
|
||||||
|
case OBJ_battery_short:
|
||||||
|
free(data.s);
|
||||||
|
break;
|
||||||
case OBJ_battery_time:
|
case OBJ_battery_time:
|
||||||
free(data.s);
|
free(data.s);
|
||||||
break;
|
break;
|
||||||
@ -1733,6 +1736,15 @@ static struct text_object *construct_text_object(const char *s,
|
|||||||
END OBJ(battery, 0)
|
END OBJ(battery, 0)
|
||||||
char bat[64];
|
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) {
|
if (arg) {
|
||||||
sscanf(arg, "%63s", bat);
|
sscanf(arg, "%63s", bat);
|
||||||
} else {
|
} else {
|
||||||
@ -3834,6 +3846,9 @@ static void generate_text_internal(char *p, int p_max_size,
|
|||||||
OBJ(battery_bar) {
|
OBJ(battery_bar) {
|
||||||
new_bar(p, obj->a, obj->b, get_battery_perct_bar(obj->data.s));
|
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__ */
|
#endif /* __OpenBSD__ */
|
||||||
|
|
||||||
OBJ(buffers) {
|
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)
|
int get_battery_perct(const char *bat)
|
||||||
{
|
{
|
||||||
static int rep = 0;
|
static int rep = 0;
|
||||||
|
@ -56,6 +56,7 @@ enum text_object_type {
|
|||||||
OBJ_battery_time,
|
OBJ_battery_time,
|
||||||
OBJ_battery_percent,
|
OBJ_battery_percent,
|
||||||
OBJ_battery_bar,
|
OBJ_battery_bar,
|
||||||
|
OBJ_battery_short,
|
||||||
#endif /* !__OpenBSD__ */
|
#endif /* !__OpenBSD__ */
|
||||||
OBJ_buffers,
|
OBJ_buffers,
|
||||||
OBJ_cached,
|
OBJ_cached,
|
||||||
|
Loading…
Reference in New Issue
Block a user