mirror of
				https://github.com/rad4day/Waybar.git
				synced 2025-11-01 00:12:42 +01:00 
			
		
		
		
	Change scroll-step unit to percent
This commit is contained in:
		| @@ -111,7 +111,7 @@ | ||||
|         "format-disconnected": "Disconnected ⚠" | ||||
|     }, | ||||
|     "pulseaudio": { | ||||
|         //"scroll-step": 1, | ||||
|         // "scroll-step": 1, // %, can be a float | ||||
|         "format": "{volume}% {icon}", | ||||
|         "format-bluetooth": "{volume}% {icon}", | ||||
|         "format-muted": "", | ||||
|   | ||||
| @@ -77,7 +77,8 @@ bool waybar::modules::Pulseaudio::handleVolume(GdkEventScroll *e) { | ||||
|     return 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_; | ||||
|   scrolling_ = true; | ||||
|   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 (volume_ + 1 < 100) { | ||||
|       pa_cvolume_inc(&pa_volume, change); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Olegs Jeremejevs
					Olegs Jeremejevs