Minor fixes...
authornorly <ny-git@enpas.org>
Tue, 14 Feb 2012 14:12:24 +0000 (14:12 +0000)
committernorly <ny-git@enpas.org>
Tue, 14 Feb 2012 14:12:24 +0000 (14:12 +0000)
statuses/cpuusage.c
statuses/memusage.c
statuses/volume_alsa.c
sysstatus.c

index fa9282974951c5a61b95fa4c7bee58e3a3ad15b0..dd9f1c516eb3e86ef67d4c51821cccb2d3b5defb 100644 (file)
@@ -23,11 +23,11 @@ float cpu_history[CPU_HISTORY_SIZE]; // don't care about init values
 void status_cpuusage()
 {
        double loadavg[3] = { -13.37, -13.37, -13.37 } ;
-       
+
        char *stline = NULL;
        size_t stlen;
        FILE *stfile;
-       
+
        unsigned long cpu_user;
        unsigned long cpu_nice;
        unsigned long cpu_sys;
@@ -35,51 +35,51 @@ void status_cpuusage()
        unsigned long cpu_idle;
        unsigned long cpu_total;
        int i;
-       
-       
+
+
        fputs("^fg(yellow)", stdout);   // Error signaling color
-       
+
        stfile = fopen("/proc/stat", "r");
        if (stfile != NULL)
        {
                for(i = CPU_HISTORY_SIZE - 1; i > 0; i--)
                        cpu_history[i] = cpu_history[i - 1];
-               
+
                stlen = getline(&stline, &stlen, stfile);
                fclose(stfile);
-               
-               if ( 4 == sscanf(stline, "%*s %ld %ld %ld %ld", &cpu_user, &cpu_nice, &cpu_sys, &cpu_idle) );
+
+               if ( 4 == sscanf(stline, "%*s %ld %ld %ld %ld", &cpu_user, &cpu_nice, &cpu_sys, &cpu_idle) )
                {
                        cpu_used = cpu_user + cpu_nice + cpu_sys;
                        cpu_total = cpu_used + cpu_idle;
-                       
+
                        // Now do the percentage
                        cpu_history[0] = (float)(cpu_used - last_cpu_used) /
                                                (float)(cpu_total - last_cpu_total);
-                       
+
                        last_cpu_used = cpu_used;
                        last_cpu_total = cpu_total;
-                       
-                       
+
+
                        if (cpu_history[0] < 0.4)
                                fputs("^fg(#0077FF)", stdout);  // CPU idling OK
                        else
                                fputs("^fg(#FF00FF)", stdout);  // CPU busy
-                       
+
                        //printf(" CPU: %.0f%% ", cpu_history[0] * 100);
                }
-               
+
                free(stline);
        }
-       
-       
-       if (getloadavg(loadavg, 3) > 0);
+
+
+       if (getloadavg(loadavg, 3) > 0)
                printf(" %s%.0f,%.0f,%.0f,%.0f ",
                        cpu_history[0] < 0.1000 ? " " : "",
                        cpu_history[0] * 100,
                        loadavg[0] * (100 / 1),
                        loadavg[1] * (100 / 1), // (100 / NUM_CPUS)
                        loadavg[2] * (100 / 1));
-       
+
        //fputs(" CPU usage ", stdout);
 }
index 10d373251361ca5701f0eeca95dcb852721518cb..37ba563ca59a45c5cf8e22e9aa2e157fe85dabf0 100644 (file)
@@ -8,41 +8,41 @@ void status_memusage()
        char *stline = NULL;
        size_t stlen;
        FILE *stfile;
-       
+
        int memtotal = 0;
        int memfree = 0;
        int memused;
        int membuffers = 0;
        int memcached = 0;
-       
-       
+
+
        stfile = fopen("/proc/meminfo", "r");
        if (stfile != NULL)
        {
                stlen = getline(&stline, &stlen, stfile);
                memtotal = atoi(&stline[17]);
-               
+
                stlen = getline(&stline, &stlen, stfile);
                memfree = atoi(&stline[17]);
-               
+
                stlen = getline(&stline, &stlen, stfile);
                membuffers = atoi(&stline[17]);
-               
+
                stlen = getline(&stline, &stlen, stfile);
                memcached = atoi(&stline[17]);
                free(stline);
-               
+
                fclose(stfile);
-               
+
                memused = memtotal - memfree - memcached - membuffers;
-               
+
                memused /= 1024;        // Just show MBs used
-               
+
                if ((float)memused / (float)memtotal < 0.85)
                        fputs("^fg(green)", stdout);    // < 85% mem used
                else
                        fputs("^fg(red)", stdout);      // >= 85% mem used
-               
+
                printf(" Mem: %d M ", memused);
        }
 }
index 0b1546a168cc55875ed3c6cd8df92df43e3940c0..527cafe7bce2cdf860c00df735e8a65540eae44a 100644 (file)
@@ -6,32 +6,32 @@ int status_volume_alsa(char *cardname, char *mixername, snd_mixer_selem_channel_
        snd_mixer_t *handle = NULL;
        snd_mixer_elem_t *elem;
        snd_mixer_selem_id_t *sid;
-       
+
        long min = 0, max = 0;
        long volume;
        int on_off;
-       
-       
+
+
        snd_mixer_selem_id_alloca(&sid);
 
        if (snd_mixer_open(&handle, 0) < 0)
                return -1;
-       
+
        if (snd_mixer_attach(handle, cardname) < 0)
                goto ERROR;
-       
+
        snd_mixer_selem_id_set_name(sid, mixername);
-       
+
        if (snd_mixer_selem_register(handle, NULL, NULL) < 0)
                goto ERROR;
-       
+
        if (snd_mixer_load(handle) < 0)
                goto ERROR;
-       
+
        elem = snd_mixer_find_selem(handle, sid);
        if (!elem)
                goto ERROR;
-       
+
        if (snd_mixer_selem_has_playback_volume(elem) && snd_mixer_selem_has_playback_channel(elem, channel))
        {
                snd_mixer_selem_get_playback_switch(elem, channel, &on_off);
@@ -39,9 +39,9 @@ int status_volume_alsa(char *cardname, char *mixername, snd_mixer_selem_channel_
                        fputs("^fg(#22FF22)", stdout);
                else
                        fputs("^fg(red)", stdout);
-               
+
                snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
-               
+
                snd_mixer_selem_get_playback_volume(elem, channel, &volume);
                fputs("^ca(1, amixer sset Master toggle)", stdout);
                fputs("^ca(4, amixer sset Master 2+ unmute)", stdout);
@@ -55,9 +55,9 @@ int status_volume_alsa(char *cardname, char *mixername, snd_mixer_selem_channel_
        snd_mixer_close(handle);
 
        return 0;
-       
+
        ERROR:
-       
+
        snd_mixer_close(handle);
        return -1;
 }
index f5e980c82f654df68c0ea980bbec64ba5161ba10..cac8333056b29a66689ccc0c2a0a6fc674c0cb64 100644 (file)
@@ -1,7 +1,6 @@
 #include <stdio.h>
-#include <fcntl.h>
 #include <stdlib.h>
-#include <unistd.h>
+#include "config.h"
 #include "statuses/battery.h"
 #include "statuses/cpuusage.h"
 #include "statuses/datetime.h"
@@ -10,7 +9,7 @@
 #include "statuses/volume_alsa.h"
 #include "statuses/temp.h"
 #include "statuses/uptime.h"
-#include "config.h"
+
 
 void updatestatus()
 {