Skip to content

Instantly share code, notes, and snippets.

View lachiefish's full-sized avatar

Lachie lachiefish

View GitHub Profile
#!/usr/bin/env bash
# Check if user is NOT root
if [ "$id -u" = 0 ]; then
echo "Please DO NOT run this script as root"
sleep 3
exit 1
fi
# Base devel
Invoke-Expression (&starship init powershell)
###########
# MODULES #
###########
# PSReadLine
Import-Module PSReadLine
# Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
# Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
# Set-PSReadLineKeyHandler -Key Tab -Function Complete
@lachiefish
lachiefish / charge-threshold.sh
Last active October 16, 2024 19:48
Read and set battery charge thresholds on Linux (BAT0) - Run as root or with sudo - NOTE: Your battery may not be BAT0, run 'ls /sys/class/power_supply/' before this script to make sure.
#!/bin/bash
# Get current charge start threshold (in percent)
charge_start=$(cat /sys/class/power_supply/BAT0/charge_start_threshold)
echo "Current charge start threshold: $charge_start%"
# Get current charge end threshold (in percent)
charge_end=$(cat /sys/class/power_supply/BAT0/charge_end_threshold)
echo "Current charge end threshold: $charge_end%"
@lachiefish
lachiefish / json-to-gpx.py
Last active December 21, 2022 21:58
Converts a Google Timeline export JSON file into a GPX file to be used with other applications. The JSON file is in the same directory as the python script and is named timeline.json. Try blocks are because Google has used different time formats over the years.
import json
import datetime
# Open the JSON file
with open('timeline.json') as f:
data = json.load(f)
# Open a new GPX file for writing
with open('timeline.gpx', 'w') as gpx_file:
# Write the GPX file header