marioortizmanero / polybar-pulseaudio-control

A feature-full Polybar module to control PulseAudio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Many unnecessary updates

marioortizmanero opened this issue · comments

I've noticed that when using the script, getCurSink is called twice, and other unnecessary updates are done. I'll document it to do more research and fix it once I have more time:

Only running the script:

❯ bash pulseaudio-control-debug.sh 
getCurSink called
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1

Volume up -> volume down -> single sink switch -> mute (output is called too many times?)

❯ bash pulseaudio-control-debug.sh --listen
getCurSink called
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1
getCurSink called
getCurlVol called
getVolMuteStatus called
 20%    1
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1
getCurSink called
getCurlVol called
getVolMuteStatus called
 58%    2
getCurSink called
getCurlVol called
getVolMuteStatus called
 58%    2
getCurSink called
getCurlVol called
getVolMuteStatus called
 58%    2
getCurSink called
getCurlVol called
getVolMuteStatus called
 58%    2
getCurSink called
getCurlVol called
getVolMuteStatus called
 58%    2
getCurSink called
getCurlVol called
getVolMuteStatus called
%{F#6b6b6b} 58%    2%{F-}

Random update when seemingly nothing changed:

❯ bash pulseaudio-control-debug.sh --listen
getCurSink called
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1

Update when a new song starts (unnecessary):

❯ bash pulseaudio-control-debug.sh --listen
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1

Update when the song is paused (unnecessary):

❯ bash pulseaudio-control-debug.sh --listen
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1
getCurSink called
getCurlVol called
getVolMuteStatus called
 18%    1

Increasing & decreasing the volume (curiously, getCurVol is only called once for the latter)::

❯ bash pulseaudio-control-debug.sh --up    
getCurSink called
volUp called
getCurlVol called
getCurlVol called

❯ bash pulseaudio-control-debug.sh --down
getCurSink called
volDown called
getCurlVol called

Other calls:

❯ bash pulseaudio-control-debug.sh --sync
getCurSink called
volSync called
getSinkInputs called
getCurlVol called

❯ bash pulseaudio-control-debug.sh --change
getCurSink called
changeDevice called

If the global getCurSink is removed, these errors are displayed:

❯ bash pulseaudio-control.bash --up
pulseaudio-control.sh: line 58: [: 102
30
58: integer expression expected
pulseaudio-control.sh: line 60: [: 102
30
58: integer expression expected
❯ bash pulseaudio-control.bash --down
Operation failed: Invalid argument

Because activeSink is empty when getCurVol is called. This is because getCurSink should be called in volUp and volDown before getCurVol. I should also check for more possible errors related to that before removing the global getCurSink. Maybe if getCurVol took a parameter rather than activeSink it would be easier to manage.

EDIT: done