summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS.md1
-rw-r--r--slstatus.c21
2 files changed, 14 insertions, 8 deletions
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 63a71c9..7a61847 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -7,3 +7,4 @@ Thanks you very much for your great help!
- [pfannkuckengesicht](https://github.com/pfannkuchengesicht)
- [sahne](https://github.com/sahne)
- [Ali H. Fardan](http://raiz.duckdns.org)
+- [Quentin Rameau](https://fifth.space)
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';