mirror of
https://git.sr.ht/~coasteen/dotfiles
synced 2025-11-04 14:47:38 +01:00
Upload files to ".suckless/slstatus/components"
This commit is contained in:
parent
6068e3ac2f
commit
d7e467af03
5 changed files with 67 additions and 0 deletions
BIN
.suckless/slstatus/components/temperature.o
Normal file
BIN
.suckless/slstatus/components/temperature.o
Normal file
Binary file not shown.
34
.suckless/slstatus/components/uptime.c
Normal file
34
.suckless/slstatus/components/uptime.c
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "../slstatus.h"
|
||||||
|
#include "../util.h"
|
||||||
|
|
||||||
|
#if defined(CLOCK_BOOTTIME)
|
||||||
|
#define UPTIME_FLAG CLOCK_BOOTTIME
|
||||||
|
#elif defined(CLOCK_UPTIME)
|
||||||
|
#define UPTIME_FLAG CLOCK_UPTIME
|
||||||
|
#else
|
||||||
|
#define UPTIME_FLAG CLOCK_MONOTONIC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *
|
||||||
|
uptime(const char *unused)
|
||||||
|
{
|
||||||
|
char warn_buf[256];
|
||||||
|
uintmax_t h, m;
|
||||||
|
struct timespec uptime;
|
||||||
|
|
||||||
|
if (clock_gettime(UPTIME_FLAG, &uptime) < 0) {
|
||||||
|
snprintf(warn_buf, sizeof(warn_buf), "clock_gettime %d", UPTIME_FLAG);
|
||||||
|
warn(warn_buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
h = uptime.tv_sec / 3600;
|
||||||
|
m = uptime.tv_sec % 3600 / 60;
|
||||||
|
|
||||||
|
return bprintf("%juh %jum", h, m);
|
||||||
|
}
|
||||||
BIN
.suckless/slstatus/components/uptime.o
Normal file
BIN
.suckless/slstatus/components/uptime.o
Normal file
Binary file not shown.
33
.suckless/slstatus/components/user.c
Normal file
33
.suckless/slstatus/components/user.c
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "../slstatus.h"
|
||||||
|
#include "../util.h"
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gid(const char *unused)
|
||||||
|
{
|
||||||
|
return bprintf("%d", getgid());
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
username(const char *unused)
|
||||||
|
{
|
||||||
|
struct passwd *pw;
|
||||||
|
|
||||||
|
if (!(pw = getpwuid(geteuid()))) {
|
||||||
|
warn("getpwuid '%d':", geteuid());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bprintf("%s", pw->pw_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
uid(const char *unused)
|
||||||
|
{
|
||||||
|
return bprintf("%d", geteuid());
|
||||||
|
}
|
||||||
BIN
.suckless/slstatus/components/user.o
Normal file
BIN
.suckless/slstatus/components/user.o
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue