Compare commits

...

6 Commits

Author SHA1 Message Date
Ivan Milov 2a48125a9f
Merge 7264513d60 into 11b522c313 2024-01-18 11:46:42 +01: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
Ivan Milov 7264513d60
[module bspwm] fix for https://github.com/polybar/polybar/issues/2420
Adding monitor index field into `bspwm_monitor`
command to focus: `bspc desktop -f <mon_name>:^<workspace_n>` -> `bspc desktop -f ^<mon_index>:^<workspace_n>`
2021-06-30 09:53:21 +02:00
9 changed files with 58 additions and 3 deletions

View File

@ -9,6 +9,8 @@ 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

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

@ -153,6 +153,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 +168,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

@ -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

@ -37,6 +37,7 @@ namespace modules {
label_t label;
string name;
bool focused{false};
size_t index{0};
};
public:

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

@ -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

@ -2,6 +2,8 @@
#include <sys/socket.h>
#include <set>
#include "drawtypes/iconset.hpp"
#include "drawtypes/label.hpp"
#include "modules/meta/base.inl"
@ -201,6 +203,8 @@ namespace modules {
size_t pos;
std::set<size_t> positions;
size_t curr_pos;
// Extract the string for the defined monitor
if (m_pinworkspaces) {
const auto needle_active = ":M" + m_bar.monitor->name + ":";
@ -209,10 +213,27 @@ namespace modules {
if ((pos = data.find(BSPWM_STATUS_PREFIX)) != string::npos) {
data = data.replace(pos, prefix_len, ":");
}
// workaround to get monitor index
{
auto f = [&positions, &data](const std::string& sub) {
size_t pos = data.find(sub, 0);
while (pos != string::npos) {
positions.insert(pos);
pos = data.find(sub, pos + 1);
}
};
f(":m");
f(":M");
}
if ((pos = data.find(needle_active)) != string::npos) {
curr_pos = pos;
data.erase(0, pos + 1);
}
if ((pos = data.find(needle_inactive)) != string::npos) {
curr_pos = pos;
data.erase(0, pos + 1);
}
if ((pos = data.find(":m", 1)) != string::npos) {
@ -227,6 +248,14 @@ namespace modules {
return false;
}
auto index{1};
for (auto p : positions) {
if (p == curr_pos)
break;
index++;
}
m_log.info("%s: Parsing socket data: %s", name(), data);
m_monitors.clear();
@ -241,6 +270,10 @@ namespace modules {
if (tag[0] == 'm' || tag[0] == 'M') {
m_monitors.emplace_back(std::make_unique<bspwm_monitor>());
m_monitors.back()->name = value;
m_monitors.back()->index = index;
if (not m_pinworkspaces)
index++;
if (m_monitorlabel) {
m_monitors.back()->label = m_monitorlabel->clone();
@ -463,7 +496,7 @@ namespace modules {
string workspace_n{data.substr(separator + 1)};
if (monitor_n < m_monitors.size()) {
send_command("desktop -f " + m_monitors[monitor_n]->name + ":^" + workspace_n,
send_command("desktop -f ^" + std::to_string(m_monitors[monitor_n]->index) + ":^" + workspace_n,
"Sending desktop focus command to ipc handler");
} else {
m_log.err("%s: Invalid monitor index in command: %s", name(), data);
@ -501,7 +534,7 @@ namespace modules {
void bspwm_module::send_command(const string& payload_cmd, const string& log_info) {
auto ipc = bspwm_util::make_connection();
auto payload = bspwm_util::make_payload(payload_cmd);
m_log.info("%s: %s", name(), log_info);
m_log.info("%s: %s PAYLOAD: %s", name(), log_info, payload_cmd);
ipc->send(payload->data, payload->len, 0);
ipc->disconnect();
}

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);
}