1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
3 * Conky, a system monitor, based on torsmo
5 * Any original torsmo code is licensed under the BSD license
7 * All code written since the fork of torsmo is licensed under the GPL
9 * Please see COPYING for details
11 * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
13 * All rights reserved.
15 * This program is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 * vim: ts=4 sw=4 noet ai cindent syntax=c
31 #include <sys/ioctl.h>
32 #include <sys/dkstat.h>
33 #include <sys/param.h>
34 #include <sys/resource.h>
35 #include <sys/socket.h>
37 #include <sys/sysctl.h>
39 #include <sys/types.h>
43 #include <net/if_mib.h>
44 #include <net/if_media.h>
45 #include <net/if_var.h>
52 #include <dev/wi/if_wavelan_ieee.h>
53 #include <dev/acpica/acpiio.h>
61 #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
62 #define KELVTOC(x) ((x - 2732) / 10.0)
63 #define MAXSHOWDEVS 16
69 __attribute__((gnu_inline)) inline void
70 proc_find_top(struct process **cpu, struct process **mem);
72 static short cpu_setup = 0;
74 static int getsysctl(const char *name, void *ptr, size_t len)
78 if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) {
82 if (nlen != len && errno == ENOMEM) {
89 struct ifmibdata *data = NULL;
92 static int swapmode(unsigned long *retavail, unsigned long *retfree)
95 unsigned long pagesize = getpagesize();
96 struct kvm_swap swapary[1];
101 #define CONVERT(v) ((quad_t)(v) * (pagesize / 1024))
103 n = kvm_getswapinfo(kd, swapary, 1, 0);
104 if (n < 0 || swapary[0].ksw_total == 0) {
108 *retavail = CONVERT(swapary[0].ksw_total);
109 *retfree = CONVERT(swapary[0].ksw_total - swapary[0].ksw_used);
111 n = (int) ((double) swapary[0].ksw_used * 100.0 /
112 (double) swapary[0].ksw_total);
117 void prepare_update(void)
121 void update_uptime(void)
123 int mib[2] = { CTL_KERN, KERN_BOOTTIME };
124 struct timeval boottime;
126 size_t size = sizeof(boottime);
128 if ((sysctl(mib, 2, &boottime, &size, NULL, 0) != -1)
129 && (boottime.tv_sec != 0)) {
131 info.uptime = now - boottime.tv_sec;
133 fprintf(stderr, "Could not get uptime\n");
138 int check_mount(char *s)
140 struct statfs *mntbuf;
143 mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
144 for (i = mntsize - 1; i >= 0; i--) {
145 if (strcmp(mntbuf[i].f_mntonname, s) == 0) {
153 void update_meminfo(void)
155 u_int total_pages, inactive_pages, free_pages;
156 unsigned long swap_avail, swap_free;
158 int pagesize = getpagesize();
160 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages)) {
161 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_page_count\"\n");
164 if (GETSYSCTL("vm.stats.vm.v_free_count", free_pages)) {
165 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_free_count\"\n");
168 if (GETSYSCTL("vm.stats.vm.v_inactive_count", inactive_pages)) {
169 fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_inactive_count\"\n");
172 info.memmax = total_pages * (pagesize >> 10);
173 info.mem = (total_pages - free_pages - inactive_pages) * (pagesize >> 10);
174 info.memeasyfree = info.memfree = info.memmax - info.mem;
176 if ((swapmode(&swap_avail, &swap_free)) >= 0) {
177 info.swapmax = swap_avail;
178 info.swap = (swap_avail - swap_free);
179 info.swapfree = swap_free;
187 void update_net_stats(void)
191 long long r, t, last_recv, last_trans;
192 struct ifaddrs *ifap, *ifa;
196 delta = current_update_time - last_update_time;
197 if (delta <= 0.0001) {
201 if (getifaddrs(&ifap) < 0) {
205 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
206 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
208 if (ifa->ifa_flags & IFF_UP) {
209 struct ifaddrs *iftmp;
212 last_recv = ns->recv;
213 last_trans = ns->trans;
215 if (ifa->ifa_addr->sa_family != AF_LINK) {
219 for (iftmp = ifa->ifa_next;
220 iftmp != NULL && strcmp(ifa->ifa_name, iftmp->ifa_name) == 0;
221 iftmp = iftmp->ifa_next) {
222 if (iftmp->ifa_addr->sa_family == AF_INET) {
223 memcpy(&(ns->addr), iftmp->ifa_addr,
224 iftmp->ifa_addr->sa_len);
228 ifd = (struct if_data *) ifa->ifa_data;
232 if (r < ns->last_read_recv) {
233 ns->recv += ((long long) 4294967295U - ns->last_read_recv) + r;
235 ns->recv += (r - ns->last_read_recv);
238 ns->last_read_recv = r;
240 if (t < ns->last_read_trans) {
241 ns->trans += ((long long) 4294967295U -
242 ns->last_read_trans) + t;
244 ns->trans += (t - ns->last_read_trans);
247 ns->last_read_trans = t;
249 /* calculate speeds */
250 ns->recv_speed = (ns->recv - last_recv) / delta;
251 ns->trans_speed = (ns->trans - last_trans) / delta;
260 void update_total_processes(void)
264 kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
266 info.procs = n_processes;
269 void update_running_processes(void)
271 struct kinfo_proc *p;
275 p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes);
276 for (i = 0; i < n_processes; i++) {
277 #if (__FreeBSD__ < 5) && (__FreeBSD_kernel__ < 5)
278 if (p[i].kp_proc.p_stat == SRUN) {
280 if (p[i].ki_stat == SRUN) {
286 info.run_procs = cnt;
289 struct cpu_load_struct {
290 unsigned long load[5];
293 struct cpu_load_struct fresh = { {0, 0, 0, 0, 0} };
294 long cpu_used, oldtotal, oldused;
296 void get_cpu_count(void)
298 /* int cpu_count = 0; */
300 /* XXX: FreeBSD doesn't allow to get per CPU load stats on SMP machines.
301 * It's possible to get a CPU count, but as we fulfill only
302 * info.cpu_usage[0], it's better to report there's only one CPU.
303 * It should fix some bugs (e.g. cpugraph) */
305 if (GETSYSCTL("hw.ncpu", cpu_count) == 0) {
306 info.cpu_count = cpu_count;
311 info.cpu_usage = malloc(info.cpu_count * sizeof(float));
312 if (info.cpu_usage == NULL) {
313 CRIT_ERR(NULL, NULL, "malloc");
317 /* XXX: SMP support */
318 void update_cpu_usage(void)
321 long cp_time[CPUSTATES];
322 size_t cp_len = sizeof(cp_time);
324 /* add check for !info.cpu_usage since that mem is freed on a SIGUSR1 */
325 if ((cpu_setup == 0) || (!info.cpu_usage)) {
330 if (sysctlbyname("kern.cp_time", &cp_time, &cp_len, NULL, 0) < 0) {
331 fprintf(stderr, "Cannot get kern.cp_time");
334 fresh.load[0] = cp_time[CP_USER];
335 fresh.load[1] = cp_time[CP_NICE];
336 fresh.load[2] = cp_time[CP_SYS];
337 fresh.load[3] = cp_time[CP_IDLE];
338 fresh.load[4] = cp_time[CP_IDLE];
340 used = fresh.load[0] + fresh.load[1] + fresh.load[2];
341 total = fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
343 if ((total - oldtotal) != 0) {
344 info.cpu_usage[0] = ((double) (used - oldused)) /
345 (double) (total - oldtotal);
347 info.cpu_usage[0] = 0;
354 void update_load_average(void)
360 info.loadavg[0] = (double) v[0];
361 info.loadavg[1] = (double) v[1];
362 info.loadavg[2] = (double) v[2];
365 double get_acpi_temperature(int fd)
370 if (GETSYSCTL("hw.acpi.thermal.tz0.temperature", temp)) {
372 "Cannot read sysctl \"hw.acpi.thermal.tz0.temperature\"\n");
376 return KELVTOC(temp);
379 static void get_battery_stats(int *battime, int *batcapacity, int *batstate, int *ac) {
380 if (battime && GETSYSCTL("hw.acpi.battery.time", *battime)) {
381 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.time\"\n");
383 if (batcapacity && GETSYSCTL("hw.acpi.battery.life", *batcapacity)) {
384 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.life\"\n");
386 if (batstate && GETSYSCTL("hw.acpi.battery.state", *batstate)) {
387 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.state\"\n");
389 if (ac && GETSYSCTL("hw.acpi.acline", *ac)) {
390 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
394 void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
396 int battime, batcapacity, batstate, ac;
399 get_battery_stats(&battime, &batcapacity, &batstate, &ac);
401 if (batstate != 1 && batstate != 2 && batstate != 0 && batstate != 7)
402 fprintf(stderr, "Unknown battery state %d!\n", batstate);
403 else if (batstate != 1 && ac == 0)
404 fprintf(stderr, "Battery charging while not on AC!\n");
405 else if (batstate == 1 && ac == 1)
406 fprintf(stderr, "Battery discharing while on AC!\n");
410 if (batstate == 1 && battime != -1)
411 snprintf(buf, n, "%d:%2.2d", battime / 60, battime % 60);
414 if (batstate == 1) // Discharging
415 snprintf(buf, n, "remaining %d%%", batcapacity);
417 snprintf(buf, n, batstate == 2 ? "charging (%d%%)" :
418 (batstate == 7 ? "absent/on AC" : "charged (%d%%)"),
422 fprintf(stderr, "Unknown requested battery stat %d\n", item);
426 static int check_bat(const char *bat)
428 int batnum, numbatts;
430 if (GETSYSCTL("hw.acpi.battery.units", numbatts)) {
431 fprintf(stderr, "Cannot read sysctl \"hw.acpi.battery.units\"\n");
435 fprintf(stderr, "No battery unit detected\n");
438 if (!bat || (batnum = strtol(bat, &endptr, 10)) < 0 ||
439 bat == endptr || batnum > numbatts) {
440 fprintf(stderr, "Wrong battery unit %s requested\n", bat ? bat : "");
446 int get_battery_perct(const char *bat)
448 union acpi_battery_ioctl_arg battio;
450 int designcap, lastfulcap, batperct;
452 if ((battio.unit = batnum = check_bat(bat)) < 0)
454 if ((acpifd = open("/dev/acpi", O_RDONLY)) < 0) {
455 fprintf(stderr, "Can't open ACPI device\n");
458 if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) == -1) {
459 fprintf(stderr, "Unable to get info for battery unit %d\n", batnum);
463 designcap = battio.bif.dcap;
464 lastfulcap = battio.bif.lfcap;
465 batperct = (designcap > 0 && lastfulcap > 0) ?
466 (int) (((float) lastfulcap / designcap) * 100) : 0;
467 return batperct > 100 ? 100 : batperct;
470 int get_battery_perct_bar(const char *bar)
472 int batperct = get_battery_perct(bar);
473 return (int)(batperct * 2.56 - 1);
476 int open_acpi_temperature(const char *name)
479 /* Not applicable for FreeBSD. */
483 void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size)
487 if (!p_client_buffer || client_buffer_size <= 0) {
491 if (GETSYSCTL("hw.acpi.acline", state)) {
492 fprintf(stderr, "Cannot read sysctl \"hw.acpi.acline\"\n");
497 strncpy(p_client_buffer, "Running on AC Power", client_buffer_size);
499 strncpy(p_client_buffer, "Running on battery", client_buffer_size);
503 void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
505 /* not implemented */
506 if (p_client_buffer && client_buffer_size > 0) {
507 memset(p_client_buffer, 0, client_buffer_size);
511 void get_adt746x_cpu(char *p_client_buffer, size_t client_buffer_size)
513 /* not implemented */
514 if (p_client_buffer && client_buffer_size > 0) {
515 memset(p_client_buffer, 0, client_buffer_size);
519 void get_adt746x_fan(char *p_client_buffer, size_t client_buffer_size)
521 /* not implemented */
522 if (p_client_buffer && client_buffer_size > 0) {
523 memset(p_client_buffer, 0, client_buffer_size);
527 /* rdtsc() and get_freq_dynamic() copied from linux.c */
529 #if defined(__i386) || defined(__x86_64)
530 __attribute__((gnu_inline)) inline unsigned long long int rdtsc(void)
532 unsigned long long int x;
534 __asm__ volatile(".byte 0x0f, 0x31":"=A" (x));
539 /* return system frequency in MHz (use divisor=1) or GHz (use divisor=1000) */
540 void get_freq_dynamic(char *p_client_buffer, size_t client_buffer_size,
541 const char *p_format, int divisor)
543 #if defined(__i386) || defined(__x86_64)
545 struct timeval tvstart, tvstop;
546 unsigned long long cycles[2]; /* gotta be 64 bit */
547 unsigned int microseconds; /* total time taken */
549 memset(&tz, 0, sizeof(tz));
551 /* get this function in cached memory */
552 gettimeofday(&tvstart, &tz);
554 gettimeofday(&tvstart, &tz);
556 /* we don't trust that this is any specific length of time */
559 gettimeofday(&tvstop, &tz);
560 microseconds = ((tvstop.tv_sec - tvstart.tv_sec) * 1000000) +
561 (tvstop.tv_usec - tvstart.tv_usec);
563 snprintf(p_client_buffer, client_buffer_size, p_format,
564 (float) ((cycles[1] - cycles[0]) / microseconds) / divisor);
566 get_freq(p_client_buffer, client_buffer_size, p_format, divisor, 1);
571 char get_freq(char *p_client_buffer, size_t client_buffer_size, const char *p_format,
572 int divisor, unsigned int cpu)
577 freq_sysctl = (char *) calloc(16, sizeof(char));
578 if (freq_sysctl == NULL) {
582 snprintf(freq_sysctl, 16, "dev.cpu.%d.freq", (cpu - 1));
584 if (!p_client_buffer || client_buffer_size <= 0 || !p_format
589 if (GETSYSCTL(freq_sysctl, freq) == 0) {
590 snprintf(p_client_buffer, client_buffer_size, p_format,
591 (float) freq / divisor);
593 snprintf(p_client_buffer, client_buffer_size, p_format, 0.0f);
600 void update_top(void)
602 proc_find_top(info.cpu, info.memu);
606 void update_wifi_stats(void)
608 struct ifreq ifr; /* interface stats */
611 struct ifaddrs *ifap, *ifa;
612 struct ifmediareq ifmr;
615 /* Get iface table */
616 if (getifaddrs(&ifap) < 0) {
620 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
621 ns = get_net_stat((const char *) ifa->ifa_name, NULL, NULL);
623 s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
626 bzero(&ifmr, sizeof(ifmr));
627 strlcpy(ifmr.ifm_name, ifa->ifa_name, IFNAMSIZ);
628 if (ioctl(s, SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) {
633 /* We can monitor only wireless interfaces
634 * which are not in hostap mode */
635 if ((ifmr.ifm_active & IFM_IEEE80211)
636 && !(ifmr.ifm_active & IFM_IEEE80211_HOSTAP)) {
638 bzero(&ifr, sizeof(ifr));
639 strlcpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ);
640 wireq.wi_type = WI_RID_COMMS_QUALITY;
641 wireq.wi_len = WI_MAX_DATALEN;
642 ifr.ifr_data = (void *) &wireq;
644 if (ioctl(s, SIOCGWAVELAN, (caddr_t) &ifr) < 0) {
645 perror("ioctl (getting wi status)");
649 /* wi_val[0] = quality
651 * wi_val[2] = noise */
652 ns->linkstatus = (int) wireq.wi_val[1];
660 void update_diskio(void)
662 int devs_count, num_selected, num_selections, dn;
663 struct device_selection *dev_select = NULL;
664 long select_generation;
665 static struct statinfo statinfo_cur;
666 char device_name[text_buffer_size];
667 struct diskio_stat *cur;
668 unsigned int reads, writes;
669 unsigned int total_reads = 0, total_writes = 0;
672 memset(&statinfo_cur, 0, sizeof(statinfo_cur));
673 statinfo_cur.dinfo = (struct devinfo *)calloc(1, sizeof(struct devinfo));
674 stats.current = stats.current_read = stats.current_write = 0;
676 if (devstat_getdevs(NULL, &statinfo_cur) < 0) {
677 free(statinfo_cur.dinfo);
681 devs_count = statinfo_cur.dinfo->numdevs;
682 if (devstat_selectdevs(&dev_select, &num_selected, &num_selections,
683 &select_generation, statinfo_cur.dinfo->generation,
684 statinfo_cur.dinfo->devices, devs_count, NULL, 0, NULL, 0,
685 DS_SELECT_ONLY, MAXSHOWDEVS, 1) >= 0) {
686 for (dn = 0; dn < devs_count; dn++) {
690 di = dev_select[dn].position;
691 dev = &statinfo_cur.dinfo->devices[di];
692 snprintf(device_name, text_buffer_size, "%s%d",
693 dev_select[dn].device_name, dev_select[dn].unit_number);
695 total_reads += (reads = dev->bytes[DEVSTAT_READ] / 512);
696 total_writes += (writes = dev->bytes[DEVSTAT_WRITE] / 512);
697 for (cur = stats.next; cur; cur = cur->next) {
698 if (cur->dev && !strcmp(device_name, cur->dev)) {
699 update_diskio_values(cur, reads, writes);
704 update_diskio_values(&stats, total_reads, total_writes);
709 free(statinfo_cur.dinfo);
712 /* While topless is obviously better, top is also not bad. */
714 int comparecpu(const void *a, const void *b)
716 if (((const struct process *)a)->amount > ((const struct process *)b)->amount) {
718 } else if (((const struct process *)a)->amount < ((const struct process *)b)->amount) {
725 int comparemem(const void *a, const void *b)
727 if (((const struct process *)a)->totalmem > ((const struct process *)b)->totalmem) {
729 } else if (((const struct process *)a)->totalmem < ((const struct process *)b)->totalmem) {
736 __attribute__((gnu_inline)) inline void
737 proc_find_top(struct process **cpu, struct process **mem)
739 struct kinfo_proc *p;
742 struct process *processes;
746 /* we get total pages count again to be sure it is up to date */
747 if (GETSYSCTL("vm.stats.vm.v_page_count", total_pages) != 0) {
748 CRIT_ERR(NULL, NULL, "Cannot read sysctl \"vm.stats.vm.v_page_count\"");
751 p = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_processes);
752 processes = malloc(n_processes * sizeof(struct process));
754 for (i = 0; i < n_processes; i++) {
755 if (!((p[i].ki_flag & P_SYSTEM)) && p[i].ki_comm != NULL) {
756 processes[j].pid = p[i].ki_pid;
757 processes[j].name = strndup(p[i].ki_comm, text_buffer_size);
758 processes[j].amount = 100.0 * p[i].ki_pctcpu / FSCALE;
759 processes[j].totalmem = (float) (p[i].ki_rssize /
760 (float) total_pages) * 100.0;
761 processes[j].vsize = p[i].ki_size;
762 processes[j].rss = (p[i].ki_rssize * getpagesize());
767 qsort(processes, j - 1, sizeof(struct process), comparemem);
768 for (i = 0; i < 10 && i < n_processes; i++) {
769 struct process *tmp, *ttmp;
771 tmp = malloc(sizeof(struct process));
772 tmp->pid = processes[i].pid;
773 tmp->amount = processes[i].amount;
774 tmp->totalmem = processes[i].totalmem;
775 tmp->name = strndup(processes[i].name, text_buffer_size);
776 tmp->rss = processes[i].rss;
777 tmp->vsize = processes[i].vsize;
787 qsort(processes, j - 1, sizeof(struct process), comparecpu);
788 for (i = 0; i < 10 && i < n_processes; i++) {
789 struct process *tmp, *ttmp;
791 tmp = malloc(sizeof(struct process));
792 tmp->pid = processes[i].pid;
793 tmp->amount = processes[i].amount;
794 tmp->totalmem = processes[i].totalmem;
795 tmp->name = strndup(processes[i].name, text_buffer_size);
796 tmp->rss = processes[i].rss;
797 tmp->vsize = processes[i].vsize;
807 #if defined(FREEBSD_DEBUG)
808 printf("=====\nmem\n");
809 for (i = 0; i < 10; i++) {
810 printf("%d: %s(%d) %.2f %ld %ld\n", i, mem[i]->name,
811 mem[i]->pid, mem[i]->totalmem, mem[i]->vsize, mem[i]->rss);
815 for (i = 0; i < j; i++) {
816 free(processes[i].name);
821 #if defined(i386) || defined(__i386__)
822 #define APMDEV "/dev/apm"
823 #define APM_UNKNOWN 255
825 int apm_getinfo(int fd, apm_info_t aip)
827 if (ioctl(fd, APMIO_GETINFO, aip) == -1) {
834 char *get_apm_adapter(void)
837 struct apm_info a_info;
840 out = (char *) calloc(16, sizeof(char));
842 fd = open(APMDEV, O_RDONLY);
844 strncpy(out, "ERR", 16);
848 if (apm_getinfo(fd, &a_info) != 0) {
850 strncpy(out, "ERR", 16);
855 switch (a_info.ai_acline) {
857 strncpy(out, "off-line", 16);
861 if (a_info.ai_batt_stat == 3) {
862 strncpy(out, "charging", 16);
865 strncpy(out, "on-line", 16);
870 strncpy(out, "unknown", 16);
876 char *get_apm_battery_life(void)
880 struct apm_info a_info;
883 out = (char *) calloc(16, sizeof(char));
885 fd = open(APMDEV, O_RDONLY);
887 strncpy(out, "ERR", 16);
891 if (apm_getinfo(fd, &a_info) != 0) {
893 strncpy(out, "ERR", 16);
898 batt_life = a_info.ai_batt_life;
899 if (batt_life == APM_UNKNOWN) {
900 strncpy(out, "unknown", 16);
901 } else if (batt_life <= 100) {
902 snprintf(out, 16, "%d%%", batt_life);
905 strncpy(out, "ERR", 16);
911 char *get_apm_battery_time(void)
916 struct apm_info a_info;
919 out = (char *) calloc(16, sizeof(char));
921 fd = open(APMDEV, O_RDONLY);
923 strncpy(out, "ERR", 16);
927 if (apm_getinfo(fd, &a_info) != 0) {
929 strncpy(out, "ERR", 16);
934 batt_time = a_info.ai_batt_time;
936 if (batt_time == -1) {
937 strncpy(out, "unknown", 16);
944 snprintf(out, 16, "%2d:%02d:%02d", h, m, s);
952 void get_battery_short_status(char *buffer, unsigned int n, const char *bat)
954 get_battery_stuff(buffer, n, bat, BATTERY_STATUS);
955 if (0 == strncmp("charging", buffer, 8)) {
957 memmove(buffer + 1, buffer + 8, n - 8);
958 } else if (0 == strncmp("discharging", buffer, 11)) {
960 memmove(buffer + 1, buffer + 11, n - 11);
961 } else if (0 == strncmp("absent/on AC", buffer, 12)) {
963 memmove(buffer + 1, buffer + 12, n - 12);
967 /* empty stubs so conky links */
968 void update_entropy(void) {}
969 void free_all_processes(void) {}
970 void clear_cpu_stats(void) {}