changed to easier variable names
This commit is contained in:
parent
8894244cb8
commit
b5813a7f67
|
@ -19,4 +19,4 @@ static const char timeformat[] = "%y-%m-%d %H:%M:%S";
|
||||||
|
|
||||||
/* statusbar */
|
/* statusbar */
|
||||||
#define FORMATSTRING "wifi %4s | bat %4s | cpu %4s %3s | ram %3s | vol %4s | %3s"
|
#define FORMATSTRING "wifi %4s | bat %4s | cpu %4s %3s | ram %3s | vol %4s | %3s"
|
||||||
#define ARGUMENTS pWifi_signal, pBattery, pCpu_usage, pCpu_temperature, pRam_usage, pVolume, pDatetime
|
#define ARGUMENTS wifi_signal, battery, cpu_usage, cpu_temperature, ram_usage, volume, datetime
|
||||||
|
|
76
slstatus.c
76
slstatus.c
|
@ -15,14 +15,14 @@
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
void setstatus(char *str);
|
void setstatus(char *str);
|
||||||
char *battery();
|
char *get_battery();
|
||||||
char *cpu_temperature();
|
char *get_cpu_temperature();
|
||||||
char *cpu_usage();
|
char *get_cpu_usage();
|
||||||
char *datetime();
|
char *get_datetime();
|
||||||
char *ram_usage();
|
char *get_ram_usage();
|
||||||
char *smprintf(char *fmt, ...);
|
char *smprintf(char *fmt, ...);
|
||||||
char *volume();
|
char *get_volume();
|
||||||
char *wifi_signal();
|
char *get_wifi_signal();
|
||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
static Display *dpy;
|
static Display *dpy;
|
||||||
|
@ -37,7 +37,7 @@ setstatus(char *str)
|
||||||
|
|
||||||
/* battery percentage */
|
/* battery percentage */
|
||||||
char *
|
char *
|
||||||
battery()
|
get_battery()
|
||||||
{
|
{
|
||||||
int battery_now, battery_full, battery_perc;
|
int battery_now, battery_full, battery_perc;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
@ -75,7 +75,7 @@ battery()
|
||||||
|
|
||||||
/* cpu temperature */
|
/* cpu temperature */
|
||||||
char *
|
char *
|
||||||
cpu_temperature()
|
get_cpu_temperature()
|
||||||
{
|
{
|
||||||
int temperature;
|
int temperature;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
@ -98,7 +98,7 @@ cpu_temperature()
|
||||||
|
|
||||||
/* cpu percentage */
|
/* cpu percentage */
|
||||||
char *
|
char *
|
||||||
cpu_usage()
|
get_cpu_usage()
|
||||||
{
|
{
|
||||||
int cpu_perc;
|
int cpu_perc;
|
||||||
long double a[4], b[4];
|
long double a[4], b[4];
|
||||||
|
@ -140,7 +140,7 @@ cpu_usage()
|
||||||
|
|
||||||
/* date and time */
|
/* date and time */
|
||||||
char *
|
char *
|
||||||
datetime()
|
get_datetime()
|
||||||
{
|
{
|
||||||
time_t tm;
|
time_t tm;
|
||||||
size_t bufsize = 19;
|
size_t bufsize = 19;
|
||||||
|
@ -159,7 +159,7 @@ datetime()
|
||||||
|
|
||||||
/* ram percentage */
|
/* ram percentage */
|
||||||
char *
|
char *
|
||||||
ram_usage()
|
get_ram_usage()
|
||||||
{
|
{
|
||||||
int ram_perc;
|
int ram_perc;
|
||||||
long total, free, available;
|
long total, free, available;
|
||||||
|
@ -213,7 +213,7 @@ smprintf(char *fmt, ...)
|
||||||
|
|
||||||
/* alsa volume percentage */
|
/* alsa volume percentage */
|
||||||
char *
|
char *
|
||||||
volume()
|
get_volume()
|
||||||
{
|
{
|
||||||
int mute = 0;
|
int mute = 0;
|
||||||
long vol = 0, max = 0, min = 0;
|
long vol = 0, max = 0, min = 0;
|
||||||
|
@ -251,7 +251,7 @@ volume()
|
||||||
|
|
||||||
/* wifi percentage */
|
/* wifi percentage */
|
||||||
char *
|
char *
|
||||||
wifi_signal()
|
get_wifi_signal()
|
||||||
{
|
{
|
||||||
int bufsize = 255;
|
int bufsize = 255;
|
||||||
int strength;
|
int strength;
|
||||||
|
@ -317,6 +317,13 @@ int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
char status[1024];
|
char status[1024];
|
||||||
|
char *wifi_signal = NULL;
|
||||||
|
char *battery = NULL;
|
||||||
|
char *cpu_usage = NULL;
|
||||||
|
char *cpu_temperature = NULL;
|
||||||
|
char *ram_usage = NULL;
|
||||||
|
char *volume = NULL;
|
||||||
|
char *datetime = NULL;
|
||||||
|
|
||||||
/* open display */
|
/* open display */
|
||||||
if (!(dpy = XOpenDisplay(0x0))) {
|
if (!(dpy = XOpenDisplay(0x0))) {
|
||||||
|
@ -324,32 +331,29 @@ main()
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *pWifi_signal = NULL;
|
|
||||||
char *pBattery = NULL;
|
|
||||||
char *pCpu_usage = NULL;
|
|
||||||
char *pCpu_temperature = NULL;
|
|
||||||
char *pRam_usage = NULL;
|
|
||||||
char *pVolume = NULL;
|
|
||||||
char *pDatetime = NULL;
|
|
||||||
|
|
||||||
/* return status every second */
|
/* return status every second */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
pWifi_signal = wifi_signal();
|
/* assign the values */
|
||||||
pBattery = battery();
|
wifi_signal = get_wifi_signal();
|
||||||
pCpu_usage = cpu_usage();
|
battery = get_battery();
|
||||||
pCpu_temperature = cpu_temperature();
|
cpu_usage = get_cpu_usage();
|
||||||
pRam_usage = ram_usage();
|
cpu_temperature = get_cpu_temperature();
|
||||||
pVolume = volume();
|
ram_usage = get_ram_usage();
|
||||||
pDatetime = datetime();
|
volume = get_volume();
|
||||||
|
datetime = get_datetime();
|
||||||
|
|
||||||
|
/* return the status */
|
||||||
sprintf(status, FORMATSTRING, ARGUMENTS);
|
sprintf(status, FORMATSTRING, ARGUMENTS);
|
||||||
setstatus(status);
|
setstatus(status);
|
||||||
free(pWifi_signal);
|
|
||||||
free(pBattery);
|
/* free the values */
|
||||||
free(pCpu_usage);
|
free(wifi_signal);
|
||||||
free(pCpu_temperature);
|
free(battery);
|
||||||
free(pRam_usage);
|
free(cpu_usage);
|
||||||
free(pVolume);
|
free(cpu_temperature);
|
||||||
free(pDatetime);
|
free(ram_usage);
|
||||||
|
free(volume);
|
||||||
|
free(datetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close display */
|
/* close display */
|
||||||
|
|
Loading…
Reference in New Issue