WLAN Soundboard
A simple WLAN soundboard that could be much more than this, but for now it's just a PoC to get started with something :)
Prerequisites
These quick and dirty instructions assumes:
- working PostmarketOS device
- pmos version comes with a pre-configured DE and pipewire (like the standard Phosh images)
- sound tested and working (you can ssh and try
paplay somefile.mp3, if it works, you're good, if not, fix the sound first) - working
nginx nginxandsshservices autostart on boot (optional but nice to have, so hey, why not)
sound config
By default the sound server, pipewire is a user service, not a system service, so that means that only the default pmos user user can play sound, we can however expose the pulse server to the whole system, locally via TCP:
- create the file
/etc/pulse/default.pa.d/tcp.pawith this content:
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1
- reboot for the change to take effect, or if you can't wait type:
pactl load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1
Once this is done it means that any user can in theory play sound as long as the environment variable PULSE_SERVER is set to tcp:127.0.0.1:4713.
nginx config
We need to tweak nginx so that it can handle good old Common Gateway Interface (CGI). Ultimately we want to have an URL that points to the execution of a shell script, yet to be written.
- install
fcgiwrap - (also: don't forget to start the service with
sudo rc-service fcgiwrap start
sudo apk add fcgiwrap sudo rc-update add fcgiwrap default
- edit
/etc/nginx/http.d/default.confand add the following part next to the otherlocationdirectives:
# CGI stuff
location /bleeps {
root /var/www/bleeps;
fastcgi_param PULSE_SERVER "tcp:127.0.0.1:4713";
fastcgi_pass unix:/var/run/fcgiwrap/fcgiwrap.sock;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/bleeps/bloops.cgi;
}
- restart
nginx
sudo service nginx restart
CGI file
- Create the file
/var/www/bleeps/bloops.cgiwith:
#!/bin/sh
#
# bleeps!
# bleeps!
# bleeps!
# bleeps!
# bleeeeeeeeeps!
echo "content-type: text/html"
echo
case ${QUERY_STRING} in
"bleep1")
paplay bleep1.ogg 1>&- 2>&- &
;;
"bleep2")
paplay bleep2.ogg 1>&- 2>&- &
;;
"bleep3")
paplay bleep3.ogg 1>&- 2>&- &
;;
"bleep4")
paplay bleep4.ogg 1>&- 2>&- &
;;
"bleep5")
paplay bleep5.ogg 1>&- 2>&- &
;;
esac
cat << EOF
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bleeeeeeeeeeeps</title>
<style>
body {background-color: #BBB; margin: 0;}
.centre {flex-direction: column; justify-content: center; align-items: center; display: flex; height: 100vh; font-size: 7vh; line-height: 0.2;}
a {text-decoration: none;}
a:visited, a, a:hover {color: #000;)
</style>
</head>
<body>
<div class="centre">
<p><a href="?bleep1">◧</a></p>
<p><a href="?bleep2">◢</a></p>
<p><a href="?bleep3">◯</a></p>
<p><a href="?bleep4">◈</a></p>
<p><a href="?bleep5">◪</a></p>
</div>
</body>
</html>
EOF
- make the file executable
sudo chmod +x bloops.cgi
- copy a bunch of
oggaudio files in the/var/www/bleeps/folder. Name thembleep1.oggtobleep5.ogg
party time
Point any browser from any device on the same WLAN to the URL http://IP-OF-PHONE/bleeps
