diff options
Diffstat (limited to 'status-sound.js')
-rw-r--r-- | status-sound.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/status-sound.js b/status-sound.js new file mode 100644 index 0000000..e76c576 --- /dev/null +++ b/status-sound.js @@ -0,0 +1,28 @@ +global.lastKnownAudio = "Muted"; + +let updateAudio = async () => { + let volume = await loudness.getVolume() + let muted = await loudness.getMuted() + + if (!muted) { + global.lastKnownAudio = volume + "%"; + + if (volume <= 0) { + document.getElementById("statusbar-sound-icon").src = "./icons/volume-0.svg"; + } else if (volume <= 33) { + document.getElementById("statusbar-sound-icon").src = "./icons/volume-1.svg"; + } else if (volume <= 66) { + document.getElementById("statusbar-sound-icon").src = "./icons/volume-2.svg"; + } else { + document.getElementById("statusbar-sound-icon").src = "./icons/volume-3.svg"; + } + } else { + global.lastKnownAudio = "Muted"; + document.getElementById("statusbar-sound-icon").src = "./icons/volume-0.svg"; + } +} + +(async () => { + setInterval(updateAudio, 10000) + await updateAudio(); +})()
\ No newline at end of file |