This mostly comes down to tracking whether each channel is a playback,
or capture channel, and using the appropriate APIs when dealing with
it.
Some cleanup related to this:
* Add a channel struct, for per-channel data. Previously, our channel
list was just a list of ALSA channel IDs.
* We now store current volume per-channel (but volume min/max is
per-device)
* Muted state is stored per-channel
* Track both the device’s playback and capture volume ranges, as well
as whether the device *has* playback or capture volume.
* Get the playback/capture volume ranges once, during init, instead of
at each update.
* Use struct pointers for the volume/muted channels. This way we don’t
have to iterate all channels and to string comparisons on the name
each time we update our state.
Previously, only the date command inside the script was run with
LC_TIME=C.
But there’s no reason to be that conservative; we absolutely do not
want _anything_ in that script to generate locale dependent output.
* Bind the foreign-toplevel-manager object *after* the first round of
global objects. This ensures we bind all pre-existing wl-output
objects before binding the toplevel manager. This is important, since
otherwise we wont get any output_enter() events for the initial set of
toplevels.
* Bind xdg-output-manager, to be able to bind xdg-output objects for
each wl-output.
* Add xdg-output-listener to each wl/xdg-output, to be able to get the
outputs’ names.
* Add a list of outputs to each toplevel. The output_enter() event
adds to this list, and output_leave() removes from it.
* Add option ‘all-monitors’. When not set (the default), toplevels are
only included in the generated content if they are mapped on the same
output as the bar itself. When *not* set, all toplevels are always
included in the generated content.
* ‘content’ is a template; the module returns a list of toplevels,
each one instantiated using the content template.
* Each toplevel has 6 tags:
- app-id (string)
- title (string)
- maximized (bool)
- minimized (bool)
- activated (bool)
- fullscreen (bool)
To show the application name and title of the currently active window,
one can do:
- foreign-toplevel:
content:
map:
tag: activated
values:
false: {empty: {}}
true: {string: {text: "{app-id}: {title}"}}
Otherwise we’ll keep adding the same channel(s) over and over again,
for each (successful) connect attempt.
I.e. if you plug and unplug an USB soundcard repeatedly, we’ll keep
extending the channel list each time.
When e.g. a USB soundcard is inserted, we get several CREATE
events. In my experiments, we only succeed in connecting to ALSA after
the last event.
This means, we’ll have several CREATE events that we receive, remove
the watcher, attempt to connect, fail, and then re-add the watcher.
What if that “last” CREATE event occurs while our watcher has been
removed? That’s right, we miss it, and will get stuck waiting forever.
The solution is keep the watcher around.
Now, if we’ve been successfully connected to ALSA for a long time,
chances are we’ve built up events (for other cards, for example). We
don’t want to trigger a storm of re-connect attempts, so drain the
event queue after having been disconnected from ALSA.
There *is* a small race here - if a card is removed and
re-added *very* fast, we _may_ accidentally drain the CREATE event. I
don’t see this happening in reality though.
While waiting for the configured ALSA card to become available, use
inotify and watch for CREATE events on /dev/snd instead of
polling (using a timeout in the poll(3) call).
Note that we don’t know the actual names of the files that (will) be
created. This means:
* Every time we see a CREATE event on /dev/snd, we *try* to connect to
ALSA. If we fail, we go back to watching /dev/snd again.
* ALSA (not yambar) will log an error message each time we fail.
These options allows you to select which channel to use as volume
source, and which channel to use as the source for the muted state.
With this, we can also remove the check for *all* (playback) channels
having the same volume/muted state. And with that, we no longer need
to warn when not all channels have the same volume/muted state.
With this patch, a non-existing ALSA device is no longer considered a
fatal error. Instead, we keep retrying until we succeed.
Furthermore, if we have successfully opened the ALSA device, and it
then disappears, we a) no longer crash, or cause 100% CPU usage, and
b) try to re-connect to the device.
With this, we now handle e.g. USB soundcards being disconnected and
then re-connected. We should also handle pseudo devices, like pipewire
provides ones, when yambar is started before pipewire.
Closes#59Closes#61Closes#86
If the module is empty (width is 0) no spacing will be rendered for it.
This makes modules that auto-hide (for example, network modules for interfaces not used all of the time) occupy no space in the bar.
When set, river tags and seats’ view titles apply to the output yambar
is on, only.
The default is disabled, which implements the old behavior, where
river tags and seats’ view titles represent the union of all
outputs.
This allows you to configure the width of each side of the border
individually. border.width can still be used, and will set all four
borders to the same width.
Closes#77