torrinfail / dwmblocks

Modular status bar for dwm written in c.
ISC License
495 stars 310 forks source link

Volume display on OpenBSD #67

Closed swindlesmccoop closed 2 years ago

swindlesmccoop commented 2 years ago

When I was using i3blocks, I was able to enter either while true; do [command]; sleep 0.1 to update a command every 0.1 seconds. Now I've read that you can use signals to tell it when to update since the program does not support floating numbers. What is the signal that I need to use for it to update? I think it was 10 when I used Linux but since I am on OpenBSD I think that it's different. However, the ones I have tried (23 and 32) do not seem to work.

swindlesmccoop commented 2 years ago

I did a bit of investigating and realized that I was using signals wrong...anyways, what I figured out is that I needed my script to actually send the signal to the dwmblocks process. The only problem is that all of the blocks to the right of the block where the signal is defined as 1 are truncated. I have attached my blocks.h file for debugging if that's helpful. blocks.h

zamoranos commented 2 years ago

There are two user-defined signals for POSIX Standard signals, SIGUSR1 and SIGUSR2 https://dsa.cs.tsinghua.edu.cn/oj/static/unix_signal.html https://man.openbsd.org/signal.3 https://www.gnu.org/software/libc/manual/html_node/Miscellaneous-Signals.html

I also use OpenBSD btw. For volume control, My dwm/config.h has something like this: { MODKEY, XK_equal, spawn, SHCMD("sndioctl output.level=+0.05; pkill -SIGUSR1 dwmblocks") },

In dwmblocks: {"", "sb-volume", 0, 1},

swindlesmccoop commented 2 years ago

That looks like it would work. Do you know how to bind the actual media keys like on a laptop (in my case the ThinkPad T420) in config.h so that they can run that command instead of whatever arbitrary command its running?

zamoranos commented 2 years ago

I think this will do: { 0, XF86XK_AudioMute, spawn, SHCMD("pkill -SIGUSR1 dwmblocks") }, { 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pkill -SIGUSR1 dwmblocks") }, { 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pkill -SIGUSR1 dwmblocks") },

swindlesmccoop commented 2 years ago

Thank you! This is quite literally the exact thing I was looking for. In case anyone finds this on Google or something, in order to fix the error: use of undeclared identifier 'XF86XK_AudioRaiseVolume' error, you need to add a line above all of the keybinds with #include <X11/XF86keysym.h>