Skip to content

Instantly share code, notes, and snippets.

@jigpu
jigpu / encode.sh
Last active October 10, 2021 19:42
Convert audiobook / podcast to Opus
#!/bin/sh
# Run as e.g. `parallel ./encode.sh -- *.mp3` to mass-transcode.
# Adjust the parameters below to change the output of the encoding.
# Suggestions: 1.5x, 16kbps, mono; 1.5x, 24kbps stereo
SPEED=1.5
BITRATE=16
MONO=1
@jigpu
jigpu / teradici-cas-tablet-monitor.sh
Last active August 9, 2021 17:07
Enable the "Tablet Monitor" option of Teradici's "Cloud Access Software" on a specific display
#!/bin/sh
# teradici-cas-tablet-monitor.sh
#
# Enable the "Tablet Monitor" option of Teradici's "Cloud Access Software"
# on a specific display. This script uses xdotool to make the appropriate
# mouse movements and clicks. It must be installed on the client machine
# (not the remote server) and is intended to be run in response to a
# keyboard shortcut. A similar shortcut should also be set up on the remote
# server to set the tablet mapping as well (e.g. via the `MapToOutput` option
@jigpu
jigpu / btreset.sh
Created December 19, 2020 20:11
Raspberry Pi Bluetooth Watchdog / Reset
#!/bin/sh
# Force a reset of the Bluetooth interface if it freezes up.
#
# https://github.com/raspberrypi/linux/issues/2832#issuecomment-597001597
if test $(id -u) -ne 0; then
echo "This script must be run as root."
exit 1
fi
@jigpu
jigpu / copy-acpi-tables.sh
Last active November 20, 2020 21:01
Creates a copy of the ACPI tables in a tarball for sharing
#!/usr/bin/env bash
# Creates a copy of the ACPI tables in a tarball for sharing. An
# `acpi-tables.tar.gz` file will be created in the current directory.
#
# Simply pointing `tar` at sysfs sadly does not work, due to the
# files changing apparent size. It seems the preferred way to
# copy the files is with `cat`, so we define our own `catcopy`
# function that can be called for each file. Once everything
# has been copied out of sysfs we can safely tar up the the
@jigpu
jigpu / gist:62def2209f71f320d48fa8685e2df66f
Created June 19, 2020 17:44
Session keep-awake magic
# Quick hack that can be added to .bashrc to create a `caffiene` command that will
# prevent your system from going to sleep. Note that you need sudo access since the
# systemd-inhibit command will not allow normal users to block sleep/shutdown.
#
# Run it right after connecting over SSH to ensure the system doesn't sleep while
# you are connected. A more clever solution would be to set up someting like
# socket activation of SSH which masks the sleep target prior to start and unmaks
# afterward (assuming nothing else is still wanting to mask it -- that's the tricky
# part!).
#
@jigpu
jigpu / xorg-hotplug.sh
Created June 1, 2020 20:54
Wacom Autoconfig on Hotplug
#!/bin/bash
# Usage:
# xorg-hotplug.sh [device]
#
# device - Name of an Xorg device to configure.
#
# xorg-hotplug should be added to your window manager's list of startup programs. If
# run with no arguments, it will sit in the background monitoring for hotplug events
# by monitoring the Xorg log file. When a new device is connected, it will automatically
@jigpu
jigpu / boinc-idle-gnome
Created April 14, 2020 03:51
BOINC idle monitor for GNOME
#!/usr/bin/env bash
function usage() {
cat <<EOF >&2
BOINC idle monitor for GNOME
Monitor the idle time published by GNOME over the session dbus and control
BOINC's run mode in response. This tool does not have global visibility into
idle status across sessions and so may occasionally not update the run mode
@jigpu
jigpu / cauliflower-alfredo.md
Last active April 11, 2020 21:52
Cauliflower Alfredo Sauce

Cauliflower-Based Alfredo Sauce

Produces a thick, creamy, garlicy, alfredo-like sauce for pasta and other dishes. Can be made dairy-free or vegan by simply substituting in oil and vegtable broth.

Makes appx. 5 cups of sauce

Ingredients

#!/usr/bin/python3
"""Get scalar firmware version through FTDI. Must be run as root.
Usage:
ftdi-scalar-version.py
Requirements:
Python 3 (sudo yum install python3)
pyftdi (sudo pip3 install pyftdi)
@jigpu
jigpu / state.py
Created March 5, 2020 23:26
Print out changes to evdev multitouch state
#!/usr/bin/env python3
import sys
import libevdev
AXES = {
'ABS_MT_TRACKING_ID': libevdev.EV_ABS.ABS_MT_TRACKING_ID,
'ABS_MT_POSITION_X': libevdev.EV_ABS.ABS_MT_POSITION_X,
'ABS_MT_POSITION_Y': libevdev.EV_ABS.ABS_MT_POSITION_Y
}