Change scroll-step unit to percent
parent
a1ffa7fa9f
commit
d5c1e6f312
|
@ -111,7 +111,7 @@
|
||||||
"format-disconnected": "Disconnected ⚠"
|
"format-disconnected": "Disconnected ⚠"
|
||||||
},
|
},
|
||||||
"pulseaudio": {
|
"pulseaudio": {
|
||||||
//"scroll-step": 1,
|
// "scroll-step": 1, // %, can be a float
|
||||||
"format": "{volume}% {icon}",
|
"format": "{volume}% {icon}",
|
||||||
"format-bluetooth": "{volume}% {icon}",
|
"format-bluetooth": "{volume}% {icon}",
|
||||||
"format-muted": "",
|
"format-muted": "",
|
||||||
|
|
|
@ -77,7 +77,8 @@ bool waybar::modules::Pulseaudio::handleVolume(GdkEventScroll *e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool direction_up = false;
|
bool direction_up = false;
|
||||||
uint16_t change = config_["scroll-step"].isUInt() ? config_["scroll-step"].asUInt() * 100 : 100;
|
double volume_tick = (double)PA_VOLUME_NORM / 100;
|
||||||
|
pa_volume_t change = volume_tick;
|
||||||
pa_cvolume pa_volume = pa_volume_;
|
pa_cvolume pa_volume = pa_volume_;
|
||||||
scrolling_ = true;
|
scrolling_ = true;
|
||||||
if (e->direction == GDK_SCROLL_UP) {
|
if (e->direction == GDK_SCROLL_UP) {
|
||||||
|
@ -97,6 +98,11 @@ bool waybar::modules::Pulseaudio::handleVolume(GdkEventScroll *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isDouble returns true for integers as well, just in case
|
||||||
|
if (config_["scroll-step"].isDouble()) {
|
||||||
|
change = round(config_["scroll-step"].asDouble() * volume_tick);
|
||||||
|
}
|
||||||
|
|
||||||
if (direction_up) {
|
if (direction_up) {
|
||||||
if (volume_ + 1 < 100) {
|
if (volume_ + 1 < 100) {
|
||||||
pa_cvolume_inc(&pa_volume, change);
|
pa_cvolume_inc(&pa_volume, change);
|
||||||
|
|
Loading…
Reference in New Issue