ports/sysutils/conky/patches/patch-src_conky_c

87 lines
2.5 KiB
Text
Raw Normal View History

2023-08-16 22:26:55 +00:00
Correctly change update_interval based on whether AC is plugged in
or on battery for OpenBSD.
Index: src/conky.c
--- src/conky.c.orig
+++ src/conky.c
@@ -125,7 +125,7 @@
/* FIXME: apm_getinfo is unused here. maybe it's meant for common.c */
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
- || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
+ || defined(__OpenBSD__))
int apm_getinfo(int fd, apm_info_t aip);
char *get_apm_adapter(void);
char *get_apm_battery_life(void);
@@ -401,10 +401,6 @@ static int maximum_width;
#endif /* X11 */
-#ifdef __OpenBSD__
-static int sensor_device;
-#endif
-
long color0, color1, color2, color3, color4, color5, color6, color7, color8,
color9;
@@ -418,11 +414,13 @@ unsigned int text_buffer_size = DEFAULT_TEXT_BUFFER_SI
int utf8_mode = 0;
/* no buffers in used memory? */
-int no_buffers;
+int no_buffers = 0;
/* pad percentages to decimals? */
static int pad_percents = 0;
+enum IFUP_STRICTNESS ifup_strictness = IFUP_UP;
+
static char *global_text = 0;
char *get_global_text(void)
@@ -1015,7 +1013,7 @@ void generate_text_internal(char *p, int p_max_size,
get_powerbook_batt_info(p, p_max_size, obj->data.i);
}
#endif /* __linux__ */
-#if (defined(__FreeBSD__) || defined(__linux__))
+#if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__))
OBJ(if_up) {
if (!interface_up(obj)) {
DO_JUMP;
@@ -1899,7 +1897,7 @@ void generate_text_internal(char *p, int p_max_size,
}
#endif /* __linux__ */
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
- || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
+ || defined(__OpenBSD__))
OBJ(apm_adapter) {
char *msg;
@@ -3494,6 +3492,7 @@ static void main_loop(void)
info.looped = 0;
while (terminate == 0 && (total_run_times == 0 || info.looped < total_run_times)) {
if(update_interval_bat != NOBATTERY && update_interval_bat != update_interval_old) {
+#ifndef __OpenBSD__
char buf[max_user_text];
get_battery_short_status(buf, max_user_text, "BAT0");
@@ -3502,6 +3501,18 @@ static void main_loop(void)
} else {
update_interval = update_interval_old;
}
+#else
+ char *apm_status;
+ apm_status = get_apm_adapter();
+ if (apm_status != NULL) {
+ if (strcmp(apm_status,"off-line") == 0) {
+ update_interval = update_interval_bat;
+ } else {
+ update_interval = update_interval_old;
+ }
+ free(apm_status);
+ }
+#endif
}
info.looped++;