Skip to content

Instantly share code, notes, and snippets.

View mwvent's full-sized avatar

Matthew Watts mwvent

View GitHub Profile
@mwvent
mwvent / vglrun_auto
Created May 10, 2018 13:13
Automatically find GLX capable display and run vglrun with it. Useful for multiseat with one powerful GPU. Assumes displays are accessible by all users
#!/bin/bash
# This script is intended to be used as a replacement for vglrun -d ? program - the display is auto selected
# it can also be included in a game launcher script to automatically get virtualgl if needed and fix LD_PRELOAD order issues with Steam games
# if you have a preffered GPU put name here as it appears on glxinfo renderer string - a partial string is fine if it matches more than one
# GPU the result will be randomly selected
PREFFERED_CARD="GTX 650 Ti"
# ------------------------------------------------------------------------------------------------------------------------------------
# This portion of the script checks libdlfaker.so and libvglfaker.so are at the END of the LD_PRELOAD string
@mwvent
mwvent / listdisplays
Created May 10, 2018 13:42
List display number, glx capable and gpu name - I use for scripts that need to automatically locate a GPU display number when number is unkown
#!/bin/bash
# Get a list of sessions from loginctl - filtered to ones with a DISPLAY set then filter DISPLAY number
DISPLAYS=$(loginctl list-sessions | grep -v "SESSION" | grep -v "listed" | tr -s " " | sed '/^$/d' | cut -d " " -f2 | xargs loginctl show-session | grep "Display=" | cut -d "=" -f 2)
# Iterate found list of DISPLAYS - attempt to determine which are GLX capable, add them to the GLX_DISPLAYS list when found
for CUR_DISPLAY in $DISPLAYS; do
if [ "$( DISPLAY=$CUR_DISPLAY glxinfo 2>&1 | grep "Error:" )" = "" ]; then
HAS_GLX="HASGLX"
else
HAS_GLX="NOGLX"
@mwvent
mwvent / bluetoothbulb_connector.service
Created January 30, 2019 14:49
Bluetooth Speaker Auto connect service - for running in BG when autologging in on Kodi, replace USERGID and USERNAME with autologin user
#/etc/systemd/system/bluetoothbulb_connector.service
[Unit]
Description=BluetoothBulbConnector
After=network.target
[Path]
PathExists=/run/user/1000
[Install]
WantedBy=multi-user.target
@mwvent
mwvent / RCSwitch.cpp
Created June 19, 2019 00:06
My mod of RCSwitch.cpp from the RCSwitch Arduino Lib to spit out my doorbell and other random stuff as protocol 7
/*
RCSwitch - Arduino libary for remote control outlet switches
Copyright (c) 2011 Suat Özgür. All right reserved.
Contributors:
- Andre Koehler / info(at)tomate-online(dot)de
- Gordeev Andrey Vladimirovich / gordeev(at)openpyro(dot)com
- Skineffect / http://forum.ardumote.com/viewtopic.php?f=2&t=46
- Dominik Fischer / dom_fischer(at)web(dot)de
- Frank Oltmanns / <first name>.<last name>(at)gmail(dot)com
@mwvent
mwvent / cam_alarmserver_zm_bridge.sh
Last active March 13, 2020 02:33
Receive motion events from Xiongmai/Netsurv web camera and pass to Zoneminders trigger port eliminating need for image analysis on ZM Server
#!/bin/bash
# Function to translate camera serial into zoneminder monitor id
function serialToID() {
MONITORID=0
if [ "$1" == '"383c49531157b1b1"' ]; then
MONITORID=9
fi
echo $MONITORID
}
# Netcat persistent listen
@mwvent
mwvent / README.txt
Last active September 23, 2021 15:57
Zoneminder Record High-res H264 streams 24/7 with low CPU Load
>>>>>>>>>>>>>>>>>>>>> BIG UPDATE <<<<<<<<<<<<<<<<<<<<<<<<<<<<
On zoneminder version 1.35.16 and later there is a DecodingEnabled setting for each monitor - this script is therefore of little use anymore
>>>>>>>>>>>>>>>>>>>>> ORIGINAL README <<<<<<<<<<<<<<<<<<<<<<<<<<<<
The original Zoneminder Forum thread about all this is here:
https://forums.zoneminder.com/viewtopic.php?f=9&t=27537&p=107235#p107235
@mwvent
mwvent / example hook script
Created February 20, 2020 17:26
LAN home events - sending and listenting for UDP broadcasts
# Example broadcast command triggered in my case by the RPi doorbell
echo "doorbell" | socat - UDP-DATAGRAM:255.255.255.255:12345,broadcast
@mwvent
mwvent / deps
Created April 10, 2020 21:31
Play Top Zoneminder Recordings as a loopback video device
future==0.18.2
mysql-connector==2.2.9
pkg-resources==0.0.0
@mwvent
mwvent / Google>Tasmota nodered function
Last active October 17, 2021 18:32
Tasmota Rules For Sonoff Mini Piggybacking a cheapie floodlight
codes = {
0xFF0000 : { "Event": "RED1", "IRSend": {"Protocol":"NEC","Bits":32,"Data":"0xF720DF","DataLSB":"0xEF04FB","Repeat":0} },
0x00FF00 : { "Event": "GRN1", "IRSend": {"Protocol":"NEC","Bits":32,"Data":"0xF7A05F","DataLSB":"0xEF05FA","Repeat":0} },
0x0000FF : { "Event": "BLU1", "IRSend": {"Protocol":"NEC","Bits":32,"Data":"0xF7609F","DataLSB":"0xEF06F9","Repeat":0} },
0xFFFFFF : { "Event": "WHT", "IRSend": {"Protocol":"NEC","Bits":32,"Data":"0xF7E01F","DataLSB":"0xEF07F8","Repeat":0} },
0xBFFF00 : { "Event": "GRN1", "IRSend": {"Protocol":"NEC","Bits":32,"Data":"0xF7A05F","DataLSB":"0xEF05FA","Repeat":0} },
0xFF9100 : { "Event": "ORG1", "IRSend": {"Protocol":"NEC","Bits":32,"Data":"0xF708F7","DataLSB":"0xEF10EF","Repeat":0} },
0xAD670A : { "Event": "ORG2", "IRSend": {"Protocol":"NEC","Bits":32,"Data":"0xF730CF","DataLSB":"0xEF0CF3","Repeat":0} },
0x88EBE4 : { "Event": "CYA1", "IRSend": {"Protocol":"NEC","Bits":32,"Data":"0xF7B04F","DataLSB":"0xEF0DF2","Repeat":0} },
0x
@mwvent
mwvent / Record images and data from IP Webcam app - make timelapse plot data
Last active October 11, 2021 16:58
Data collection scripts for ******'s homework - record images and sensor data from android phone running "ip webcam" and create timelapse and data spreadsheet where phone IP address is 192.168.1.25
#!/bin/bash
# Name this file cleanspreadsheet.sh
# run as ./cleanspreadsheet.sh > data2.csv
echo "Mins Elapsed,DateTime,Temp C,Pressure mbar,Humidty %,BAT"
START_TIME="2021-10-10 17:51:24"
START_TIME_UNIXTIME="$(date -d "${START_TIME}" +%s)"
tail -n +2 data.csv | awk -F',' '{printf "%s %s,%.2f,%.2f,%.2f,%s\n",$1,$2,$3,$4,$5,$6}' | while read LN; do
LINE_TIME="$(echo $LN | cut -d ',' -f 1)"
LINE_TIME_UNIXTIME="$(date -d "${LINE_TIME}" +%s)"