#include #include #include #include "../util.h" #define VOL_BUF_SIZE 4 const char * pamixer_vol_perc(void) { bool MUTED = false; char vol_buf[VOL_BUF_SIZE]; char mute, ch; unsigned short i = 0; FILE *mute_fp = popen("pamixer --get-mute | head -c1", "r"); FILE *vol_fp = popen("pamixer --get-volume | head -c3", "r"); mute = fgetc(mute_fp); pclose (mute_fp); ch = fgetc(vol_fp); while (ch != '\n' && ch != EOF && i < VOL_BUF_SIZE) { vol_buf[i++] = ch; ch = fgetc(vol_fp); } vol_buf[i] = '\0'; pclose (vol_fp); if (mute == 't') { return bprintf("󰝟"); } else { return bprintf("%s%%", vol_buf); } }