Compare commits

...

15 Commits

Author SHA1 Message Date
Jonas DOREL e9f53b2986
Merge dbec0d73a1 into 11b522c313 2024-01-18 11:59:44 +07:00
Roddy Rappaport 11b522c313 doc: Added unmute-on-scroll to changelog and module descriptions 2024-01-17 18:01:10 +01:00
Roddy Rappaport 82a81ce07c feat(pulseaudio): Add unmute on scroll option (polybar#3067)
This will allow users to specify in their config if they want the mixers
to unmute if they use the scroll wheel on the module.

Closes: #3067
2024-01-17 18:01:10 +01:00
Roddy Rappaport c2dd279bf7 feat(alsa): Add unmute on scroll option (polybar#3067)
This will allow users to specify in their config if they want the mixers
to unmute if they use the scroll wheel on the module.
2024-01-17 18:01:10 +01:00
patrick96 174ce34285 fix(doc): Update vulnerable rtd search extension
Ref: https://github.com/readthedocs/readthedocs-sphinx-search/security/advisories/GHSA-xgfm-fjx6-62mj
2024-01-16 22:37:15 +01:00
patrick96 b4d8be590b Update PKGBUILD for 3.7.1 2023-11-27 17:36:23 +01:00
patrick96 b25d00b159 fix(doc): Wrong header level in changelog 2023-11-27 17:29:31 +01:00
patrick96 367847ec3b
Merge branch 'hotfix/3.7.1' 2023-11-27 17:20:39 +01:00
patrick96 91bd85cf50
Version 3.7.1 2023-11-27 17:15:23 +01:00
patrick96 ade2ee0981 build: Update i3ipcpp
Closes #3042
Includes polybar/i3ipcpp#16
2023-11-27 15:53:30 +01:00
patrick96 c552df3b66 fix: Modules did not validate tags used in formats
The 'value' variable that was used for validation, was empty because it
was used in a move at the beginning of the function.

Fixes #3043
2023-11-16 22:29:00 +01:00
patrick96 432e19df01 build: Add missing headers in common.hpp 2023-11-12 15:18:34 +01:00
patrick96 cbfbba0700 Remove tray_visibility signal
No longer needed since tray visibility is now controlled directly by the
enclosing module
2023-11-11 04:01:26 +01:00
patrick96 8566051336 fix(tray): Allow module to disappear for empty tray
Modules that don't produce any output are hidden by the controller
(don't have margins or separators).
The tray module should also do that for `format = <tray>` when there are
no icons.

This required the visibility handling to be tied to the module
visibility instead of being handled by the renderer.
Otherwise, the renderer would hide the tray (because the %{Pt} tag was
never sent) and the tray would not unhide when new icons appeared; it
can't differentiate between hidden because empty and hidden because the
module is hidden by the user (the latter is the reason the renderer does
hiding at all).

Fixes #3036
2023-11-11 04:01:26 +01:00
Jonas DOREL dbec0d73a1
Update actions.rst 2022-12-22 16:22:26 +01:00
22 changed files with 101 additions and 59 deletions

View File

@ -9,6 +9,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- An option `unmute-on-scroll` for `internal/pulseaudio` and `internal/alsa` to unmute audio when the user scrolls on the widget.
## [3.7.1] - 2023-11-27
### Build
- Fixed missing header when using `libc++` in clang 15 and below
### Changed
- `internal/tray`: The module must use the `<tray>` tag (this is the default) ([`#3037`](https://github.com/polybar/polybar/pull/3037))
### Fixed
- Modules did not validate that all tags (e.g. `<label>`) used in a format were valid for that format ([`#3043`](https://github.com/polybar/polybar/issues/3043), [`#3045`](https://github.com/polybar/polybar/pull/3045))
- `internal/tray`: Fixed `module-margin` and `separator` being applied to completely empty tray module ([`#3036`](https://github.com/polybar/polybar/issues/3036), [`#3037`](https://github.com/polybar/polybar/pull/3037))
## [3.7.0] - 2023-11-05
### Breaking
@ -247,7 +260,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Empty color values are no longer treated as invalid and no longer produce an error.
[Unreleased]: https://github.com/polybar/polybar/compare/3.7.0...HEAD
[Unreleased]: https://github.com/polybar/polybar/compare/3.7.1...HEAD
[3.7.1]: https://github.com/polybar/polybar/releases/tag/3.7.1
[3.7.0]: https://github.com/polybar/polybar/releases/tag/3.7.0
[3.6.3]: https://github.com/polybar/polybar/releases/tag/3.6.3
[3.6.2]: https://github.com/polybar/polybar/releases/tag/3.6.2

View File

@ -1,7 +1,7 @@
# Maintainer: Patrick Ziegler <p.ziegler96@gmail.com>
_pkgname=polybar
pkgname="${_pkgname}-git"
pkgver=3.7.0
pkgver=3.7.1
pkgrel=1
pkgdesc="A fast and easy-to-use status bar"
# aarch64 is not officially supported by polybar, it is only listed here for convenience

View File

@ -4,4 +4,4 @@
sphinx~=7.2.6
sphinx-rtd-theme~=2.0.0rc2
sphinx-notfound-page~=1.0.0
readthedocs-sphinx-search~=0.3.1
readthedocs-sphinx-search~=0.3.2

View File

@ -92,6 +92,9 @@ when you click anywhere on the bar (where there isn't another click action):
This will then trigger the ``toggle`` action on the ``mydate`` module when you
click anywhere on the bar.
/!\\ ``click-left`` and related trigger configurations are only possible in the bar section,
as well as in the following modules: ``text``, ``script``, ``ipc``.
Similarly, we can use action strings in ``%{A}``
`formatting tags <https://github.com/polybar/polybar/wiki/Formatting#action-a>`_
just as we would regular commands:
@ -153,6 +156,9 @@ internal/alsa
``interval`` is the config setting in the module. Volume changed like this
will never go above 100%.
if ``unmute-on-scroll`` is turned on, the sound will also be unmuted when
this action is called.
:``toggle``:
Toggles between muted and unmuted.
@ -165,6 +171,9 @@ internal/pulseaudio
will never go above ~153% (if ``use-ui-max`` is set to ``true``) or 100% (if
not).
if ``unmute-on-scroll`` is turned on, the sound will also be unmuted when
this action is called.
:``toggle``:
Toggles between muted and unmuted.

View File

@ -1,9 +1,11 @@
#pragma once
#include <array>
#include <functional>
#include <memory>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include "settings.hpp"

View File

@ -104,9 +104,6 @@ namespace signals {
struct tray_pos_change : public detail::value_signal<tray_pos_change, int> {
using base_type::base_type;
};
struct tray_visibility : public detail::value_signal<tray_visibility, bool> {
using base_type::base_type;
};
} // namespace ui_tray
} // namespace signals

View File

@ -36,7 +36,6 @@ namespace signals {
} // namespace ui
namespace ui_tray {
struct tray_pos_change;
struct tray_visibility;
} // namespace ui_tray
} // namespace signals

View File

@ -67,6 +67,7 @@ namespace modules {
map<control, control_t> m_ctrl;
int m_headphoneid{0};
bool m_mapped{false};
bool m_unmute_on_scroll{false};
int m_interval{5};
atomic<bool> m_muted{false};
atomic<bool> m_headphones{false};

View File

@ -189,7 +189,7 @@ namespace modules {
string get_format() const;
string get_output();
void set_visible(bool value);
virtual void set_visible(bool value);
void action_module_toggle();
void action_module_show();

View File

@ -51,6 +51,7 @@ namespace modules {
pulseaudio_t m_pulseaudio;
int m_interval{5};
bool m_unmute_on_scroll{false};
atomic<bool> m_muted{false};
atomic<int> m_volume{0};
atomic<double> m_decibels{0};

View File

@ -8,11 +8,21 @@
POLYBAR_NS
namespace modules {
/**
* Wraps the tray_manager in a module.
*
* The module produces the `%{Pt}` formatting tag, which is used by the renderer
* to place the tray.
* The visibility of the tray icons is directly tied to the visibility of the
* module.
*/
class tray_module : public static_module<tray_module> {
public:
explicit tray_module(const bar_settings& bar_settings, string name_, const config&);
string get_format() const;
void set_visible(bool value) override;
void start() override;
bool build(builder* builder, const string& tag) const;

View File

@ -116,14 +116,13 @@ class tray_client {
unsigned int m_height;
};
class tray_manager
: public xpp::event::sink<evt::expose, evt::visibility_notify, evt::client_message, evt::configure_request,
evt::resize_request, evt::selection_clear, evt::property_notify, evt::reparent_notify, evt::destroy_notify,
evt::map_notify, evt::unmap_notify>,
public signal_receiver<SIGN_PRIORITY_TRAY, signals::ui::visibility_change, signals::ui::dim_window,
signals::ui::update_background, signals::ui_tray::tray_pos_change, signals::ui_tray::tray_visibility>,
public non_copyable_mixin,
public non_movable_mixin {
class tray_manager : public xpp::event::sink<evt::expose, evt::visibility_notify, evt::client_message,
evt::configure_request, evt::resize_request, evt::selection_clear, evt::property_notify,
evt::reparent_notify, evt::destroy_notify, evt::map_notify, evt::unmap_notify>,
public signal_receiver<SIGN_PRIORITY_TRAY, signals::ui::visibility_change, signals::ui::dim_window,
signals::ui::update_background, signals::ui_tray::tray_pos_change>,
public non_copyable_mixin,
public non_movable_mixin {
public:
using make_type = unique_ptr<tray_manager>;
static make_type make(const bar_settings& settings);
@ -194,7 +193,6 @@ class tray_manager
bool on(const signals::ui::dim_window& evt) override;
bool on(const signals::ui::update_background& evt) override;
bool on(const signals::ui_tray::tray_pos_change& evt) override;
bool on(const signals::ui_tray::tray_visibility& evt) override;
private:
connection& m_connection;

View File

@ -76,13 +76,13 @@ struct tray_settings {
using on_update = std::function<void(void)>;
class manager : public xpp::event::sink<evt::expose, evt::client_message, evt::configure_request, evt::resize_request,
evt::selection_clear, evt::property_notify, evt::reparent_notify, evt::destroy_notify,
evt::map_notify, evt::unmap_notify>,
public signal_receiver<SIGN_PRIORITY_TRAY, signals::ui::update_background,
signals::ui_tray::tray_pos_change, signals::ui_tray::tray_visibility>,
non_copyable_mixin,
non_movable_mixin {
class manager
: public xpp::event::sink<evt::expose, evt::client_message, evt::configure_request, evt::resize_request,
evt::selection_clear, evt::property_notify, evt::reparent_notify, evt::destroy_notify, evt::map_notify,
evt::unmap_notify>,
public signal_receiver<SIGN_PRIORITY_TRAY, signals::ui::update_background, signals::ui_tray::tray_pos_change>,
non_copyable_mixin,
non_movable_mixin {
public:
explicit manager(connection& conn, signal_emitter& emitter, const logger& logger, const bar_settings& bar_opts,
on_update on_update);
@ -103,6 +103,8 @@ class manager : public xpp::event::sink<evt::expose, evt::client_message, evt::c
bool is_visible() const;
bool change_visibility(bool visible);
protected:
void recalculate_width();
void reconfigure_clients();
@ -130,7 +132,6 @@ class manager : public xpp::event::sink<evt::expose, evt::client_message, evt::c
void remove_client(const client& client);
void remove_client(xcb_window_t win);
void clean_clients();
bool change_visibility(bool visible);
void handle(const evt::expose& evt) override;
void handle(const evt::client_message& evt) override;
@ -145,7 +146,6 @@ class manager : public xpp::event::sink<evt::expose, evt::client_message, evt::c
bool on(const signals::ui::update_background& evt) override;
bool on(const signals::ui_tray::tray_pos_change& evt) override;
bool on(const signals::ui_tray::tray_visibility& evt) override;
private:
connection& m_connection;

@ -1 +1 @@
Subproject commit 36b2a1b05083837abe259b1990d738feaf4fa866
Subproject commit 0daa58349ab3373161a4a73c1ccd2822328d2c73

View File

@ -839,13 +839,10 @@ bool renderer::on(const signals::ui::request_snapshot& evt) {
}
void renderer::apply_tray_position(const tags::context& context) {
if (context.get_relative_tray_position() != std::pair<alignment, int>()) {
int absolute_x = static_cast<int>(
block_x(context.get_relative_tray_position().first) + context.get_relative_tray_position().second);
auto [alignment, pos] = context.get_relative_tray_position();
if (alignment != alignment::NONE) {
int absolute_x = static_cast<int>(block_x(alignment) + pos);
m_sig.emit(signals::ui_tray::tray_pos_change{absolute_x});
m_sig.emit(signals::ui_tray::tray_visibility{true});
} else {
m_sig.emit(signals::ui_tray::tray_visibility{false});
}
}

View File

@ -28,6 +28,7 @@ namespace modules {
// Load configuration values
m_mapped = m_conf.get(name(), "mapped", m_mapped);
m_interval = m_conf.get(name(), "interval", m_interval);
m_unmute_on_scroll = m_conf.get(name(), "unmute-on-scroll", m_unmute_on_scroll);
auto master_mixer_name = m_conf.get(name(), "master-mixer", "Master"s);
auto speaker_mixer_name = m_conf.get(name(), "speaker-mixer", ""s);
@ -261,6 +262,9 @@ namespace modules {
}
const auto& mixers = get_mixers();
for (auto&& mixer : mixers) {
if (m_unmute_on_scroll) {
mixer->set_mute(true);
}
m_mapped ? mixer->set_normalized_volume(math_util::cap<float>(mixer->get_normalized_volume() + interval, 0, 100))
: mixer->set_volume(math_util::cap<float>(mixer->get_volume() + interval, 0, 100));
}

View File

@ -92,7 +92,7 @@ namespace modules {
};
auto format = make_unique<module_format>();
format->value = move(value);
format->value = std::move(value);
format->fg = m_conf.get(m_modname, name + "-foreground", formatdef("foreground", format->fg));
format->bg = m_conf.get(m_modname, name + "-background", formatdef("background", format->bg));
format->ul = m_conf.get(m_modname, name + "-underline", formatdef("underline", format->ul));
@ -122,18 +122,14 @@ namespace modules {
tag_collection.insert(tag_collection.end(), tags.begin(), tags.end());
tag_collection.insert(tag_collection.end(), whitelist.begin(), whitelist.end());
size_t start, end;
while ((start = value.find('<')) != string::npos && (end = value.find('>', start)) != string::npos) {
if (start > 0) {
value.erase(0, start);
end -= start;
start = 0;
}
string tag{value.substr(start, end + 1)};
size_t start = 0;
size_t end = 0;
while ((start = format->value.find('<', start)) != string::npos && (end = format->value.find('>', start)) != string::npos) {
string tag{format->value.substr(start, end - start + 1)};
if (find(tag_collection.begin(), tag_collection.end(), tag) == tag_collection.end()) {
throw undefined_format_tag(tag + " is not a valid format tag for \"" + name + "\"");
}
value.erase(0, tag.size());
start = end + 1;
}
m_formats.insert(make_pair(move(name), move(format)));

View File

@ -23,6 +23,7 @@ namespace modules {
// Load configuration values
m_interval = m_conf.get(name(), "interval", m_interval);
m_unmute_on_scroll = m_conf.get(name(), "unmute-on-scroll", m_unmute_on_scroll);
auto sink_name = m_conf.get(name(), "sink", ""s);
bool m_max_volume = m_conf.get(name(), "use-ui-max", true);
@ -156,10 +157,16 @@ namespace modules {
}
void pulseaudio_module::action_inc() {
if (m_unmute_on_scroll) {
m_pulseaudio->set_mute(false);
}
m_pulseaudio->inc_volume(m_interval);
}
void pulseaudio_module::action_dec() {
if (m_unmute_on_scroll) {
m_pulseaudio->set_mute(false);
}
m_pulseaudio->inc_volume(-m_interval);
}

View File

@ -8,27 +8,46 @@ namespace modules {
template class module<tray_module>;
tray_module::tray_module(const bar_settings& bar_settings, string name_, const config& config)
: static_module<tray_module>(bar_settings, move(name_), config)
: static_module<tray_module>(bar_settings, std::move(name_), config)
, m_tray(connection::make(), signal_emitter::make(), m_log, bar_settings, [&] { this->broadcast(); }) {
m_formatter->add(DEFAULT_FORMAT, TAG_TRAY, {TAG_TRAY});
/* There are a bunch of edge cases with regards to tray visiblity when the
* <tray> tag is not there (in that case the tray icons should under no
* circumnstances appear). To avoid this, we simply disallow the situation.
* The module is basically useless without that tag anyway.
*/
if (!m_formatter->has(TAG_TRAY, DEFAULT_FORMAT)) {
throw module_error("The " + std::string(TAG_TRAY) + " tag is required in " + name() + "." + DEFAULT_FORMAT);
}
// Otherwise the tray does not see the initial module visibility
m_tray.change_visibility(visible());
}
string tray_module::get_format() const {
return DEFAULT_FORMAT;
}
void tray_module::set_visible(bool value) {
m_tray.change_visibility(value);
static_module<tray_module>::set_visible(value);
}
void tray_module::start() {
m_tray.setup(m_conf, name());
this->static_module<tray_module>::start();
}
bool tray_module::build(builder* builder, const string& tag) const {
if (tag == TAG_TRAY) {
// Don't produce any output if the tray is empty so that the module can be hidden
if (tag == TAG_TRAY && m_tray.get_width() > 0) {
builder->control(tags::controltag::t);
extent_val offset_extent = {extent_type::PIXEL, static_cast<float>(m_tray.get_width())};
builder->offset(offset_extent);
return true;
}
return false;
}

View File

@ -1172,14 +1172,6 @@ bool tray_manager::on(const signals::ui_tray::tray_pos_change& evt) {
return true;
}
bool tray_manager::on(const signals::ui_tray::tray_visibility& evt) {
if (evt.cast() == m_hidden && m_opts.tray_position == tray_postition::MODULE) {
return change_visibility(evt.cast());
} else {
return true;
}
}
tray_client::tray_client(connection& conn, xcb_window_t win, unsigned int w, unsigned int h)
: m_connection(conn), m_window(win), m_width(w), m_height(h) {}

View File

@ -522,7 +522,7 @@ void manager::clean_clients() {
}
bool manager::change_visibility(bool visible) {
if (!is_active() || m_hidden == !visible) {
if (m_hidden == !visible) {
return false;
}
@ -764,10 +764,6 @@ bool manager::on(const signals::ui_tray::tray_pos_change& evt) {
return true;
}
bool manager::on(const signals::ui_tray::tray_visibility& evt) {
return change_visibility(evt.cast());
}
} // namespace tray
POLYBAR_NS_END

View File

@ -1,4 +1,4 @@
# Polybar version information
# Update this on every release
# This is used to create the version string if a git repo is not available
3.7.0
3.7.1