kekl
This commit is contained in:
3
Makefile
3
Makefile
@ -28,7 +28,8 @@ COM =\
|
||||
components/user\
|
||||
components/volume\
|
||||
components/wifi\
|
||||
components/mullvad
|
||||
components/mullvad\
|
||||
components/relay
|
||||
all: slstatus
|
||||
|
||||
$(COM:=.o): config.mk $(REQ:=.h) slstatus.h
|
||||
|
@ -12,7 +12,7 @@ static int
|
||||
mullvad_conn()
|
||||
{
|
||||
FILE *fp;
|
||||
char buff[128];
|
||||
char buff[0x80];
|
||||
int conn = 0;
|
||||
|
||||
fp = popen(MULLVAD_STAT_CMD, "r");
|
||||
|
45
components/relay.c
Normal file
45
components/relay.c
Normal file
@ -0,0 +1,45 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "../slstatus.h"
|
||||
#include "../util.h"
|
||||
|
||||
#define MULLVAD_STAT_CMD "mullvad status"
|
||||
|
||||
static const char *get_relay() {
|
||||
FILE *fp;
|
||||
char buff[0x80];
|
||||
static char relay[0x80];
|
||||
|
||||
fp = popen("mullvad status", "r");
|
||||
if (fp == NULL) {
|
||||
perror("popen");
|
||||
return NULL;
|
||||
}
|
||||
while (fgets(buff, sizeof(buff), fp) != NULL) {
|
||||
if (strstr(buff, "Relay")) {
|
||||
if (sscanf(buff, "Relay: %s", relay) == 1) {
|
||||
fclose(fp);
|
||||
return relay;
|
||||
}
|
||||
}
|
||||
}
|
||||
pclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *mullvad_relay(const char *stat) {
|
||||
static char rtrelay[0x80];
|
||||
const char *relay = get_relay();
|
||||
|
||||
if (relay != NULL) {
|
||||
snprintf(rtrelay, sizeof(rtrelay), "%s", relay);
|
||||
} else {
|
||||
snprintf(rtrelay, sizeof(rtrelay), "No Relay");
|
||||
}
|
||||
|
||||
return rtrelay;
|
||||
}
|
||||
|
@ -11,13 +11,14 @@ static const struct arg args[] = {
|
||||
{ netspeed_tx, " [ %sB/s]", IFACE },
|
||||
{ ipv4, " ^c#fb4934^[ %s]", IFACE },
|
||||
{ run_command, " ^c#fb4934^[%s]", "sh /opt/suckless/slstatus/components/wg.sh" },
|
||||
{ mullvad_stat, " [VPN: %s]", NULL},
|
||||
{ mullvad_relay, " [%s]", NULL },
|
||||
{ mullvad_stat, " [%s]", NULL },
|
||||
|
||||
//{ battery_perc, " ^c#fe9019^[ %s%%", BAT },
|
||||
//{ battery_remaining," %s]", BAT },
|
||||
|
||||
{ run_command, " ^c#8ec07c^[ %s]", "amixer sget Master | awk -F\"[][]\" '/%/ { print $2 }' | head -n1" },
|
||||
// { vol_perc, " ^c#8ec07c^[ %s]", NULL },
|
||||
//{ run_command, " ^c#8ec07c^[ %s]", "amixer sget Master | awk -F\"[][]\" '/%/ { print $2 }' | head -n1" },
|
||||
{ vol_perc, " ^c#8ec07c^[ %s]", NULL },
|
||||
{ cpu_perc, " ^c#b8bb26^[%s%%]", NULL },
|
||||
{ ram_used, " ^c#d3869b^[ %s]", NULL },
|
||||
{ datetime, " ^c#ebdbb2^[ %s]", "%H:%M:%S" },
|
||||
|
@ -86,3 +86,5 @@ const char *wifi_perc(const char *interface);
|
||||
|
||||
/* mullvad */
|
||||
const char *mullvad_stat(const char *stat);
|
||||
|
||||
const char *mullvad_relay(const char *stat);
|
||||
|
Reference in New Issue
Block a user