sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit e1d1fdaba95c6241a1ed8d738e477ce58f45b4ec
parent d0ad4920b6180a3b93a438de83f6f1e844d7ccf7
Author: blut <CXblut@gmail.com>
Date:   Sun,  8 Jun 2014 18:09:00 +0000

dwmstatus alsa volume

Diffstat:
Adwm.suckless.org/dwmstatus/getvol.c | 32++++++++++++++++++++++++++++++++
Mdwm.suckless.org/dwmstatus/index.md | 1+
2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/dwmstatus/getvol.c b/dwm.suckless.org/dwmstatus/getvol.c @@ -0,0 +1,32 @@ +#include <alsa/asoundlib.h> +#include <alsa/control.h> + +int +get_vol(void) +{ + long int vol; + snd_hctl_t *hctl; + snd_ctl_elem_id_t *id; + snd_ctl_elem_value_t *control; + +// To find card and subdevice: /proc/asound/, aplay -L, amixer controls + snd_hctl_open(&hctl, "hw:0", 0); + snd_hctl_load(hctl); + + snd_ctl_elem_id_alloca(&id); + snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); + +// amixer controls + snd_ctl_elem_id_set_name(id, "Master Playback Volume"); + + snd_hctl_elem_t *elem = snd_hctl_find_elem(hctl, id); + + snd_ctl_elem_value_alloca(&control); + snd_ctl_elem_value_set_id(control, id); + + snd_hctl_elem_read(elem, control); + vol = snd_ctl_elem_value_get_integer(control,0); + + snd_hctl_close(hctl); + return (int)vol; +} diff --git a/dwm.suckless.org/dwmstatus/index.md b/dwm.suckless.org/dwmstatus/index.md @@ -46,6 +46,7 @@ add them here as file or as code example. dynamic_info. * [Battery function](batterystatus.c) : Battery percentage and status. + if charging, - if discharging, = if full. +* [Alsa Volume API](getvol.c) : Alsa Volume via the Alsa API Questions ---------