Skip to content

Instantly share code, notes, and snippets.

#!/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 / 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
@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 / list_watched_movies.sh
Created April 12, 2020 10:25
List parent dirs of watched movies
/bin/sh
curl --silent --user ${USER}:${PASS} --data-binary '{ "jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"filter": {"field": "playcount", "operator": "greaterthan", "value": "0" }, "properties": [ "file" ] }, "id":"libMovies" }' --header 'content-type: application/json;' http://${IP_ADDR}:8080/jsonrpc | jq '.result | .movies | .[] | ."file"' | tr -d \" | awk -F/ '{print $6}'
@PieGuy314
PieGuy314 / chromebook.txt
Last active April 6, 2020 11:15
Minimal Gnome desktop on a Chromebook - Non-automatically added packages
adduser/stable,now 3.118 all [installed]
apt-listchanges/stable,now 3.19 all [installed]
apt-utils/stable,now 1.8.2 amd64 [installed]
apt/stable,now 1.8.2 amd64 [installed]
avahi-daemon/stable,now 0.7-4+b1 amd64 [installed]
base-files/stable,now 10.3+deb10u3 amd64 [installed]
base-passwd/stable,now 3.5.46 amd64 [installed]
bash-completion/stable,now 1:2.8-6 all [installed]
bash/stable,now 5.0-4 amd64 [installed]
bc/stable,now 1.07.1-2+b1 amd64 [installed]
#!/bin/sh
watch -n 1 'vcgencmd measure_clock arm && vcgencmd measure_temp'