Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: GPIO Config
#1
Hi There,

I want to assign several functions to one button.
http://192.168.178.46/gpio-config.php

It doesn't work with

mpc stop && mpc clear && mpc load Favorites && mpc play
or
mpc stop && mpc clear && mpc load 'Default Playlist' && mpc play


salute
Reply
#2
Multiple commands need to be in an executable script.

Example:

cd ~
sudo nano ./test_script.sh

test_script.sh
Code:
#!/bin/bash
mpc stop && mpc clear && mpc load Favorites && mpc play

sudo chmod +x ./test_script.sh

Then specify the full path to the script as the CMD in GPIO Config.

/home/pi/test_script.sh
Reply
#3
Thanks for this Tip.

nano ./button.sh
chmod +x ./button.sh


http://192.168.178.46/gpio-config.php

/home/pi/button.sh 1
/home/pi/button.sh 2
/home/pi/button.sh 3
/home/pi/button.sh 9

Code:
#!/bin/bash

if [ $# -lt 1 ]
then
       echo "Usage : $0 buttonnumber"
       exit
fi

case "$1" in

1)
   mpc stop
   mpc clear
   mpc load 'Default Playlist'
   mpc play

   ;;
2)
   mpc stop
   mpc clear
   mpc load musik
   mpc play

   ;;
3)  
   mpc stop
   mpc clear
   mpc load Favorites
   mpc play

   ;;
9)
  mpc random
  mpc next
  mpc random
  ;;
*) echo "Signal number $1 is not processed"
  ;;
esac
Reply
#4
Nice :-)
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: