From 51ea4af2f52b44518daf34375d469ade3cecae3a Mon Sep 17 00:00:00 2001 From: ABelliqueux Date: Sat, 4 Jan 2025 11:28:11 +0100 Subject: [PATCH] Fix volume --- mpdlisten.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mpdlisten.py b/mpdlisten.py index 180793d..7e8797f 100755 --- a/mpdlisten.py +++ b/mpdlisten.py @@ -379,8 +379,9 @@ def main(args): # ~ songs_from_album = client.list('title', 'album', album_by_x[x]) # Set Init volume in encoder and mpd - enc.setCounter(init_volume) - client.setvol(init_volume) + volume = init_volume + enc.setCounter(volume) + client.setvol(volume) offset_polygons(MODES) global ui_vol_icon_polygon @@ -388,9 +389,15 @@ def main(args): global static_ui static_ui = generate_static_ui(current_mode) while ctrlc_pressed is False: - global volume # Rotary encoder - client.setvol(int(enc.getValue())) + cur_vol = int(client.getvol()['volume']) + if cur_vol != volume: + volume = cur_vol + elif int(enc.getValue()) != volume: + volume = int(enc.getValue()) + client.setvol(volume) + enc.setCounter(volume) + #ui_idle_for = 0 # MPD mpd_status = client.status()