• Nov 18, 2022 •AustinLeath
0 likes • 1 view
echo -e ${PATH//:/\\n} | awk '{print length, $0}' | sort -n | cut -f2- -d' '
• May 20, 2024 •AustinLeath
0 likes • 13 views
#!/bin/sh BAT_LOW=15 BAT_CRITICAL=5 if [ "$1" = "--help" ] then printf " Usage: \tbattery_check.sh warning%% hibernate%% Description: \tA script for notifying the user via dunst and logging when \tthe battery is low and the system is going to hibernate. \tCan be supplied arguments for the battery low warning and \thibernation percentage thresholds as the first and second arguments. \t Default behavior is to warn at 15% and hibernate at 5%." exit fi if [[ -n "$1" && -n "$2" && $1 -gt $2 ]] then BAT_LOW=$1 BAT_CRITICAL=$2 fi acpi -b | awk -F'[,:%]' '{print $2, $3}' | { read -r status capacity echo Low threshold: $BAT_LOW, Hibernate threshold: $BAT_CRITICAL echo Status: $status, Capacity: $capacity if [ "$status" = Discharging -a "$capacity" -le $BAT_CRITICAL ]; then echo Battery critical threshold. dunstify -u critical "Critical battery threshold, hibernating..." logger "Critical battery threshold, hibernating..." sleep .5 systemctl hibernate exit fi if [ "$status" = Discharging -a "$capacity" -le $BAT_LOW ]; then echo Battery low threshold. dunstify -u critical 'Battery low! System will hibernate at 5%.' logger 'Battery low! System will hibernate at 5%.' sleep .5 light -S 15 exit fi }
• Oct 26, 2021 •LeifMessinger
0 likes • 3 views
#!/bin/bash #Leif Messinger lsm0147 #credit.sh FILES cred="Leif Messinger lsm0147" for bruh; do if [[ $bruh =~ \.cpp|\.c|\.java|\.js ]]; then comment="//$cred" else #Basically everything else gets a pound sign comment #Pound signs are standard across linux. bash, sed, gawk, python etc #Speaking of which, I need to escape it because of that. comment="\#$cred" fi if [ -s $bruh ]; then #If the file has a shebang if egrep -q '^#!/' $bruh; then sed -i "/^\#!\//a$comment" $bruh else sed -i "1i$comment" $bruh fi else echo "$comment" > $bruh fi done
# # Austin Leath # checks for /Desktop symlink. Creates the symlink if it doesnt already exist # #Fetch the target user if desired, otherwise use the currently logged in user. if [ "$4" != "" ]; then TARGET_USER=$4 else TARGET_USER=$3 fi if [ "$5" != "" ]; then DIRECTORY_NAME=$5 else TARGET_USER="$3 Desktop" fi # Functions CHECK_SYMLINK() { if test -f "/Desktop"; then echo "/Desktop exists" else echo "/Desktop does not exist" fi } CHECK_SYNTHETIC_CONF() { if test -f "/etc/synthetic.conf"; then echo "/etc/synthetic.conf exists" else echo "/etc/synthetic.conf does not exist" fi } CREATE_SYMLINK() { if [[ $(CHECK_SYNTHETIC_CONF) != "/etc/synthetic.conf exists" ]]; then echo "/etc/synthetic.conf does not exist. creating.." touch /etc/synthetic.conf chown -R root:wheel /etc/synthetic.conf fi if grep -q "$DIRECTORY_NAME" /etc/synthetic.conf; then echo "$DIRECTORY_NAME already exists" exit 1 else echo "$DIRECTORY_NAME\t/Users/$TARGET_USER/Desktop" >> /etc/synthetic.conf fi echo "/Desktop symbolic link created" } if [[ $(CHECK_SYMLINK) != "/Desktop exists" ]]; then CREATE_SYMLINK fi exit 0
• Feb 5, 2024 •LeifMessinger
0 likes • 11 views
#!/bin/bash # Recursively find all .svelte files in the current directory and its subdirectories find . -type f -name "*.svelte" -o -name "*.html" -o -name "*.htm" | while read file; do # Replace all h1 tags with the specified format sed -i 's/<h1>\(.*\)<\/h1>/<h1 id="\1">\1<\/h1>/g' "$file" # Replace all h2 tags with the specified format sed -i 's/<h2>\(.*\)<\/h2>/<h2 id="\1">\1<\/h2>/g' "$file" # Remove whitespace from the id attribute value for i in {0..10} ; do sed -i 's/\(id="[^"]*\)\W\([^"]*"\)/\1\2/g' "$file" done done
• Jul 29, 2024 •AustinLeath
0 likes • 7 views
for region in `aws ec2 describe-regions --output text | cut -f4` do echo -e "\nListing Instances in region:'$region'..." aws ec2 describe-instances --query 'Reservations[*].Instances[*].{Instance:InstanceId,Subnet:SubnetId}' --region $region done #This script is to be used with any AWS CLI configured environment, it will list any EC2 instances and their associated subnet network ID's in JSON format