• Sep 30, 2021 •LeifMessinger
0 likes • 8 views
touch /tmp/login1.txt /tmp/login2.txt while [ true ] do who | gawk '{ print $1 }' > /tmp/login2.txt comm -13 /tmp/login1.txt /tmp/login2.txt #Just a bit easier to read #diff /tmp/login1.txt /tmp/login2.txt cat /tmp/login2.txt > /tmp/login1.txt sleep 1 done
• Mar 7, 2021 •LeifMessinger
0 likes • 10 views
#!/bin/bash #makefileMaker.sh by Leif Messinger #Needs getDependencies.sh CC="gcc" #I have no idea why it's called CXX when it's a c++ compiler #I know that cpp is c pre processor, but still, why X? CXX="g++" CXXFLAGS="-std=c++17 -O2" #CFLAGS="-std=c17" LIBRARIES="$@" #Vulkan Flags for me #LIBRARIES="-lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi" function compileAllFiles(){ #output: bruh.o yeet.o # CXX $CXXFLAGS bruh.o yeet.o -o output $LIBRARIES echo -n "output:" if compgen -G "*.cpp" &> /dev/null; then for f in *.cpp; do echo -n " ${f%.cpp}.o" done fi if compgen -G "*.c" &> /dev/null; then for f in *.c; do echo -n " ${f%.c}.o" done fi echo "" if compgen -G "*.cpp" &> /dev/null; then echo -e -n "\t$CXX $CXXFLAGS " else echo -e -n "\t$CC $CFLAGS " fi if compgen -G "*.cpp" &> /dev/null; then for f in *.cpp; do echo -n " ${f%.cpp}.o" done fi if compgen -G "*.c" &> /dev/null; then for f in *.c; do echo -n " ${f%.c}.o" done fi echo " -o output $LIBRARIES" echo "" } function compileAllObjectFiles(){ #bruh.o: bruh.cpp yeet.h # CXX $CXXFLAGS -c bruh.cpp $LIBRARIES if compgen -G "*.cpp" &> /dev/null; then for f in *.cpp; do echo -n "${f%.cpp}.o: $f" getDependencies.sh < $f echo "" echo -e "\t$CXX $CXXFLAGS -c $f" echo "" done fi #yeet.o: yeet.c # CC $CFLAGS -c yeet.c $LIBRARIES if compgen -G "*.c" &> /dev/null; then for f in *.c; do echo -n "${f%.c}.o: $f" getDependencies.sh < $f echo "" echo -e "\t$CC $CFLAGS -c $f" echo "" done fi } compileAllFiles compileAllObjectFiles #does not work on windows echo "clean:" echo -e "\trm -f -v *.o output" echo "" echo "run:" echo -e "\t./output" echo "" echo "debug:" if compgen -G "*.cpp" &> /dev/null; then echo -e -n "\t$CXX $CXXFLAGS -g " else echo -e -n "\t$CC $CFLAGS -g " fi if compgen -G "*.cpp" &> /dev/null; then for f in *.cpp; do echo -n " ${f}" done fi if compgen -G "*.c" &> /dev/null; then for f in *.c; do echo -n " ${f}" done fi echo " $LIBRARIES -o output" echo ""
• Nov 17, 2021 •LeifMessinger
0 likes • 6 views
#!/bin/bash #Takes command line arguments and pulls the header files. #Good for checking if the function you want is in the header or not. #cppToStdout.sh "time.h" while [ "$1" != "" ]; do echo "#include<$1>" | g++ -x c++ -E - shift done
• 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 }
• Mar 10, 2023 •Helper
1 like • 6 views
#!/bin/bash for branch in $(git branch | cut -c 3-); do read -p "Delete local branch $branch? (y/n) " -n 1 -r echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then git branch -D $branch fi done
• Mar 21, 2021 •LeifMessinger
0 likes • 0 views
#pinger.sh by Leif Messinger #./pinger.sh [ADDRESS] to search #./pinger.sh [ADDRESS] & to search in the background #https://serverfault.com/a/42382 ping_cancelled=false # Keep track of whether the loop was cancelled, or succeeded until ping -c1 "$1" >/dev/null 2>&1; do :; done & # The "&" backgrounds it trap "kill $!; ping_cancelled=true" SIGINT wait $! # Wait for the loop to exit, one way or another trap - SIGINT # Remove the trap, now we're done with it if [ "$ping_cancelled" == true ] #https://stackoverflow.com/a/21210966/10141528 then printf "The pinger for $1 just closed bro.\n" else printf "$1 IS UP BROOO\a\n" fi