fixed the code, works now
This commit is contained in:
parent
0da2af8c62
commit
f65fb9bca1
2 changed files with 19 additions and 13 deletions
BIN
.config.h.swp
Normal file
BIN
.config.h.swp
Normal file
Binary file not shown.
32
slstatus.c
32
slstatus.c
|
@ -29,7 +29,7 @@
|
||||||
#include "strlcat.h"
|
#include "strlcat.h"
|
||||||
#include "strlcpy.h"
|
#include "strlcpy.h"
|
||||||
|
|
||||||
typedef char *(*op_fun) (const char *);
|
typedef char *(*op_fun)();
|
||||||
struct arg {
|
struct arg {
|
||||||
op_fun func;
|
op_fun func;
|
||||||
const char *format;
|
const char *format;
|
||||||
|
@ -255,14 +255,8 @@ entropy(void)
|
||||||
static char *
|
static char *
|
||||||
gid(void)
|
gid(void)
|
||||||
{
|
{
|
||||||
gid_t gid;
|
gid_t gid = getgid();
|
||||||
|
return smprintf("%d", gid);
|
||||||
if ((gid = getgid()) < 0) {
|
|
||||||
fprintf(stderr, "Could no get gid.\n");
|
|
||||||
return smprintf(unknowntext);
|
|
||||||
} else
|
|
||||||
return smprintf("%d", gid);
|
|
||||||
return smprintf(unknowntext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
@ -612,9 +606,21 @@ wifi_essid(const char *wificard)
|
||||||
int
|
int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
|
size_t i;
|
||||||
char status_string[1024];
|
char status_string[1024];
|
||||||
|
char *res, *element;
|
||||||
struct arg argument;
|
struct arg argument;
|
||||||
|
|
||||||
|
/* get rid of unused functions warning */
|
||||||
|
if (0) { setstatus(""); battery_perc(""); cpu_perc();
|
||||||
|
datetime(""); disk_free(""); disk_perc("");
|
||||||
|
disk_total(""); disk_used(""); entropy();
|
||||||
|
gid(); hostname(); ip(""); load_avg();
|
||||||
|
ram_free(); ram_perc(); ram_used(); ram_total();
|
||||||
|
run_command(""); temp(""); uid(); uptime();
|
||||||
|
username(); vol_perc(""); wifi_perc("");
|
||||||
|
wifi_essid(""); }
|
||||||
|
|
||||||
if (!(dpy = XOpenDisplay(0x0))) {
|
if (!(dpy = XOpenDisplay(0x0))) {
|
||||||
fprintf(stderr, "Cannot open display!\n");
|
fprintf(stderr, "Cannot open display!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -622,13 +628,13 @@ main(void)
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
memset(status_string, 0, sizeof(status_string));
|
memset(status_string, 0, sizeof(status_string));
|
||||||
for (size_t i = 0; i < sizeof(args) / sizeof(args[0]); ++i) {
|
for (i = 0; i < sizeof(args) / sizeof(args[0]); ++i) {
|
||||||
argument = args[i];
|
argument = args[i];
|
||||||
if (argument.args == NULL)
|
if (argument.args == NULL)
|
||||||
char *res = argument.func();
|
res = argument.func();
|
||||||
else
|
else
|
||||||
char *res = argument.func(argument.args);
|
res = argument.func(argument.args);
|
||||||
char *element = smprintf(argument.format, res);
|
element = smprintf(argument.format, res);
|
||||||
if (element == NULL) {
|
if (element == NULL) {
|
||||||
element = smprintf(unknowntext);
|
element = smprintf(unknowntext);
|
||||||
fprintf(stderr, "Failed to format output.\n");
|
fprintf(stderr, "Failed to format output.\n");
|
||||||
|
|
Loading…
Reference in a new issue