1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2 * vim: ts=4 sw=4 noet ai cindent syntax=c
4 * Conky, a system monitor, based on torsmo
6 * Any original torsmo code is licensed under the BSD license
8 * All code written since the fork of torsmo is licensed under the GPL
10 * Please see COPYING for details
12 * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
14 * All rights reserved.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 #include <sys/ioctl.h>
31 #include <sys/dkstat.h>
32 #include <sys/param.h>
33 #include <sys/resource.h>
34 #include <sys/socket.h>
36 #include <sys/sysctl.h>
38 #include <sys/types.h>
42 #include <net/if_mib.h>
43 #include <net/if_media.h>
44 #include <net/if_var.h>
51 #include <dev/wi/if_wavelan_ieee.h>
52 #include <dev/acpica/acpiio.h>
60 #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
61 #define KELVTOC(x) ((x - 2732) / 10.0)
62 #define MAXSHOWDEVS 16
68 __attribute__((gnu_inline)) inline void
69 proc_find_top(struct process **cpu, struct process **mem);
71 static short cpu_setup = 0;
73 static int getsysctl(const char *name, void *ptr, size_t len)
77 if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) {
81 if (nlen != len && errno == ENOMEM) {
88 struct ifmibdata *data = NULL;
91 static int swapmode(unsigned long *retavail, unsigned long *retfree)
94 unsigned long pagesize = getpagesize();
95 struct kvm_swap swapary[1];
100 #define CONVERT(v) ((quad_t)(v) * (pagesize / 1024))
102 n = kvm_getswapinfo(kd, swapary, 1, 0);
103 if (n < 0 || swapary[0].ksw_total == 0) {
107 *retavail = CONVERT(swapary[0].ksw_total);
108 *retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
110 n = (int) ((double) swapary[0].ksw_used * 100.0 /
111 (double) swapary[0].ksw_total);
116 void prepare_update(void)
120 void update_uptime(void)
122 int mib[2] = { CTL_KERN, KERN_BOOTTIME };
123 struct timeval boottime;
125 size_t size = sizeof(boottime);
127 if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
128 && (boottime.tv_sec != 0)) {
130 info.uptime = now - boottime.tv_sec;
132 fprintf(stderr, "Could not get uptime\n");
137 int check_mount(char *s)
139 struct statfs *mntbuf;
142 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
143 for (i = mntsize - 1; i >= 0; i--) {
144 if (strcmp(mntbuf[i].f_mntonname, s) == 0) {
152 void update_meminfo(void)
154 u_int total_pages, inactive_pages, free_pages;
155 unsigned long swap_avail, swap_free;
157 int pagesize = getpagesize();
159 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages)) {
160 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_page_count\"\n");
163 if (GETSYSCTL("vm.stats.vm.v_free_count", free_pages)) {
164 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_free_count\"\n");
167 if (GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages)) {
168 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_inactive_count\"\n");
171 info.memmax = total_pages * (pagesize >> 10);
172 info.mem = (total_pages - free_pages - inactive_pages) * (pagesize >> 10);
173 info.memeasyfree = info.memfree = info.memmax - info.mem;
175 if ((swapmode(&swap_avail, &swap_free)) >= 0) {
176 info.swapmax = swap_avail;
177 info.swap = (swap_avail - swap_free);
178 info.swapfree = swap_free;
186 void update_net_stats(void)
190 long long r, t, last_recv, last_trans;
191 struct ifaddrs *ifap, *ifa;
195 delta = current_update_time - last_update_time;
196 if (delta <= 0.0001) {
200 if (getifaddrs(&ifap) < 0) {
204 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
205 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
207 if (ifa->ifa_flags & IFF_UP) {
208 struct ifaddrs *iftmp;
211 last_recv = ns->recv;
212 last_trans = ns->trans;
214 if (ifa->ifa_addr->sa_family != AF_LINK) {
218 for (iftmp = ifa->ifa_next;
219 iftmp != NULL && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
220 iftmp = iftmp->ifa_next) {
221 if (iftmp->ifa_addr->sa_family == AF_INET) {
222 memcpy(&(ns->addr), iftmp->ifa_addr,
223 iftmp->ifa_addr->sa_len);
227 ifd = (struct if_data *) ifa->ifa_data;
231 if (r < ns->last_read_recv) {
232 ns->recv += ((long long) 4294967295U - ns->last_read_recv) + r;
234 ns->recv += (r - ns->last_read_recv);
237 ns->last_read_recv = r;
239 if (t < ns->last_read_trans) {
240 ns->trans += ((long long) 4294967295U -
241 ns->last_read_trans) + t;
243 ns->trans += (t - ns->last_read_trans);
246 ns->last_read_trans = t;
248 /* calculate speeds */
249 ns->recv_speed = (ns->recv - last_recv) / delta;
250 ns->trans_speed = (ns->trans - last_trans) / delta;
259 void update_total_processes(void)
263 kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
265 info.procs = n_processes;
268 void update_running_processes(void)
270 struct kinfo_proc *p;
274 p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
275 for (i = 0; i < n_processes; i++) {
276 #if (__FreeBSD__ < 5) && (__FreeBSD_kernel__ < 5)
277 if (p[i].kp_proc.p_stat == SRUN) {
279 if (p[i].ki_stat == SRUN) {
285 info.run_procs = cnt;
288 struct cpu_load_struct {
289 unsigned long load[5];
292 struct cpu_load_struct fresh = { {0, 0, 0, 0, 0} };
293 long cpu_used, oldtotal, oldused;
295 void get_cpu_count(void)
297 /* int cpu_count = 0; */
299 /* XXX: FreeBSD doesn't allow to get per CPU load stats on SMP machines.
300 * It's possible to get a CPU count, but as we fulfill only
301 * info.cpu_usage[0], it's better to report there's only one CPU.
302 * It should fix some bugs (e.g. cpugraph) */
304 if (GETSYSCTL("hw.ncpu", cpu_count) == 0) {
305 info.cpu_count = cpu_count;
310 info.cpu_usage = malloc(info.cpu_count * sizeof(float));
311 if (info.cpu_usage == NULL) {
312 CRIT_ERR(NULL, NULL, "malloc");
316 /* XXX: SMP support */
317 void update_cpu_usage(void)
320 long cp_time[CPUSTATES];
321 size_t cp_len = sizeof(cp_time);
323 /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */
324 if ((cpu_setup == 0) || (!info.cpu_usage)) {
329 if (sysctlbyname("kern.cp_time", &cp_time, &cp_len, NULL, 0) < 0) {
330 fprintf(stderr, "Cannot get kern.cp_time");
333 fresh.load[0] = cp_time[CP_USER];
334 fresh.load[1] = cp_time[CP_NICE];
335 fresh.load[2] = cp_time[CP_SYS];
336 fresh.load[3] = cp_time[CP_IDLE];
337 fresh.load[4] = cp_time[CP_IDLE];
339 used = fresh.load[0] + fresh.load[1] + fresh.load[2];
340 total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
342 if ((total - oldtotal) != 0) {
343 info.cpu_usage[0] = ((double) (used - oldused)) /
344 (double) (total - oldtotal);
346 info.cpu_usage[0] = 0;
353 void update_load_average(void)
359 info.loadavg[0] = (double) v[0];
360 info.loadavg[1] = (double) v[1];
361 info.loadavg[2] = (double) v[2];
364 double get_acpi_temperature(int fd)
369 if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
371 "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
375 return KELVTOC(temp);
378 static void get_battery_stats(int *battime, int *batcapacity, int *batstate, int *ac) {
379 if (battime && GETSYSCTL("hw.acpi.battery.time", *battime)) {
380 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.time\"\n");
382 if (batcapacity && GETSYSCTL("hw.acpi.battery.life", *batcapacity)) {
383 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.life\"\n");
385 if (batstate && GETSYSCTL("hw.acpi.battery.state", *batstate)) {
386 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.state\"\n");
388 if (ac && GETSYSCTL("hw.acpi.acline", *ac)) {
389 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
393 void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
395 int battime, batcapacity, batstate, ac;
398 get_battery_stats(&battime, &batcapacity, &batstate, &ac);
400 if (batstate != 1 && batstate != 2 && batstate != 0 && batstate != 7)
401 fprintf(stderr, "Unknown battery state %d!\n", batstate);
402 else if (batstate != 1 && ac == 0)
403 fprintf(stderr, "Battery charging while not on AC!\n");
404 else if (batstate == 1 && ac == 1)
405 fprintf(stderr, "Battery discharing while on AC!\n");
409 if (batstate == 1 && battime != -1)
410 snprintf(buf, n, "%d:%2.2d", battime / 60, battime % 60);
413 if (batstate == 1) // Discharging
414 snprintf(buf, n, "remaining %d%%", batcapacity);
416 snprintf(buf, n, batstate == 2 ? "charging (%d%%)" :
417 (batstate == 7 ? "absent/on AC" : "charged (%d%%)"),
421 fprintf(stderr, "Unknown requested battery stat %d\n", item);
425 static int check_bat(const char *bat)
427 int batnum, numbatts;
429 if (GETSYSCTL("hw.acpi.battery.units", numbatts)) {
430 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.units\"\n");
434 fprintf(stderr, "No battery unit detected\n");
437 if (!bat || (batnum = strtol(bat, &endptr, 10)) < 0 ||
438 bat == endptr || batnum > numbatts) {
439 fprintf(stderr, "Wrong battery unit %s requested\n", bat ? bat : "");
445 int get_battery_perct(const char *bat)
447 union acpi_battery_ioctl_arg battio;
449 int designcap, lastfulcap, batperct;
451 if ((battio.unit = batnum = check_bat(bat)) < 0)
453 if ((acpifd = open("/dev/acpi", O_RDONLY)) < 0) {
454 fprintf(stderr, "Can't open ACPI device\n");
457 if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) == -1) {
458 fprintf(stderr, "Unable to get info for battery unit %d\n", batnum);
462 designcap = battio.bif.dcap;
463 lastfulcap = battio.bif.lfcap;
464 batperct = (designcap > 0 && lastfulcap > 0) ?
465 (int) (((float) lastfulcap / designcap) * 100) : 0;
466 return batperct > 100 ? 100 : batperct;
469 int get_battery_perct_bar(const char *bar)
471 int batperct = get_battery_perct(bar);
472 return (int)(batperct * 2.56 - 1);
475 int open_acpi_temperature(const char *name)
478 /* Not applicable for FreeBSD. */
482 void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
486 if (!p_client_buffer || client_buffer_size <= 0) {
490 if (GETSYSCTL("hw.acpi.acline", state)) {
491 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
496 strncpy(p_client_buffer, "Running on AC Power", client_buffer_size);
498 strncpy(p_client_buffer, "Running on battery", client_buffer_size);
502 void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
504 /* not implemented */
505 if (p_client_buffer && client_buffer_size > 0) {
506 memset(p_client_buffer, 0, client_buffer_size);
510 void get_adt746x_cpu(char *p_client_buffer, size_t client_buffer_size)
512 /* not implemented */
513 if (p_client_buffer && client_buffer_size > 0) {
514 memset(p_client_buffer, 0, client_buffer_size);
518 void get_adt746x_fan(char *p_client_buffer, size_t client_buffer_size)
520 /* not implemented */
521 if (p_client_buffer && client_buffer_size > 0) {
522 memset(p_client_buffer, 0, client_buffer_size);
526 /* rdtsc() and get_freq_dynamic() copied from linux.c */
528 #if defined(__i386) || defined(__x86_64)
529 __attribute__((gnu_inline)) inline unsigned long long int rdtsc(void)
531 unsigned long long int x;
533 __asm__ volatile(".byte 0x0f, 0x31":"=A" (x));
538 /* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */
539 void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
540 const char *p_format, int divisor)
542 #if defined(__i386) || defined(__x86_64)
544 struct timeval tvstart, tvstop;
545 unsigned long long cycles[2]; /* gotta be 64 bit */
546 unsigned int microseconds; /* total time taken */
548 memset(&tz, 0, sizeof(tz));
550 /* get this function in cached memory */
551 gettimeofday(&tvstart, &tz);
553 gettimeofday(&tvstart, &tz);
555 /* we don't trust that this is any specific length of time */
558 gettimeofday(&tvstop, &tz);
559 microseconds = ((tvstop.tv_sec - tvstart.tv_sec) * 1000000) +
560 (tvstop.tv_usec - tvstart.tv_usec);
562 snprintf(p_client_buffer, client_buffer_size, p_format,
563 (float) ((cycles[1] - cycles[0]) / microseconds) / divisor);
565 get_freq(p_client_buffer, client_buffer_size, p_format, divisor, 1);
570 char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_format,
571 int divisor, unsigned int cpu)
576 freq_sysctl = (char *) calloc(16, sizeof(char));
577 if (freq_sysctl == NULL) {
581 snprintf(freq_sysctl, 16, "dev.cpu.%d.freq", (cpu - 1));
583 if (!p_client_buffer || client_buffer_size <= 0 || !p_format
588 if (GETSYSCTL(freq_sysctl, freq) == 0) {
589 snprintf(p_client_buffer, client_buffer_size, p_format,
590 (float) freq / divisor);
592 snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
599 void update_top(void)
601 proc_find_top(info.cpu, info.memu);
605 void update_wifi_stats(void)
607 struct ifreq ifr; /* interface stats */
610 struct ifaddrs *ifap, *ifa;
611 struct ifmediareq ifmr;
614 /* Get iface table */
615 if (getifaddrs(&ifap) < 0) {
619 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
620 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
622 s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
625 bzero(&ifmr, sizeof(ifmr));
626 strlcpy(ifmr.ifm_name, ifa->ifa_name, IFNAMSIZ);
627 if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) {
632 /* We can monitor only wireless interfaces
633 * which are not in hostap mode */
634 if ((ifmr.ifm_active & IFM_IEEE80211)
635 && !(ifmr.ifm_active & IFM_IEEE80211_HOSTAP)) {
637 bzero(&ifr, sizeof(ifr));
638 strlcpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ);
639 wireq.wi_type = WI_RID_COMMS_QUALITY;
640 wireq.wi_len = WI_MAX_DATALEN;
641 ifr.ifr_data = (void *) &wireq;
643 if (ioctl(s, SIOCGWAVELAN, (caddr_t) &ifr) < 0) {
644 perror("ioctl (getting wi status)");
648 /* wi_val[0] = quality
650 * wi_val[2] = noise */
651 ns->linkstatus = (int) wireq.wi_val[1];
659 void update_diskio(void)
661 int devs_count, num_selected, num_selections, dn;
662 struct device_selection *dev_select = NULL;
663 long select_generation;
664 static struct statinfo statinfo_cur;
665 char device_name[text_buffer_size];
666 struct diskio_stat *cur;
667 unsigned int reads, writes;
668 unsigned int total_reads = 0, total_writes = 0;
671 memset(&statinfo_cur, 0, sizeof(statinfo_cur));
672 statinfo_cur.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
673 stats.current = stats.current_read = stats.current_write = 0;
675 if (devstat_getdevs(NULL, &statinfo_cur) < 0) {
676 free(statinfo_cur.dinfo);
680 devs_count = statinfo_cur.dinfo->numdevs;
681 if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
682 &select_generation, statinfo_cur.dinfo->generation,
683 statinfo_cur.dinfo->devices, devs_count, NULL, 0, NULL, 0,
684 DS_SELECT_ONLY, MAXSHOWDEVS, 1) >= 0) {
685 for (dn = 0; dn < devs_count; dn++) {
689 di = dev_select[dn].position;
690 dev = &statinfo_cur.dinfo->devices[di];
691 snprintf(device_name, text_buffer_size, "%s%d",
692 dev_select[dn].device_name, dev_select[dn].unit_number);
694 total_reads += (reads = dev->bytes[DEVSTAT_READ] / 512);
695 total_writes += (writes = dev->bytes[DEVSTAT_WRITE] / 512);
696 for (cur = stats.next; cur; cur = cur->next) {
697 if (cur->dev && !strcmp(device_name, cur->dev)) {
698 update_diskio_values(cur, reads, writes);
703 update_diskio_values(&stats, total_reads, total_writes);
708 free(statinfo_cur.dinfo);
711 /* While topless is obviously better, top is also not bad. */
713 int comparecpu(const void *a, const void *b)
715 if (((const struct process *)a)->amount > ((const struct process *)b)->amount) {
717 } else if (((const struct process *)a)->amount < ((const struct process *)b)->amount) {
724 int comparemem(const void *a, const void *b)
726 if (((const struct process *)a)->totalmem > ((const struct process *)b)->totalmem) {
728 } else if (((const struct process *)a)->totalmem < ((const struct process *)b)->totalmem) {
735 __attribute__((gnu_inline)) inline void
736 proc_find_top(struct process **cpu, struct process **mem)
738 struct kinfo_proc *p;
741 struct process *processes;
745 /* we get total pages count again to be sure it is up to date */
746 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages) != 0) {
747 CRIT_ERR(NULL, NULL, "Cannot read sysctl \"vm.stats.vm.v_page_count\"");
750 p = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_processes);
751 processes = malloc(n_processes * sizeof(struct process));
753 for (i = 0; i < n_processes; i++) {
754 if (!((p[i].ki_flag & P_SYSTEM)) && p[i].ki_comm != NULL) {
755 processes[j].pid = p[i].ki_pid;
756 processes[j].name = strndup(p[i].ki_comm, text_buffer_size);
757 processes[j].amount = 100.0 * p[i].ki_pctcpu / FSCALE;
758 processes[j].totalmem = (float) (p[i].ki_rssize /
759 (float) total_pages) * 100.0;
760 processes[j].vsize = p[i].ki_size;
761 processes[j].rss = (p[i].ki_rssize * getpagesize());
766 qsort(processes, j - 1, sizeof(struct process), comparemem);
767 for (i = 0; i < 10 && i < n_processes; i++) {
768 struct process *tmp, *ttmp;
770 tmp = malloc(sizeof(struct process));
771 tmp->pid = processes[i].pid;
772 tmp->amount = processes[i].amount;
773 tmp->totalmem = processes[i].totalmem;
774 tmp->name = strndup(processes[i].name, text_buffer_size);
775 tmp->rss = processes[i].rss;
776 tmp->vsize = processes[i].vsize;
786 qsort(processes, j - 1, sizeof(struct process), comparecpu);
787 for (i = 0; i < 10 && i < n_processes; i++) {
788 struct process *tmp, *ttmp;
790 tmp = malloc(sizeof(struct process));
791 tmp->pid = processes[i].pid;
792 tmp->amount = processes[i].amount;
793 tmp->totalmem = processes[i].totalmem;
794 tmp->name = strndup(processes[i].name, text_buffer_size);
795 tmp->rss = processes[i].rss;
796 tmp->vsize = processes[i].vsize;
806 #if defined(FREEBSD_DEBUG)
807 printf("=====\nmem\n");
808 for (i = 0; i < 10; i++) {
809 printf("%d: %s(%d) %.2f %ld %ld\n", i, mem[i]->name,
810 mem[i]->pid, mem[i]->totalmem, mem[i]->vsize, mem[i]->rss);
814 for (i = 0; i < j; i++) {
815 free(processes[i].name);
820 #if defined(i386) || defined(__i386__)
821 #define APMDEV "/dev/apm"
822 #define APM_UNKNOWN 255
824 int apm_getinfo(int fd, apm_info_t aip)
826 if (ioctl(fd, APMIO_GETINFO, aip) == -1) {
833 char *get_apm_adapter(void)
836 struct apm_info a_info;
839 out = (char *) calloc(16, sizeof(char));
841 fd = open(APMDEV, O_RDONLY);
843 strncpy(out, "ERR", 16);
847 if (apm_getinfo(fd, &a_info) != 0) {
849 strncpy(out, "ERR", 16);
854 switch (a_info.ai_acline) {
856 strncpy(out, "off-line", 16);
860 if (a_info.ai_batt_stat == 3) {
861 strncpy(out, "charging", 16);
864 strncpy(out, "on-line", 16);
869 strncpy(out, "unknown", 16);
875 char *get_apm_battery_life(void)
879 struct apm_info a_info;
882 out = (char *) calloc(16, sizeof(char));
884 fd = open(APMDEV, O_RDONLY);
886 strncpy(out, "ERR", 16);
890 if (apm_getinfo(fd, &a_info) != 0) {
892 strncpy(out, "ERR", 16);
897 batt_life = a_info.ai_batt_life;
898 if (batt_life == APM_UNKNOWN) {
899 strncpy(out, "unknown", 16);
900 } else if (batt_life <= 100) {
901 snprintf(out, 16, "%d%%", batt_life);
904 strncpy(out, "ERR", 16);
910 char *get_apm_battery_time(void)
915 struct apm_info a_info;
918 out = (char *) calloc(16, sizeof(char));
920 fd = open(APMDEV, O_RDONLY);
922 strncpy(out, "ERR", 16);
926 if (apm_getinfo(fd, &a_info) != 0) {
928 strncpy(out, "ERR", 16);
933 batt_time = a_info.ai_batt_time;
935 if (batt_time == -1) {
936 strncpy(out, "unknown", 16);
943 snprintf(out, 16, "%2d:%02d:%02d", h, m, s);
951 void get_battery_short_status(char *buffer, unsigned int n, const char *bat)
953 get_battery_stuff(buffer, n, bat, BATTERY_STATUS);
954 if (0 == strncmp("charging", buffer, 8)) {
956 memmove(buffer + 1, buffer + 8, n - 8);
957 } else if (0 == strncmp("discharging", buffer, 11)) {
959 memmove(buffer + 1, buffer + 11, n - 11);
960 } else if (0 == strncmp("absent/on AC", buffer, 12)) {
962 memmove(buffer + 1, buffer + 12, n - 12);
966 void update_entropy(void)
968 /* Not applicable for FreeBSD as it uses the yarrow prng. */
971 /* empty stub so conky links */
972 void free_all_processes(void)