mirror of https://github.com/polybar/polybar.git
Compare commits
6 Commits
be55bd3ecb
...
77513244a2
Author | SHA1 | Date |
---|---|---|
SWarrener | 77513244a2 | |
Roddy Rappaport | 11b522c313 | |
Roddy Rappaport | 82a81ce07c | |
Roddy Rappaport | c2dd279bf7 | |
patrick96 | 174ce34285 | |
SWarrener | 7ed03b3f22 |
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -98,7 +98,9 @@ string filesize_mib(unsigned long long kibibytes, size_t precision = 0, const st
|
|||
string filesize_gib(unsigned long long kibibytes, size_t precision = 0, const string& locale = "");
|
||||
string filesize_gib_mib(
|
||||
unsigned long long kibibytes, size_t precision_mib = 0, size_t precision_gib = 0, const string& locale = "");
|
||||
string filesize(unsigned long long kbytes, size_t precision = 0, bool fixed = false, const string& locale = "");
|
||||
string filesize(unsigned long long bytes, size_t precision = 0, bool fixed = false, const string& locale = "");
|
||||
string filesize_specific(
|
||||
unsigned long long bytes, char target, size_t precision = 0, bool fixed = false, const string& locale = "");
|
||||
|
||||
hash_type hash(const string& src);
|
||||
} // namespace string_util
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -188,6 +188,14 @@ namespace modules {
|
|||
"%total%", string_util::filesize(mount->bytes_total, m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
label->replace_token("%free%", string_util::filesize(mount->bytes_avail, m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
label->replace_token("%used%", string_util::filesize(mount->bytes_used, m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
label->replace_token("%kb_free%", string_util::filesize_specific(mount->bytes_avail, 'k', m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
label->replace_token("%kb_used%", string_util::filesize_specific(mount->bytes_used, 'k', m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
label->replace_token("%mb_free%", string_util::filesize_specific(mount->bytes_avail, 'm', m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
label->replace_token("%mb_used%", string_util::filesize_specific(mount->bytes_used, 'm', m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
label->replace_token("%gb_free%", string_util::filesize_specific(mount->bytes_avail, 'g', m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
label->replace_token("%gb_used%", string_util::filesize_specific(mount->bytes_used, 'g', m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
label->replace_token("%tb_free%", string_util::filesize_specific(mount->bytes_avail, 't', m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
label->replace_token("%tb_used%", string_util::filesize_specific(mount->bytes_used, 't', m_fixed ? 2 : 0, m_fixed, m_bar.locale));
|
||||
};
|
||||
|
||||
if (tag == TAG_BAR_FREE) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
#include <math.h>
|
||||
|
||||
POLYBAR_NS
|
||||
|
||||
|
@ -452,6 +453,33 @@ string filesize(unsigned long long bytes, size_t precision, bool fixed, const st
|
|||
return floating_point(value, precision, fixed, locale) + " " + suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a filesize string with a specific target unit
|
||||
*/
|
||||
string filesize_specific(unsigned long long bytes, char target, size_t precision, bool fixed, const string& locale) {
|
||||
double value = bytes;
|
||||
switch(target) {
|
||||
case 'k':
|
||||
value /= 1024.0;
|
||||
return floating_point(value, precision, fixed, locale) + " KB";
|
||||
break;
|
||||
case 'm':
|
||||
value /= pow(1024.0, 2);
|
||||
return floating_point(value, precision, fixed, locale) + " MB";
|
||||
break;
|
||||
case 'g':
|
||||
value /= pow(1024.0, 3);
|
||||
return floating_point(value, precision, fixed, locale) + " GB";
|
||||
break;
|
||||
case 't':
|
||||
value /= pow(1024.0, 4);
|
||||
return floating_point(value, precision, fixed, locale) + " TB";
|
||||
break;
|
||||
default:
|
||||
return floating_point(value, precision, fixed, locale) + " B";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute string hash
|
||||
*/
|
||||
|
|
|
@ -172,6 +172,8 @@ TEST(String, filesize) {
|
|||
EXPECT_EQ("3 MB", string_util::filesize(3 * 1024 * 1024));
|
||||
EXPECT_EQ("3 GB", string_util::filesize((unsigned long long)3 * 1024 * 1024 * 1024));
|
||||
EXPECT_EQ("3 TB", string_util::filesize((unsigned long long)3 * 1024 * 1024 * 1024 * 1024));
|
||||
EXPECT_EQ("3 TB", string_util::filesize_specific((unsigned long long)3 * 1024 * 1024 * 1024 * 1024, 't'));
|
||||
EXPECT_EQ("3 GB", string_util::filesize_specific((unsigned long long)3 * 1024 * 1024 * 1024, 'g'));
|
||||
}
|
||||
|
||||
// utf8_to_ucs4 {{{
|
||||
|
|
Loading…
Reference in New Issue