add configs

This commit is contained in:
lucy 2026-02-26 11:58:38 +01:00
commit 774894486f
29 changed files with 106 additions and 2 deletions

View file

@ -219,3 +219,33 @@
return bprintf("%d", v & 0xff);
}
#endif
const char *
vol_perc_pw(const char *sink)
{
FILE *fp;
char buf[64], cmd[64];
double v;
if (esnprintf(cmd, sizeof(cmd), "wpctl get-volume %s", sink) < 0)
return NULL;
if (!(fp = popen(cmd, "r"))) {
warn("popen '%s':", cmd);
return NULL;
}
if (!fgets(buf, sizeof(buf), fp)) {
pclose(fp);
return NULL;
}
pclose(fp);
if (strstr(buf, "[MUTED]"))
return "mute";
if (sscanf(buf, "Volume: %lf", &v) != 1)
return NULL;
return bprintf("%d%%", (int)(v * 100 + 0.5));
}