- Commit
- 2f22f01864ff34f07be09c99acb90fc04dff131d
- Parent
- 8a5f15b6734ac4dd7119b082d94caa638c2343c4
- Author
- Pablo <pablo-pie@riseup.net>
- Date
Improved the output of the get command
Use div_ceil when normalizing the volume to avoid rouding issues
Simple interface to set PulseAudio's volume, with graphical feedback! 🔊
Improved the output of the get command
Use div_ceil when normalizing the volume to avoid rouding issues
1 files changed, 4 insertions, 1 deletions
| Status | Name | Changes | Insertions | Deletions |
| Modified | src/main.c | 2 files changed | 4 | 1 |
diff --git a/src/main.c b/src/main.c @@ -419,8 +419,11 @@ void vol_get_cb(pa_context* ctx, const pa_sink_info* info, int eol, void* data) assert(info); assert(info->volume.channels > 0); - uint32_t vol_percent = pa_cvolume_avg(&info->volume)*100/PA_VOLUME_NORM; +#define DIV_CEIL(p, q) (((p) + (q) - 1)/(q)) + uint32_t vol_percent = DIV_CEIL(pa_cvolume_avg(&info->volume)*100, + PA_VOLUME_NORM); printf("%d%%\n", vol_percent); +#undef DIV_CEIL if (cmd.show_graphics) x11_launch_window(vol_percent, WIN_TIMEOUT_MS);