- volume (alsa volume and mute status in percent) [argument: soundcard]
- wifi_signal (wifi signal in percent) [argument: wifi card interface name] */
static const struct arg args[] = {
- /* function format argument */
- { get_wifi_signal, "wifi %4s | ", "wlp3s0" },
- { get_battery, "bat %4s | ", "BAT0" },
- { get_cpu_usage, "cpu %4s ", NULL },
- { get_cpu_temperature, "%3s | ", "/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input" },
- { get_ram_usage, "ram %3s | ", NULL },
- { get_volume, "vol %4s | ", "default" },
- { get_diskusage, "ssd %3s | ", "/" },
- { get_datetime, "%s", "%y-%m-%d %H:%M:%S" }
+ /* function format argument */
+ { wifi_perc, "wifi %4s | ", "wlp3s0" },
+ { battery_perc, "bat %4s | ", "BAT0" },
+ { cpu_perc, "cpu %4s ", NULL },
+ { temp, "%3s | ", "/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input" },
+ { ram_perc, "ram %3s | ", NULL },
+ { vol_perc, "vol %4s | ", "default" },
+ { disk_perc, "ssd %3s | ", "/" },
+ { datetime, "%s", "%y-%m-%d %H:%M:%S" },
};
/* battery percentage */
char *
-get_battery(const char *battery)
+battery_perc(const char *battery)
{
int now, full, perc;
char batterynowfile[64] = "";
return smprintf("%d%%", perc);
}
-/* cpu temperature */
-char *
-get_cpu_temperature(const char *file)
-{
- int temperature;
- FILE *fp;
-
- /* open temperature file */
- if (!(fp = fopen(file, "r"))) {
- fprintf(stderr, "Could not open temperature file.\n");
- return smprintf("n/a");
- }
-
- /* extract temperature */
- fscanf(fp, "%d", &temperature);
-
- /* close temperature file */
- fclose(fp);
-
- /* return temperature in degrees */
- return smprintf("%d°C", temperature / 1000);
-}
-
/* cpu percentage */
char *
-get_cpu_usage(const char *null)
+cpu_perc(const char *null)
{
int perc;
long double a[4], b[4];
/* date and time */
char *
-get_datetime(const char *timeformat)
+datetime(const char *timeformat)
{
time_t tm;
size_t bufsize = 64;
/* disk usage percentage */
char *
-get_diskusage(const char *mountpoint)
+disk_perc(const char *mountpoint)
{
int perc = 0;
struct statvfs fs;
/* ram percentage */
char *
-get_ram_usage(const char *null)
+ram_perc(const char *null)
{
int perc;
long total, free, buffers, cached;
return smprintf("%d%%", perc);
}
+/* temperature */
+char *
+temp(const char *file)
+{
+ int temperature;
+ FILE *fp;
+
+ /* open temperature file */
+ if (!(fp = fopen(file, "r"))) {
+ fprintf(stderr, "Could not open temperature file.\n");
+ return smprintf("n/a");
+ }
+
+ /* extract temperature */
+ fscanf(fp, "%d", &temperature);
+
+ /* close temperature file */
+ fclose(fp);
+
+ /* return temperature in degrees */
+ return smprintf("%d°C", temperature / 1000);
+}
+
+
/* alsa volume percentage */
char *
-get_volume(const char *soundcard)
+vol_perc(const char *soundcard)
{
int mute = 0;
long vol = 0, max = 0, min = 0;
/* wifi percentage */
char *
-get_wifi_signal(const char *wificard)
+wifi_perc(const char *wificard)
{
int bufsize = 255;
int strength;
/* functions */
void setstatus(const char *);
char *smprintf(const char *, ...);
-char *get_battery(const char *);
-char *get_cpu_temperature(const char *);
-char *get_cpu_usage(const char *);
-char *get_datetime(const char *);
-char *get_diskusage(const char *);
-char *get_ram_usage(const char *);
-char *get_volume(const char *);
-char *get_wifi_signal(const char *);
+char *battery_perc(const char *);
+char *cpu_perc(const char *);
+char *datetime(const char *);
+char *disk_perc(const char *);
+char *ram_perc(const char *);
+char *temp(const char *);
+char *vol_perc(const char *);
+char *wifi_perc(const char *);