Skip to content

Instantly share code, notes, and snippets.

@WinkelCode
WinkelCode / Windows Setup Excerpt.md
Last active March 29, 2024 10:21
Excerpt from my Windows installation doc

Windows Installation

Creating Partitions (gdisk)

  • (Setup-dependent) Run blkdiscard or nvme format -s [1/2] -r (followed by blkdiscard) for the disk.
  • EFI:
    • Size: 100MiB
    • Type: EF00 (EFI System Partition) (Type may be optional depending on modern UEFI firmware)
  • MSR (Microsoft Reserved):
    • Size: 16MiB
    • Type: 0C01 (Microsoft Reserved Partition)
    • Always discard/zero the MSR after creation.
@WinkelCode
WinkelCode / tplinkcfgutil.sh
Last active December 23, 2023 00:35
A shell utility to de-/encode (de-/encrypt) a back up of the configuration file for certain TP-Link devices.
#!/usr/bin/env bash
set -e
file=$2
if [ ! -f "$file" ]; then
echo "File '$file' not found"
exit 1
fi
secret="2EB38F7EC41D4B8E1422805BCD5F740BC3B95BE163E39D67579EB344427F7836"
@WinkelCode
WinkelCode / cfgdumpparse.py
Created June 28, 2023 23:55
Python script to parse dumped config of Realtek NVMe Enclosures into usable config file
# Usage ./python3 cfgdumpparse.py mydumpedconfig.txt
# Warning: This is not a "end user" tool.
# Warning: Verify output by hand, it may include unwanted values.
# Warning: This tool may produce an incorrect config that can brick your device.
import re
import sys
try:
file = sys.argv[1]
with open(file, 'r') as cfg_file:
@WinkelCode
WinkelCode / user-battery-notify.service
Created May 2, 2023 13:53
Put in `~/.config/systemd/user/user-battery-notify.service`, enable with `systemctl --user enable --now user-battery-notify.service`. Change variables as required for your system.
[Unit]
Description=Battery Level Notifier
[Service]
Environment=BATT_PATH=/sys/class/power_supply/BAT1/capacity
Environment=MIN_BATT_PCT=35
Environment=BATT_REFRESH_SECS=5
ExecStart=bash -c 'set -e; snooze=false; while true; do [ "$(cat "${BATT_PATH}")" -le "${MIN_BATT_PCT}" ] && [ "$snooze" != "true" ] && { notify-send --urgency=critical "Battery is at or below ${MIN_BATT_PCT}%"; snooze=true; }; [ "$(cat "${BATT_PATH}")" -gt "${MIN_BATT_PCT}" ] && [ "$snooze" == "true" ] && snooze=false; sleep "${BATT_REFRESH_SECS}"; done'
Restart=always
@WinkelCode
WinkelCode / bookmarklet.js
Last active April 23, 2023 21:49
YouTube Ultrawide Fullscreen Bookmarklet
// Bookmarklet will fullscreen the video and fill the screen
// Might not work on Chromium derivatives, probably same issue: https://github.com/dvlden/ultrawideo/issues/94
// One line
javascript:(function(){var e=document.querySelector(".ytp-fullscreen-button");if(e){e.click();setTimeout(function(){var e=document.querySelector("video");if(e){e.style.width="100vw",e.style.height="100vh",e.style.left="0px",e.style.top="0px"}},250)}})();
//Pretty + Comments
javascript:(function(){
// Find the fullscreen button element
var fullscreenButton = document.querySelector(".ytp-fullscreen-button");
#!/usr/bin/env bash
if [ "$EUID" != '0' ]; then
echo "This script must be run as root"
exit 1
fi
# Or just run the parts below in the terminal as root!
mkdir -p '/var/lib/sd-battmgr/'
echo "Downloading script"
@WinkelCode
WinkelCode / battery-notify4silverblue.sh
Last active May 2, 2023 09:17
Unofficial and WIP, for this program: https://github.com/the-weird-aquarian/Battery-Notifier (License: unlicense.org)
#!/usr/bin/env bash
set -e
# --- Preamble ---
# username will be pulled from arguments
program_name="battery-notify"
sourceloc_script="./$program_name.sh"
@WinkelCode
WinkelCode / wggenconf.sh
Last active May 2, 2023 09:17
WireGuard Config Generator
#!/usr/bin/env bash
wgcmd="wg"
if command -v qrencode >/dev/null 2>&1; then
generate_qr="true"
else
generate_qr="false"
fi
echo "WireGuard configuration file generator"
echo "======================================"
@WinkelCode
WinkelCode / install_portmaster_to_var.sh
Last active April 12, 2024 14:01
Work in progress
#!/usr/bin/env bash
set -e # Exit on error
if [ "$EUID" -ne 0 ]; then
echo "To ensure correct permissions, this script must be run as root."
exit 1
fi
install_location="/var/lib/safing-portmaster" # Must not include trailing slash
@WinkelCode
WinkelCode / mtp_driver_man.ps1
Last active May 2, 2023 09:18
Messing around with Windows drivers can break stuff, use at your own risk. Script requres elevated permissions. You will need PS execution policy "RemoteSigned" (or any that allows running local scripts) and unblock script via file options (or paste it into an empty text file).
# Script to automatically remove and install "appleprecisiontrackpadbluetooth.inf" and "appleprecisiontrackpadusb.inf".
# Script needs to be in an extracted "AppleBcUpdate" folder.
function remove_driver {
$driver_orignames = @("appleprecisiontrackpadbluetooth.inf", "appleprecisiontrackpadusb.inf")
# Get matching installed drivers with pnputil and include previous line (the published name)
$drivers = pnputil /enum-drivers | Select-String -Pattern $driver_orignames -Context 1,0
if ($drivers.Count -gt 2) {
Write-Host "Error: More than 2 drivers found."