Skip to content

Instantly share code, notes, and snippets.

@PieGuy314
PieGuy314 / bt-addr.sh
Last active December 2, 2023 12:10
Update/Create ALSA config file with updated BD_ADDR
#!/bin/sh
#
# Update alsa config file with new BD_ADDR
# Backup original
# Create a new config file if one doesn't exist
usage() {
echo "Usage: $0 xx:xx:xx:xx:xx:xx"
}
#!/bin/sh
# Run as a background task
while true # Keep an infinite loop to reconnect when connection lost/broker unavailable
do
mosquitto_sub -h localhost -t mqtthost/message/\# -F "%t %p" | while read -r payload
do
# Here is the callback to execute whenever you receive a message:
topic=$(echo "$payload" | cut -d ' ' -f 1)
@PieGuy314
PieGuy314 / bind-address.sh
Created November 9, 2017 10:13
Transmission: bind-address.sh - Listen for IPv4 BitTorrent connections on a specific address.
#!/bin/sh
#
# Called by /etc/openvpn/route-up.sh
#
TMPFILE=$(mktemp)
awk -F\" -v IP_ADDR="$ifconfig_local" '{if ($2 == "bind-address-ipv4") print $1 "\"" $2 "\"" $3 "\"" IP_ADDR "\"" $5; else print $0}' < /etc/transmission-daemon/settings.json > $TMPFILE
cp -pf /etc/transmission-daemon/settings.json /etc/transmission-daemon/settings.json.old
@PieGuy314
PieGuy314 / route-up.sh
Last active April 22, 2022 09:20
OpenVPN: route-up.sh
#!/bin/sh
systemctl start transmission-daemon
@PieGuy314
PieGuy314 / gist:136da8c74c422bdc6cb2664b3953ccc0
Last active March 10, 2021 09:26
shairport-sync install & update
#
# Install
#
sudo apt update && sudo apt upgrade
sudo apt-get install autoconf automake avahi-daemon build-essential git libasound2-dev libavahi-client-dev libconfig-dev libdaemon-dev libpopt-dev libssl-dev libtool xmltoman libsoxr-dev
# libmosquitto-dev
git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
@PieGuy314
PieGuy314 / gist:cc438b816073e5589686ac43a3a088d0
Created December 24, 2020 22:34
PiOs wifi power save on/off
rpi ~$ sudo systemctl --full --force edit wifi_powersave@.service
In the empty editor insert these statements, save them and quit the editor:
[Unit]
Description=Set WiFi power save %i
After=sys-subsystem-net-devices-wlan0.device
[Service]
Type=oneshot
RemainAfterExit=yes
EXTRA_CFLAGS += -Wno-bool-operation
EXTRA_CFLAGS += -fno-stack-protector
ARCH=arm64
import paho.mqtt.client as mqtt
MQTT_SERVER = "localhost"
MQTT_PATH = "Image"
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
@PieGuy314
PieGuy314 / gist:3e0015319b5b99f8e26449c066871e2e
Last active August 22, 2020 15:12
Alpine setup on a Raspberry Pi Zero/W using TTL/UART cable
# Format SD card
# Mount SD card
cd /media/user/ALPINE
tar zxvf ~/Downloads/alpine-rpi-3.12.0-armhf.tar.gz .
# Append console=ttyAMA0,115200 to 'cmdline.txt'
# Append enable_uart=1 to 'config.txt'
# Connect TTL/UART cable and power up
sudo screen /dev/ttyUSB0 115200
# Login as root on pi
alpine-setup
/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0
/dev/usbdisk /media/usb vfat noauto,ro 0 0
/dev/mmcblk0p1 /media/mmcblk0p1 vfat rw,relatime,fmask=0022,dmask=0022,errors=remount-ro 0 0
/media/mmcblk0p1/persist-vol0.img /media/persist-vol0 ext4 rw,relatime,errors=remount-ro 0 0
overlay /home overlay lowerdir=/home,upperdir=/media/persist-vol0/home,workdir=/media/persist-vol0/.home 0 0