Skip to content

Instantly share code, notes, and snippets.

View ScottJWalter's full-sized avatar
🔮
Particle. Wave. It's all data.

Scott Walter ScottJWalter

🔮
Particle. Wave. It's all data.
View GitHub Profile
#!/data/data/com.termux/files/usr/bin/bash
if [ -z "$1" ]
then
echo "No input file specified"
exit 1
fi
echo -ne "\n Checking if Termux has storage permission..."
rm -r ~/storage &>/dev/null
@ScottJWalter
ScottJWalter / hackeyMotionWaitVibrate.sh
Created January 18, 2025 17:15 — forked from cgarz/hackeyMotionWaitVibrate.sh
A hacky Termux bash script that uses the accelerometer to make an alarm that fires when the phone changes orientation.
#!/data/data/com.termux/files/usr/bin/bash
echo "getting wake lock state"
termux-notification-list | jq -r '.[] | select(.id == 1337).content' | grep -qF 'wake lock held' && locked="true" || locked="false"
if [ "$locked" = "false" ]; then
echo "wake lock not set, setting for duration of script"
termux-wake-lock
else
echo "wake lock set, Will not alter wake lock state."
fi
@ScottJWalter
ScottJWalter / venv_on_cd.sh
Last active January 17, 2025 16:59
Activate/deactivate venv as you move around the directory tree
#!/bin/sh
# add to .bashrc/.zshrc/... to wrap the cd command with a venv check
# NOTE: This assumes '.venv' is the virtual environment directory
#
function cd() {
builtin cd "$@"
if [[ -z "$VIRTUAL_ENV" ]] ; then
## If env folder is found then activate the vitualenv
@ScottJWalter
ScottJWalter / obsidian-pagebreaks.css
Created December 25, 2024 01:01 — forked from liamcain/obsidian-pagebreaks.css
Obsidian Pagebreaks
/**
Create pagebreaks in exported Obsidian PDFs.
Example:
# Heading 1
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type
@ScottJWalter
ScottJWalter / obsidian-debug-mobile.js
Created December 22, 2024 22:10 — forked from liamcain/obsidian-debug-mobile.js
Save console messages to logfile for mobile debugging
declare module "obsidian" {
interface App {
isMobile: boolean;
}
}
// Call this method inside your plugin's `onLoad` function
function monkeyPatchConsole(plugin: Plugin) {
if (!plugin.app.isMobile) {
return;
@ScottJWalter
ScottJWalter / WSL2GUIWSLg-XWayland-en.md
Created December 21, 2024 15:44 — forked from tdcosta100/WSL2GUIWSLg-XWayland-en.md
A tutorial to use GUI in WSL2/WSLg replacing original Xorg by Xwayland, allowing WSL to work like native Linux, including login screen

Full desktop shell in WSL2 using WSLg (XWayland)

Note

If you want to use Wayland in WSLg in a simpler setup, you can try the WSLg (Wayland) tutorial.

In this tutorial, we will setup GUI in WSL2. No additional software outside WSL (like VcXsrv or GWSL) is required. You will find this tutorial very similar to the one that replaces Xorg with Xvnc. Indeed, it's pretty much the same tutorial, with some few changes.

The key component we need to install is the desktop metapackage you want (GNOME, KDE, Xfce, Budgie, etc), and after that, replace the default Xorg by a script that calls Xwayland instead.

For this setup, I will use Ubuntu 24.04, and install GNOME Desktop. Unfortunately older versions of Ubuntu lack some fundamental things, so we cannot reproduce it in older versions (at least not fully). Since the key components aren't bound to Ubuntu or GNOME, you can use your favorite distro and GUI. Check the [Sample screenshot

@ScottJWalter
ScottJWalter / recent_requests.adb.sh
Last active December 20, 2024 21:49
Use ADB to get recent vibration requests
#!/bin/sh
# Run from an ADB debugging connection
#
# Reference:
# https://android.stackexchange.com/questions/215638/how-to-determine-which-app-is-causing-vibration
package_name=$1 # VIBRATE
for pkg in $(pm list packages | sed 's/package://')
do
@ScottJWalter
ScottJWalter / multipass-launcher.sh
Last active December 18, 2024 15:11
Generate a temporary cloud-init.yml file that is fed directly to multipass to launch a VM
#!/bin/sh
# WIP experiment
VM_NAME="$1"
$SSH_PUBLIC_KEY="Your Public SSH Key"
# The following method for handling temp files is adapted from
#
# https://unix.stackexchange.com/a/181938/458942
#
@ScottJWalter
ScottJWalter / inotify-watcher.sh
Last active December 21, 2024 15:04
Bash wrapper for inotify
#!/bin/sh
#
# inotify-watcher.sh -- Monitor a folder for file changes
#
# This is a wrapper around inotify, intended to make it easier to quickly
# spin up directory watchers. To activate watching for a particular event,
# comment and fill out the appropriate `inotify_XXXX` function.
#
inotify_close_write() {
# File closed after writing ("saved") and ready to be processed.
@ScottJWalter
ScottJWalter / inotifyexec.py
Created December 17, 2024 19:33 — forked from wernight/inotifyexec.py
inotifywait helper that executes a command on file change (for Linux, put it in ~/bin/)
#!/usr/bin/env python
"""Use inotify to watch a directory and execute a command on file change.
Watch for any file change below current directory (using inotify via pyinotify)
and execute the given command on file change.
Just using inotify-tools `while inotifywait -r -e close_write .; do something; done`
has many issues which are fixed by this tools:
* If your editor creates a backup before writing the file, it'll trigger multiple times.
* If your directory structure is deep, it'll have to reinitialize inotify after each change.