summaryrefslogtreecommitdiff
path: root/slstatus.c
diff options
context:
space:
mode:
Diffstat (limited to 'slstatus.c')
-rw-r--r--slstatus.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/slstatus.c b/slstatus.c
index 3d9712f..d442776 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -6,6 +6,7 @@
#include <ifaddrs.h>
#include <limits.h>
#include <linux/wireless.h>
+#include <locale.h>
#include <netdb.h>
#include <pwd.h>
#include <signal.h>
@@ -271,7 +272,7 @@ hostname(void)
char buf[HOST_NAME_MAX];
if (gethostname(buf, sizeof(buf)) == -1) {
- warn(1, "hostname");
+ warn("hostname");
return smprintf(UNKNOWN_STR);
}
@@ -400,17 +401,19 @@ static char *
run_command(const char *cmd)
{
FILE *fp;
- char buf[64] = "n/a";
+ char buf[1024] = "n/a";
fp = popen(cmd, "r");
if (fp == NULL) {
warn("Failed to get command output for %s", cmd);
return smprintf(UNKNOWN_STR);
}
- fgets(buf, sizeof(buf), fp);
- buf[sizeof(buf)-1] = '\0';
+ fgets(buf, sizeof(buf)-1, fp);
pclose(fp);
+ buf[strlen(buf)] = '\0';
+ strtok(buf, "\n");
+
return smprintf("%s", buf);
}
@@ -497,9 +500,9 @@ vol_perc(const char *card)
snd_mixer_close(handle);
if (max == 0)
- return smprintf("%d%%", 0);
+ return smprintf("0%%");
else
- return smprintf("%d%%", ((uint_fast16_t)(vol * 100) / max));
+ return smprintf("%lu%%", ((uint_fast16_t)(vol * 100) / max));
}
static char *
@@ -619,8 +622,8 @@ main(int argc, char *argv[])
if (dflag && oflag) {
usage();
}
- if (dflag) {
- (void)daemon(1, 1);
+ if (dflag && daemon(1, 1) < 0) {
+ err(1, "daemon");
}
memset(&act, 0, sizeof(act));
@@ -632,6 +635,8 @@ main(int argc, char *argv[])
dpy = XOpenDisplay(NULL);
}
+ setlocale(LC_ALL, "");
+
while (!done) {
status_string[0] = '\0';