Last active
April 19, 2025 13:00
-
-
Save wolfg1969/cfa4078853acdce3ffa75bb24c1c0324 to your computer and use it in GitHub Desktop.
A bash script to mute/unmute as GPIO button command of moOde Audio Player
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ ! -f /var/log/mute_unmute.lock ]; then # avoid running twice in the debounce time | |
touch /var/log/mute_unmute.lock | |
else | |
exit 0 | |
fi | |
volume=$(mpc status | grep volume | awk '{print $2}') | |
vol=${volume::-1} | |
if [ "$vol" != "0" ]; then | |
echo $vol > /tmp/last_vol | |
mpc volume 0 | |
else | |
last_vol=$(cat /tmp/last_vol 2>/dev/null | echo 50) | |
mpc volume $last_vol | |
fi | |
sleep 1.5 # great than the debounce time (which is 1000ms by default) | |
rm /var/log/mute_unmute.lock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment