You are not logged in.
Hi everyone,
I am trying to set up a status bar for dwm with dwmblocks. I would like to output both the screen brightness and speakers volume, both in percentage, but I don't know how to do so with a shell command (except for, maybe, the screen brightness: xrandr --verbose sort of outputs the screen brightness level, but not in percentage).
Also, I would like my status bar to be refreshed any time I modify either the screen brightness or the speakers volume (not only every X seconds, as specified in my config file). I imagine this has something to do with the "update signal" column in the dwmblocks .config file, and there is something to be implemented in the dwm .config file in order to make this work, but I still haven't figured out what. May someone give me a hint?
Thanks in advance! ![]()
Offline
You can control brightness using xbacklight and volume using pactl and send a signal evertime you press the key.
Put these in your dwm config
{ 0, XF86XK_MonBrightnessDown, spawn, SHCMD("xbacklight -dec 5; kill -44 $(pidof dwmblocks)") },
{ 0, XF86XK_MonBrightnessUp, spawn, SHCMD("xbacklight -inc 5; kill -44 $(pidof dwmblocks)") },
{ 0, XF86XK_AudioMute, spawn, SHCMD("pactl set-sink-mute 0 toggle; kill -44 $(pidof dwmblocks)") },
{ 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pactl set-sink-mute 0 false ; pactl set-sink-volume 0 -1%; kill -44 $(pidof dwmblocks)") },
{ 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pactl set-sink-mute 0 false ; pactl set-sink-volume 0 +1%; kill -44 $(pidof dwmblocks)") },and these in your dwm blocks config
{"", "xbacklight -get | awk -F. '{print $1}'", 0, 10, },
{"", "./volume.sh", 0, 10, },I use this volume.sh script to show vol info in my dwmblocks
#!/bin/sh
vol=$(pamixer --get-volume)
mute=$(pamixer --get-mute)
if [ $mute == true ]
then
echo "$vol"
else
echo "$vol"
fiOffline
Note that xbacklight only works for Intel cards using the xf86-video-intel driver. Try brightnessctl instead.
And pactl & pamixer only work with PulseAudio (or PipeWire if pipewire-pulse is installed). I think amixer(1) will work universally.
No idea about dwmblocks specifically though. My observations about Luke Smith belong in another thread...
Last edited by Head_on_a_Stick (2022-01-17 19:29:19)
Jin, Jîyan, Azadî
Offline
@aarnar
Thank you! Btw, the "setup" in my dwm config is a little bit different: for the mute volume button for instance, I first define:
static const char *mutevol[] = { "/usr/bin/pactl", "set-sink-mute", "0", "toggle", NULL};and then, in the key bindings section:
{ 0, XF86XK_AudioMute, spawn, {.v = mutevol} },So basically the only difference with your setup is that I define the mutevol function at the beginning of the file and not directly in the key bindings section. May you give me a hint on how to achieve the same result within my setup? ![]()
Offline