Skip to content

Instantly share code, notes, and snippets.

@haarp
haarp / toggle-touchpad.sh
Created March 8, 2024 10:16
toggle-touchpad
#!/bin/bash
# Toggle libinput touchpad state with each execution
touchpad=$(xinput list --name-only | grep -i touchpad)
props=$(xinput list-props "$touchpad")
enabled=$(awk '/Device Enabled \(...\)/{print $4}' <<< "$props")
tapping=$(awk '/libinput Tapping Enabled \(...\)/{print $5}' <<< "$props")
if [[ $enabled -eq 1 ]]; then
if [[ $tapping -eq 1 ]]; then
@haarp
haarp / zfs-znapshot
Created December 2, 2023 13:05
zfs-snapshot
#!/bin/bash
# Keep a number of snapshots
# adapted from my `backup-zfs`
PREFIX="daily"
KEEP=31 # days
SOURCE="data3"
# non-recursive:
EXCLUDES=("$SOURCE/Temp" "$SOURCE/Temp/playground" "$SOURCE/tmp")
@haarp
haarp / backup-zfs
Last active August 10, 2024 14:48
backup-zfs
#!/bin/bash
# ZFS-send backups v1.9.0 :D
#
# $1: target device (e.g. `/dev/sdg`) - if omitted, uses udev's $DEVNAME env var instead
# $2: optional - if existing, assume we're called by udev -> obey inhibit, log to /tmp/backup-zfs_*.log instead of stdout
# create /tmp/backup-zfs.inhibit to disable automatic udev backups
# needs udev rule like:
# `ACTION=="add", KERNEL=="sd*[!0-9]", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", RUN+="/usr/bin/setsid --fork /usr/local/bin/backup-zfs $env{DEVNAME} udev"`
#
# status beep HP led Fit-statUSB LED
#!/bin/bash
# Alternatives: https://github.com/ajslater/picopt
# https://github.com/thebeansgroup/smush.py
# TODO: implement max file size
# TODO: support gz archives with zopfli
set -u
if [[ $1 == "-h" || $1 == "--help" ]]; then
echo "Recursively and losslessly optimize images and ZIP archives. Usage: $(basename "$0") [dir] [dir]..."
#!/usr/bin/env python3
# Interact with BMBF's config
# FIXME: Album covers go missing?!
# Useful to start/kill BMBF without putting on the headset:
## adb shell am start com.weloveoculus.BMBF/.MainActivity
## adb shell am force-stop com.weloveoculus.BMBF
import sys
@haarp
haarp / BackupPC_deleteFile.pl
Last active September 5, 2020 21:05
BackupPC_deleteFile.pl
#!/usr/bin/perl
#============================================================= -*-perl-*-
#
# BackupPC_deleteFile.pl: Delete one or more files/directories from
# a range of hosts, backups, and shares
#
# DESCRIPTION
# See below for detailed description of what it does and how it works
#
# AUTHOR
@haarp
haarp / stream_gcode.py
Last active June 5, 2019 21:26
stream_gcode.py
see https://github.com/haarp/gcode-streamer