1 /* Conky, a system monitor, based on torsmo
3 * Any original torsmo code is licensed under the BSD license
5 * All code written since the fork of torsmo is licensed under the GPL
7 * Please see COPYING for details
9 * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
11 * All rights reserved.
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * vim: ts=4 sw=4 noet ai cindent syntax=c
29 #include <sys/ioctl.h>
30 #include <sys/dkstat.h>
31 #include <sys/param.h>
32 #include <sys/resource.h>
33 #include <sys/socket.h>
35 #include <sys/sysctl.h>
37 #include <sys/types.h>
41 #include <net/if_mib.h>
42 #include <net/if_media.h>
43 #include <net/if_var.h>
50 #include <dev/wi/if_wavelan_ieee.h>
51 #include <dev/acpica/acpiio.h>
59 #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
60 #define KELVTOC(x) ((x - 2732) / 10.0)
61 #define MAXSHOWDEVS 16
67 __attribute__((gnu_inline)) inline void
68 proc_find_top(struct process **cpu, struct process **mem);
70 static short cpu_setup = 0;
72 static int getsysctl(const char *name, void *ptr, size_t len)
76 if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) {
80 if (nlen != len && errno == ENOMEM) {
87 struct ifmibdata *data = NULL;
90 static int swapmode(unsigned long *retavail, unsigned long *retfree)
93 unsigned long pagesize = getpagesize();
94 struct kvm_swap swapary[1];
99 #define CONVERT(v) ((quad_t)(v) * (pagesize / 1024))
101 n = kvm_getswapinfo(kd, swapary, 1, 0);
102 if (n < 0 || swapary[0].ksw_total == 0) {
106 *retavail = CONVERT(swapary[0].ksw_total);
107 *retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
109 n = (int) ((double) swapary[0].ksw_used * 100.0 /
110 (double) swapary[0].ksw_total);
115 void prepare_update(void)
119 void update_uptime(void)
121 int mib[2] = { CTL_KERN, KERN_BOOTTIME };
122 struct timeval boottime;
124 size_t size = sizeof(boottime);
126 if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
127 && (boottime.tv_sec != 0)) {
129 info.uptime = now - boottime.tv_sec;
131 fprintf(stderr, "Could not get uptime\n");
136 int check_mount(char *s)
138 struct statfs *mntbuf;
141 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
142 for (i = mntsize - 1; i >= 0; i--) {
143 if (strcmp(mntbuf[i].f_mntonname, s) == 0) {
151 void update_meminfo(void)
153 u_int total_pages, inactive_pages, free_pages;
154 unsigned long swap_avail, swap_free;
156 int pagesize = getpagesize();
158 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages)) {
159 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_page_count\"\n");
162 if (GETSYSCTL("vm.stats.vm.v_free_count", free_pages)) {
163 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_free_count\"\n");
166 if (GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages)) {
167 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_inactive_count\"\n");
170 info.memmax = total_pages * (pagesize >> 10);
171 info.mem = (total_pages - free_pages - inactive_pages) * (pagesize >> 10);
172 info.memeasyfree = info.memfree = info.memmax - info.mem;
174 if ((swapmode(&swap_avail, &swap_free)) >= 0) {
175 info.swapmax = swap_avail;
176 info.swap = (swap_avail - swap_free);
177 info.swapfree = swap_free;
185 void update_net_stats(void)
189 long long r, t, last_recv, last_trans;
190 struct ifaddrs *ifap, *ifa;
194 delta = current_update_time - last_update_time;
195 if (delta <= 0.0001) {
199 if (getifaddrs(&ifap) < 0) {
203 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
204 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
206 if (ifa->ifa_flags & IFF_UP) {
207 struct ifaddrs *iftmp;
210 last_recv = ns->recv;
211 last_trans = ns->trans;
213 if (ifa->ifa_addr->sa_family != AF_LINK) {
217 for (iftmp = ifa->ifa_next;
218 iftmp != NULL && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
219 iftmp = iftmp->ifa_next) {
220 if (iftmp->ifa_addr->sa_family == AF_INET) {
221 memcpy(&(ns->addr), iftmp->ifa_addr,
222 iftmp->ifa_addr->sa_len);
226 ifd = (struct if_data *) ifa->ifa_data;
230 if (r < ns->last_read_recv) {
231 ns->recv += ((long long) 4294967295U - ns->last_read_recv) + r;
233 ns->recv += (r - ns->last_read_recv);
236 ns->last_read_recv = r;
238 if (t < ns->last_read_trans) {
239 ns->trans += ((long long) 4294967295U -
240 ns->last_read_trans) + t;
242 ns->trans += (t - ns->last_read_trans);
245 ns->last_read_trans = t;
247 /* calculate speeds */
248 ns->recv_speed = (ns->recv - last_recv) / delta;
249 ns->trans_speed = (ns->trans - last_trans) / delta;
258 void update_total_processes(void)
262 kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
264 info.procs = n_processes;
267 void update_running_processes(void)
269 struct kinfo_proc *p;
273 p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
274 for (i = 0; i < n_processes; i++) {
275 #if (__FreeBSD__ < 5) && (__FreeBSD_kernel__ < 5)
276 if (p[i].kp_proc.p_stat == SRUN) {
278 if (p[i].ki_stat == SRUN) {
284 info.run_procs = cnt;
287 struct cpu_load_struct {
288 unsigned long load[5];
291 struct cpu_load_struct fresh = { {0, 0, 0, 0, 0} };
292 long cpu_used, oldtotal, oldused;
294 void get_cpu_count(void)
296 /* int cpu_count = 0; */
298 /* XXX: FreeBSD doesn't allow to get per CPU load stats on SMP machines.
299 * It's possible to get a CPU count, but as we fulfill only
300 * info.cpu_usage[0], it's better to report there's only one CPU.
301 * It should fix some bugs (e.g. cpugraph) */
303 if (GETSYSCTL("hw.ncpu", cpu_count) == 0) {
304 info.cpu_count = cpu_count;
309 info.cpu_usage = malloc(info.cpu_count * sizeof(float));
310 if (info.cpu_usage == NULL) {
311 CRIT_ERR(NULL, NULL, "malloc");
315 /* XXX: SMP support */
316 void update_cpu_usage(void)
319 long cp_time[CPUSTATES];
320 size_t cp_len = sizeof(cp_time);
322 /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */
323 if ((cpu_setup == 0) || (!info.cpu_usage)) {
328 if (sysctlbyname("kern.cp_time", &cp_time, &cp_len, NULL, 0) < 0) {
329 fprintf(stderr, "Cannot get kern.cp_time");
332 fresh.load[0] = cp_time[CP_USER];
333 fresh.load[1] = cp_time[CP_NICE];
334 fresh.load[2] = cp_time[CP_SYS];
335 fresh.load[3] = cp_time[CP_IDLE];
336 fresh.load[4] = cp_time[CP_IDLE];
338 used = fresh.load[0] + fresh.load[1] + fresh.load[2];
339 total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
341 if ((total - oldtotal) != 0) {
342 info.cpu_usage[0] = ((double) (used - oldused)) /
343 (double) (total - oldtotal);
345 info.cpu_usage[0] = 0;
352 void update_load_average(void)
358 info.loadavg[0] = (double) v[0];
359 info.loadavg[1] = (double) v[1];
360 info.loadavg[2] = (double) v[2];
363 double get_acpi_temperature(int fd)
368 if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
370 "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
374 return KELVTOC(temp);
377 static void get_battery_stats(int *battime, int *batcapacity, int *batstate, int *ac) {
378 if (battime && GETSYSCTL("hw.acpi.battery.time", *battime)) {
379 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.time\"\n");
381 if (batcapacity && GETSYSCTL("hw.acpi.battery.life", *batcapacity)) {
382 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.life\"\n");
384 if (batstate && GETSYSCTL("hw.acpi.battery.state", *batstate)) {
385 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.state\"\n");
387 if (ac && GETSYSCTL("hw.acpi.acline", *ac)) {
388 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
392 void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
394 int battime, batcapacity, batstate, ac;
397 get_battery_stats(&battime, &batcapacity, &batstate, &ac);
399 if (batstate != 1 && batstate != 2 && batstate != 0 && batstate != 7)
400 fprintf(stderr, "Unknown battery state %d!\n", batstate);
401 else if (batstate != 1 && ac == 0)
402 fprintf(stderr, "Battery charging while not on AC!\n");
403 else if (batstate == 1 && ac == 1)
404 fprintf(stderr, "Battery discharing while on AC!\n");
408 if (batstate == 1 && battime != -1)
409 snprintf(buf, n, "%d:%2.2d", battime / 60, battime % 60);
412 if (batstate == 1) // Discharging
413 snprintf(buf, n, "remaining %d%%", batcapacity);
415 snprintf(buf, n, batstate == 2 ? "charging (%d%%)" :
416 (batstate == 7 ? "absent/on AC" : "charged (%d%%)"),
420 fprintf(stderr, "Unknown requested battery stat %d\n", item);
424 static int check_bat(const char *bat)
426 int batnum, numbatts;
428 if (GETSYSCTL("hw.acpi.battery.units", numbatts)) {
429 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.units\"\n");
433 fprintf(stderr, "No battery unit detected\n");
436 if (!bat || (batnum = strtol(bat, &endptr, 10)) < 0 ||
437 bat == endptr || batnum > numbatts) {
438 fprintf(stderr, "Wrong battery unit %s requested\n", bat ? bat : "");
444 int get_battery_perct(const char *bat)
446 union acpi_battery_ioctl_arg battio;
448 int designcap, lastfulcap, batperct;
450 if ((battio.unit = batnum = check_bat(bat)) < 0)
452 if ((acpifd = open("/dev/acpi", O_RDONLY)) < 0) {
453 fprintf(stderr, "Can't open ACPI device\n");
456 if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) == -1) {
457 fprintf(stderr, "Unable to get info for battery unit %d\n", batnum);
461 designcap = battio.bif.dcap;
462 lastfulcap = battio.bif.lfcap;
463 batperct = (designcap > 0 && lastfulcap > 0) ?
464 (int) (((float) lastfulcap / designcap) * 100) : 0;
465 return batperct > 100 ? 100 : batperct;
468 int get_battery_perct_bar(const char *bar)
470 int batperct = get_battery_perct(bar);
471 return (int)(batperct * 2.56 - 1);
474 int open_acpi_temperature(const char *name)
477 /* Not applicable for FreeBSD. */
481 void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
485 if (!p_client_buffer || client_buffer_size <= 0) {
489 if (GETSYSCTL("hw.acpi.acline", state)) {
490 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
495 strncpy(p_client_buffer, "Running on AC Power", client_buffer_size);
497 strncpy(p_client_buffer, "Running on battery", client_buffer_size);
501 void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
503 /* not implemented */
504 if (p_client_buffer && client_buffer_size > 0) {
505 memset(p_client_buffer, 0, client_buffer_size);
509 void get_adt746x_cpu(char *p_client_buffer, size_t client_buffer_size)
511 /* not implemented */
512 if (p_client_buffer && client_buffer_size > 0) {
513 memset(p_client_buffer, 0, client_buffer_size);
517 void get_adt746x_fan(char *p_client_buffer, size_t client_buffer_size)
519 /* not implemented */
520 if (p_client_buffer && client_buffer_size > 0) {
521 memset(p_client_buffer, 0, client_buffer_size);
525 /* rdtsc() and get_freq_dynamic() copied from linux.c */
527 #if defined(__i386) || defined(__x86_64)
528 __attribute__((gnu_inline)) inline unsigned long long int rdtsc(void)
530 unsigned long long int x;
532 __asm__ volatile(".byte 0x0f, 0x31":"=A" (x));
537 /* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */
538 void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
539 const char *p_format, int divisor)
541 #if defined(__i386) || defined(__x86_64)
543 struct timeval tvstart, tvstop;
544 unsigned long long cycles[2]; /* gotta be 64 bit */
545 unsigned int microseconds; /* total time taken */
547 memset(&tz, 0, sizeof(tz));
549 /* get this function in cached memory */
550 gettimeofday(&tvstart, &tz);
552 gettimeofday(&tvstart, &tz);
554 /* we don't trust that this is any specific length of time */
557 gettimeofday(&tvstop, &tz);
558 microseconds = ((tvstop.tv_sec - tvstart.tv_sec) * 1000000) +
559 (tvstop.tv_usec - tvstart.tv_usec);
561 snprintf(p_client_buffer, client_buffer_size, p_format,
562 (float) ((cycles[1] - cycles[0]) / microseconds) / divisor);
564 get_freq(p_client_buffer, client_buffer_size, p_format, divisor, 1);
569 char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_format,
570 int divisor, unsigned int cpu)
575 freq_sysctl = (char *) calloc(16, sizeof(char));
576 if (freq_sysctl == NULL) {
580 snprintf(freq_sysctl, 16, "dev.cpu.%d.freq", (cpu - 1));
582 if (!p_client_buffer || client_buffer_size <= 0 || !p_format
587 if (GETSYSCTL(freq_sysctl, freq) == 0) {
588 snprintf(p_client_buffer, client_buffer_size, p_format,
589 (float) freq / divisor);
591 snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
598 void update_top(void)
600 proc_find_top(info.cpu, info.memu);
604 void update_wifi_stats(void)
606 struct ifreq ifr; /* interface stats */
609 struct ifaddrs *ifap, *ifa;
610 struct ifmediareq ifmr;
613 /* Get iface table */
614 if (getifaddrs(&ifap) < 0) {
618 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
619 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
621 s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
624 bzero(&ifmr, sizeof(ifmr));
625 strlcpy(ifmr.ifm_name, ifa->ifa_name, IFNAMSIZ);
626 if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) {
631 /* We can monitor only wireless interfaces
632 * which are not in hostap mode */
633 if ((ifmr.ifm_active & IFM_IEEE80211)
634 && !(ifmr.ifm_active & IFM_IEEE80211_HOSTAP)) {
636 bzero(&ifr, sizeof(ifr));
637 strlcpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ);
638 wireq.wi_type = WI_RID_COMMS_QUALITY;
639 wireq.wi_len = WI_MAX_DATALEN;
640 ifr.ifr_data = (void *) &wireq;
642 if (ioctl(s, SIOCGWAVELAN, (caddr_t) &ifr) < 0) {
643 perror("ioctl (getting wi status)");
647 /* wi_val[0] = quality
649 * wi_val[2] = noise */
650 ns->linkstatus = (int) wireq.wi_val[1];
658 void update_diskio(void)
660 int devs_count, num_selected, num_selections, dn;
661 struct device_selection *dev_select = NULL;
662 long select_generation;
663 static struct statinfo statinfo_cur;
664 char device_name[text_buffer_size];
665 struct diskio_stat *cur;
666 unsigned int reads, writes;
667 unsigned int total_reads = 0, total_writes = 0;
670 memset(&statinfo_cur, 0, sizeof(statinfo_cur));
671 statinfo_cur.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
672 stats.current = stats.current_read = stats.current_write = 0;
674 if (devstat_getdevs(NULL, &statinfo_cur) < 0) {
675 free(statinfo_cur.dinfo);
679 devs_count = statinfo_cur.dinfo->numdevs;
680 if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
681 &select_generation, statinfo_cur.dinfo->generation,
682 statinfo_cur.dinfo->devices, devs_count, NULL, 0, NULL, 0,
683 DS_SELECT_ONLY, MAXSHOWDEVS, 1) >= 0) {
684 for (dn = 0; dn < devs_count; dn++) {
688 di = dev_select[dn].position;
689 dev = &statinfo_cur.dinfo->devices[di];
690 snprintf(device_name, text_buffer_size, "%s%d",
691 dev_select[dn].device_name, dev_select[dn].unit_number);
693 total_reads += (reads = dev->bytes[DEVSTAT_READ] / 512);
694 total_writes += (writes = dev->bytes[DEVSTAT_WRITE] / 512);
695 for (cur = stats.next; cur; cur = cur->next) {
696 if (cur->dev && !strcmp(device_name, cur->dev)) {
697 update_diskio_values(cur, reads, writes);
702 update_diskio_values(&stats, total_reads, total_writes);
707 free(statinfo_cur.dinfo);
710 /* While topless is obviously better, top is also not bad. */
712 int comparecpu(const void *a, const void *b)
714 if (((const struct process *)a)->amount > ((const struct process *)b)->amount) {
716 } else if (((const struct process *)a)->amount < ((const struct process *)b)->amount) {
723 int comparemem(const void *a, const void *b)
725 if (((const struct process *)a)->totalmem > ((const struct process *)b)->totalmem) {
727 } else if (((const struct process *)a)->totalmem < ((const struct process *)b)->totalmem) {
734 __attribute__((gnu_inline)) inline void
735 proc_find_top(struct process **cpu, struct process **mem)
737 struct kinfo_proc *p;
740 struct process *processes;
744 /* we get total pages count again to be sure it is up to date */
745 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages) != 0) {
746 CRIT_ERR(NULL, NULL, "Cannot read sysctl \"vm.stats.vm.v_page_count\"");
749 p = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_processes);
750 processes = malloc(n_processes * sizeof(struct process));
752 for (i = 0; i < n_processes; i++) {
753 if (!((p[i].ki_flag & P_SYSTEM)) && p[i].ki_comm != NULL) {
754 processes[j].pid = p[i].ki_pid;
755 processes[j].name = strndup(p[i].ki_comm, text_buffer_size);
756 processes[j].amount = 100.0 * p[i].ki_pctcpu / FSCALE;
757 processes[j].totalmem = (float) (p[i].ki_rssize /
758 (float) total_pages) * 100.0;
759 processes[j].vsize = p[i].ki_size;
760 processes[j].rss = (p[i].ki_rssize * getpagesize());
765 qsort(processes, j - 1, sizeof(struct process), comparemem);
766 for (i = 0; i < 10 && i < n_processes; i++) {
767 struct process *tmp, *ttmp;
769 tmp = malloc(sizeof(struct process));
770 tmp->pid = processes[i].pid;
771 tmp->amount = processes[i].amount;
772 tmp->totalmem = processes[i].totalmem;
773 tmp->name = strndup(processes[i].name, text_buffer_size);
774 tmp->rss = processes[i].rss;
775 tmp->vsize = processes[i].vsize;
785 qsort(processes, j - 1, sizeof(struct process), comparecpu);
786 for (i = 0; i < 10 && i < n_processes; i++) {
787 struct process *tmp, *ttmp;
789 tmp = malloc(sizeof(struct process));
790 tmp->pid = processes[i].pid;
791 tmp->amount = processes[i].amount;
792 tmp->totalmem = processes[i].totalmem;
793 tmp->name = strndup(processes[i].name, text_buffer_size);
794 tmp->rss = processes[i].rss;
795 tmp->vsize = processes[i].vsize;
805 #if defined(FREEBSD_DEBUG)
806 printf("=====\nmem\n");
807 for (i = 0; i < 10; i++) {
808 printf("%d: %s(%d) %.2f %ld %ld\n", i, mem[i]->name,
809 mem[i]->pid, mem[i]->totalmem, mem[i]->vsize, mem[i]->rss);
813 for (i = 0; i < j; i++) {
814 free(processes[i].name);
819 #if defined(i386) || defined(__i386__)
820 #define APMDEV "/dev/apm"
821 #define APM_UNKNOWN 255
823 int apm_getinfo(int fd, apm_info_t aip)
825 if (ioctl(fd, APMIO_GETINFO, aip) == -1) {
832 char *get_apm_adapter(void)
835 struct apm_info a_info;
838 out = (char *) calloc(16, sizeof(char));
840 fd = open(APMDEV, O_RDONLY);
842 strncpy(out, "ERR", 16);
846 if (apm_getinfo(fd, &a_info) != 0) {
848 strncpy(out, "ERR", 16);
853 switch (a_info.ai_acline) {
855 strncpy(out, "off-line", 16);
859 if (a_info.ai_batt_stat == 3) {
860 strncpy(out, "charging", 16);
863 strncpy(out, "on-line", 16);
868 strncpy(out, "unknown", 16);
874 char *get_apm_battery_life(void)
878 struct apm_info a_info;
881 out = (char *) calloc(16, sizeof(char));
883 fd = open(APMDEV, O_RDONLY);
885 strncpy(out, "ERR", 16);
889 if (apm_getinfo(fd, &a_info) != 0) {
891 strncpy(out, "ERR", 16);
896 batt_life = a_info.ai_batt_life;
897 if (batt_life == APM_UNKNOWN) {
898 strncpy(out, "unknown", 16);
899 } else if (batt_life <= 100) {
900 snprintf(out, 16, "%d%%", batt_life);
903 strncpy(out, "ERR", 16);
909 char *get_apm_battery_time(void)
914 struct apm_info a_info;
917 out = (char *) calloc(16, sizeof(char));
919 fd = open(APMDEV, O_RDONLY);
921 strncpy(out, "ERR", 16);
925 if (apm_getinfo(fd, &a_info) != 0) {
927 strncpy(out, "ERR", 16);
932 batt_time = a_info.ai_batt_time;
934 if (batt_time == -1) {
935 strncpy(out, "unknown", 16);
942 snprintf(out, 16, "%2d:%02d:%02d", h, m, s);
950 void get_battery_short_status(char *buffer, unsigned int n, const char *bat)
952 get_battery_stuff(buffer, n, bat, BATTERY_STATUS);
953 if (0 == strncmp("charging", buffer, 8)) {
955 memmove(buffer + 1, buffer + 8, n - 8);
956 } else if (0 == strncmp("discharging", buffer, 11)) {
958 memmove(buffer + 1, buffer + 11, n - 11);
959 } else if (0 == strncmp("absent/on AC", buffer, 12)) {
961 memmove(buffer + 1, buffer + 12, n - 12);
965 void update_entropy(void)
967 /* Not applicable for FreeBSD as it uses the yarrow prng. */
970 /* empty stub so conky links */
971 void free_all_processes(void)