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()