diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2022-04-17 10:46:59 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2022-04-17 10:46:59 -0500 |
commit | 35a2dd3734f1d31060fe28837cf0e1d947c8d6f4 (patch) | |
tree | 5fcb17f0849b520417ac0f29b94879f3e359ef43 /.old | |
parent | 3d3d79a57fb6d0a5728e0070475f05d1699f0818 (diff) | |
download | scripts-35a2dd3734f1d31060fe28837cf0e1d947c8d6f4.tar.xz scripts-35a2dd3734f1d31060fe28837cf0e1d947c8d6f4.zip |
reorganize all scripts
Diffstat (limited to '.old')
-rwxr-xr-x | .old/bsdtpscroll | 4 | ||||
-rwxr-xr-x | .old/delsimpic | 39 | ||||
-rwxr-xr-x | .old/ffconcat | 12 | ||||
-rwxr-xr-x | .old/hwtexedit | 49 | ||||
-rwxr-xr-x | .old/lipsum | 87 | ||||
-rwxr-xr-x | .old/lipsum.~1~ | 90 | ||||
-rwxr-xr-x | .old/lipsumsh | 72 | ||||
-rwxr-xr-x | .old/memuse | 33 | ||||
-rwxr-xr-x | .old/mnt | 11 | ||||
-rwxr-xr-x | .old/netstat | 45 | ||||
-rwxr-xr-x | .old/sb-internet | 24 | ||||
-rwxr-xr-x | .old/settitle | 4 | ||||
-rwxr-xr-x | .old/setup | 76 | ||||
-rwxr-xr-x | .old/setwindowtitle | 10 | ||||
-rwxr-xr-x | .old/shblr | 14 | ||||
-rwxr-xr-x | .old/sinkold | 48 | ||||
-rwxr-xr-x | .old/speedtest | 8 | ||||
-rwxr-xr-x | .old/speedtest-cli | 8 | ||||
-rwxr-xr-x | .old/testtimmywm | 5 | ||||
-rwxr-xr-x | .old/transtape | 11 | ||||
-rwxr-xr-x | .old/umnt | 8 | ||||
-rwxr-xr-x | .old/virt | 31 | ||||
-rwxr-xr-x | .old/webcamdesktopffplay | 2 | ||||
-rwxr-xr-x | .old/win10 | 4 | ||||
-rwxr-xr-x | .old/ytdl-dlplst | 5 |
25 files changed, 700 insertions, 0 deletions
diff --git a/.old/bsdtpscroll b/.old/bsdtpscroll new file mode 100755 index 0000000..0f2cd20 --- /dev/null +++ b/.old/bsdtpscroll @@ -0,0 +1,4 @@ +#!/bin/sh +xinput set-prop "/dev/wsmouse" "WS Pointer Wheel Emulation" 1 +xinput set-prop "/dev/wsmouse" "WS Pointer Wheel Emulation Button" 2 +xinput set-prop "/dev/wsmouse" "WS Pointer Wheel Emulation Axes" 6 7 4 5 diff --git a/.old/delsimpic b/.old/delsimpic new file mode 100755 index 0000000..83c3d1a --- /dev/null +++ b/.old/delsimpic @@ -0,0 +1,39 @@ +#!/usr/bin/awk -f +function convtobytes(num) { + if (match(num, " K")) + mul = 1000 + else if (match(num, " M")) + mul = 1000 * 1000 + else if (match(num, " G")) + mul = 1000 * 1000 * 1000 + else + mul = 1 + return int(num * mul) +} + +BEGIN { + cmd = "czkawka_cli image -d $PWD" + FS = " - " + largestsize = 0 + imc = 0 + k = 0 + while (cmd | getline) { + print $0 + if (!match($0, "^/")) { + delete images + largestsize = 0 + imc = 0 + k++ + break + } + images[$imc] = $0 + if (size = convtobytes($3) > largestsize) { + largestsize = size + keep[$k] = $1 + } + imc++ + } + for (image in keep) { + print $image + } +} diff --git a/.old/ffconcat b/.old/ffconcat new file mode 100755 index 0000000..06eb066 --- /dev/null +++ b/.old/ffconcat @@ -0,0 +1,12 @@ +#!/bin/sh +ffconcat="$(ls | sed "s/^/file '/; s/$/'/")" +echo "$ffconcat" > ffconcat + +ffmpeg \ + -f concat \ + -safe 0 \ + -i ffconcat \ + -c copy \ + out.mkv + +rm ffconcat diff --git a/.old/hwtexedit b/.old/hwtexedit new file mode 100755 index 0000000..262d10b --- /dev/null +++ b/.old/hwtexedit @@ -0,0 +1,49 @@ +#!/bin/sh +dir=~/docs/school + +files="$(find $dir -name \*.tex -printf "%T@ %p\n" | sort -nr | cut -d' ' -f 2-)" + +echo "$files" | awk ' +function printcol(c1, c2, c3) { printf "%-12s %-32s %s\n", c1, c2, c3 } +BEGIN { + printcol(" class:", "containing dir:", "file:") + fn = 1 +} +{ + tf = c = cf = $0 + sub(/.*\//, "", tf) + sub("'$dir'/", "", c) + sub(/\/.*/, "", c) + sub("'$dir'/"c"/", "", cf) + sub("/"tf, "", cf) + printcol(fn": "c, cf, tf) + fn++ +} +' +read -p "Choose file number: " filenum +file="$(echo "$files" | head -$filenum | tail -1)" +dir="$(echo "$file" | sed 's/\(\/.*\)\/.*/\1/')" + +cd "$dir" + +st -e $EDITOR "$file" & +echo "$file" | entr pdflatex -output-directory "$dir" "$file" || echo "entr or LaTeX is not installed!" & +zathura "$(echo "$file" | sed 's/.tex$/.pdf/')" & + +#listfiles() { +# pids=$(xdotool search --class "Vim") +# for pid in $pids; do +# names="$(xdotool getwindowname $pid | grep '\.tex')\n$names" +# #$openfiles="$(echo "$name" | cut -d' ' -f1)\n$openfiles" +# #$openfilepaths="$(echo "$name" | awk -F'[()]' '{ print $2 }')\n$openfiles" +# done +# #file="$(echo $openfiles | grep "^$1")" +# [ -z "$file" ] \ +# && interactiveopt "$(echo $openfiles | sort -bu | tail +2)" "Which file to autocompile? " 1 \ +# && file="$opt" +#} +# +#[ -e "$1" ] && file="$1" || listfiles +# +#echo "$file" | entr pdflatex "$file" || echo "entr or LaTeX is not installed!" + diff --git a/.old/lipsum b/.old/lipsum new file mode 100755 index 0000000..7ae9b7e --- /dev/null +++ b/.old/lipsum @@ -0,0 +1,87 @@ +#!/bin/awk -f + +function printusage() { + print "Usage: lipsum [# of] [w/words|s/sentences|p/paragraphs] [1/t/true|0/f/false output 'lorem ipsum' in first entry] [min words] [max words]\n" + exit 1 +} + +function capitalize() { + sub(/./, toupper(substr($0, 0, 1))) +} + +function randrange(min, max) { + return int((rand() * (max - min)) + min) +} + +function isint(arg) { + return arg ~ /^[0-9]+$/ +} + +function genwords(words, cmd) { + if (words > 0 && cmd | getline) { + capitalize(); print + for (i = 1; cmd | getline && i < words; i++) + print " "$0 + print "\n" + } +} + +function gensentences(sentences, delim, cmd, min, max) { + for (; sentences > 0 && cmd | getline; sentences--) { + capitalize(); print + words = randrange(min, max) # Isn't possible to initialize or increment multiple variables in awk for loops + for (i = 1; cmd | getline && i < words; i++) + print (rand() < 0.10 ? ", " : " ")$0 + print delim + } +} + +function genparagraphs(paragraphs, cmd, min, max) { + for (; paragraphs > 0; paragraphs--) { + print "\t" + gensentences(randrange(6, 10), ". ", cmd, min, max) + print "\n" + } +} + +BEGIN { + dictionary = "/home/timmy/.local/share/lorem-ipsum-dictionary" # List of lorem ipsum words separated by newlines + cmd = "< "dictionary" shuf -r -n" # Command to generate random permutations of words from dictionary separated by newlines + echolorem = "echo -n 'lorem\nipsum\ndolor\nsit\namet\n'" + + ORS = "" + srand() + + # Parse Arguments + !isint(ARGV[1]) && ARGV[1] && printusage() + numof = ARGC > 1 ? ARGV[1] : 5 + mode = ARGC > 2 ? ARGV[2] : "p" + litext = 1 + if (ARGV[3]) + switch (ARGV[3]) { + case /^1$|^t$|^true$/: litext = 1; break + case /^0$|^f$|^false$/: litext = 0; break + default: printusage() + } + litext && cmd = echolorem "&&" cmd + min = isint(ARGV[4]) ? ARGV[4] : 5 + max = isint(ARGV[5]) ? ARGV[5] : 12 + + switch (mode) { + case /^w$|^words$/: + cmd = cmd numof + genwords(numof, cmd) + break + case /^s$|^sentences$/: + cmd = cmd (max * numof) + gensentences(numof, ".\n", cmd, min, max) + break + case /^p$|^paragraphs$/: + cmd = cmd (max * 10 * numof) + genparagraphs(numof, cmd, min, max) + break + default: + printusage() + } + close(cmd) +} diff --git a/.old/lipsum.~1~ b/.old/lipsum.~1~ new file mode 100755 index 0000000..efa71b5 --- /dev/null +++ b/.old/lipsum.~1~ @@ -0,0 +1,90 @@ +#!/usr/bin/awk -f + +function printusage() { + print "Usage: lipsum [# of] [w/words|s/sentences|p/paragraphs] [1/t/true|0/f/false output 'lorem ipsum' in first entry] [min words] [max words]\n" + exit 1 +} + +function capitalize(word) { + sub(/./, toupper(substr(word, 0, 1)), word) + print word +} + +function isint(arg) { + return arg ~ /^[0-9]+$/ +} + +function randrange(min, max) { + return int((rand() * (max - min)) + min) +} + +function genword() { + wc++ # There's gotta be a more efficient way of doing this + return (wc > 5 || !litextout) ? word[randrange(0, dictlen)] : litext[wc - 1] +} + +function genwords(words) { + if (words > 0) { + capitalize(genword()) + for (i = 1; i < words; i++) + print " " genword() + print "\n" + } +} + +function gensentences(sentences, delim, min, max) { + for (; sentences > 0; sentences--) { + capitalize(genword()) + words = randrange(min, max) # Isn't possible to initialize or increment multiple variables in awk for loops + for (i = 1; i < words; i++) + print (rand() < 0.10 ? ", " : " ") genword() + print delim + } +} + +function genparagraphs(paragraphs, min, max) { + for (; paragraphs > 0; paragraphs--) { + print "\t" + gensentences(randrange(6, 10), ". ", min, max) + print "\n" + } +} + +BEGIN { + dictionary = "/home/timmy/.local/share/lorem-ipsum-dictionary" # List of lorem ipsum words separated by newlines + litext[0] = "lorem"; litext[1] = "ipsum"; litext[2] = "dolor"; litext[3] = "sit"; litext[4] = "amet" + + ORS = "" + srand() + + for (dictlen = 0; getline < dictionary; dictlen++) + word[dictlen] = $0 + + # Parse Arguments + !isint(ARGV[1]) && ARGV[1] && printusage() + numof = ARGC > 1 ? ARGV[1] : 5 + mode = ARGC > 2 ? ARGV[2] : "p" + litextout = 1 + if (ARGV[3]) + switch (ARGV[3]) { + case /^1$|^t$|^true$/: litextout = 1; break + case /^0$|^f$|^false$/: litextout = 0; break + default: printusage() + } + min = isint(ARGV[4]) ? ARGV[4] : 5 + max = isint(ARGV[5]) ? ARGV[5] : 12 + + switch (mode) { + case /^w$|^words$/: + genwords(numof) + break + case /^s$|^sentences$/: + gensentences(numof, ".\n", min, max) + break + case /^p$|^paragraphs$/: + genparagraphs(numof, min, max) + break + default: + printusage() + } +} diff --git a/.old/lipsumsh b/.old/lipsumsh new file mode 100755 index 0000000..d229877 --- /dev/null +++ b/.old/lipsumsh @@ -0,0 +1,72 @@ +#!/bin/sh + +dictionary=/home/timmy/.local/share/lorem-ipsum-dictionary + +shuf -r -n$1 $dictionary | awk -f- hi hello yolo <<'AWKSCRIPT' +BEGIN { for(i = 1; i < ARGC; i++) print ARGV[i] } +AWKSCRIPT +echo +#shuf -r -n$1 $dictionary | tr '\n' ' ' + + + + + +exit + +#genipsums() { shuf -r -n$1 $dictionary | tr '\n' ' ' | sed 's/.$//'; } +genipsums() { shuf -r -n$1 $dictionary; } +gensentence() { genipsums $1 | sed ':a;N;$!ba; s/\n/ /g; s/.$//; s/\(^\| \)\([a-z]\)/\1\u\2/'; } + +genparagraph() { + sentences=`shuf -n1 -i 4-12` + echo -n '\t' + + for i in `seq $sentences`; do + words=`shuf -n1 -i 1-10` + [ "$loremipsumtext" = '1' ] && echo -n "Lorem ipsum " && genipsums $words && loremipsumtext=0 || gensentence $words + [ "$words" -le 4 ] || [ `shuf -n1 -i 0-2` = 1 ] && echo -n ', ' && genipsums `shuf -n1 -i 3-10` # make more complex + echo -n '. ' + done + echo +} + +loremipsumtext=1 + +genparagraph + + + +#exit +# +#dictionary=/home/timmy/.local/share/lorem-ipsum-dictionary +# +#ipsums=$1 +# +##set -- `tr '\n' ' ' < $dictionary` +#set -- `cat $dictionary` +# +##rand=`od -An -N$ipsums /dev/urandom` +# +#shuf -r -n$ipsums -i 1-$# | while read line; do +# eval echo -n \${$line} +# echo -n ' ' +#done +# +#echo +# +#exit +# +# +# +#words=`wc -w $dictionary | cut -d' ' -f1` +# +#echo -n '\tLorem ipsum ' +# +#shuf -r -n$1 -i 1-$words | while read line; do +# #cut -z -d' ' -f$line $dictionary && echo -n ' ' +# head -n$line $dictionary | tail -n1 | tr -d '\n' +# num=`shuf -n1 -i 1-100` +# ([ "$num" -lt 10 ] && echo -n '. ') || ([ "$num" -gt 90 ] && echo -n ', ') || ([ "$num" = '50' ] && echo -n '.\n\t') || echo -n ' ' +#done +#echo diff --git a/.old/memuse b/.old/memuse new file mode 100755 index 0000000..eb9ffde --- /dev/null +++ b/.old/memuse @@ -0,0 +1,33 @@ +#!/usr/bin/awk -f +function getvar(label) { + while (getline < meminfo && $1 != label":"); + return $2 +} + +BEGIN { + meminfo="/proc/meminfo" + + # Make sure these are in order of the output of /proc/meminfo + memtotal = getvar("MemTotal") + memfree = getvar("MemFree") + buffers = getvar("Buffers") + cached = getvar("Cached") + shmem = getvar("Shmem") + sreclaimable = getvar("SReclaimable") + + # Htop calculations + totalused = memtotal - memfree + totalcached = cached + sreclaimable - shmem + noncachenonbuf = totalused - (buffers + totalcached) + + # Print % of memory used + print int((noncachenonbuf * 100) / memtotal)"%" +} + +#BEGIN { +# cmd="free -b" +# cmd | getline +# cmd | getline +# print int($3*100/$2)"%" +#} +##awk '{ if(!total){ total = $2 } else if(!free){ free = $2 } else{ exit } } END{ print int(((total-free)*100)/total)"%" }' /proc/meminfo diff --git a/.old/mnt b/.old/mnt new file mode 100755 index 0000000..7547912 --- /dev/null +++ b/.old/mnt @@ -0,0 +1,11 @@ +#!/bin/sh +# '/part\s*$\|rom\s*$/!d; s/\s*[^[:space:]]*\s*$/\)/; s/\s/ \(/' # More correct in my opinion, but slower +if partition=`lsblk -npro "name,size,type,mountpoint" | sed '/part $\|rom $/!d; s/ [a-z]* $/\)/; s/ / \(/' | dmenu -p "Choose drive to mount: " | cut -d' ' -f1` \ +&& [ -n "$partition" ] \ +&& mountpoint=`ls -d /media/mnt/slot*/ | dmenu -p "Choose mountpoint: "` \ +&& [ -n "$mountpoint" ] +then + doas mount "$partition" "$mountpoint"; user="$(whoami)"; ug="$(groups | cut -d' ' -f1)"; doas chown "$user":"$ug" "$mountpoint" \ + && notify-send --urgency low "Device Successfully Mounted" "Successfully Mounted partition \"$partition\" to mountpoint \"$mountpoint\"" \ + || notify-send --urgency low "Error Mounting Device" "Could not mount partition \"$partition\" to mountpoint \"$mountpoint\"" +fi diff --git a/.old/netstat b/.old/netstat new file mode 100755 index 0000000..e7b23c3 --- /dev/null +++ b/.old/netstat @@ -0,0 +1,45 @@ +#!/usr/bin/awk -f + +BEGIN { +wifidev=ENVIRON["WIFIDEV"] +ethedev=ENVIRON["ETHEDEV"] +getline state < ("/sys/class/net/"ethedev"/operstate") +switch (state) { + case "up": + print "" + break + case "down": + getline state < ("/sys/class/net/"wifidev"/operstate") + switch (state) { + case "up": + # make this nicer, obviously + getline < "/proc/net/wireless" + getline < "/proc/net/wireless" + getline < "/proc/net/wireless" + sigstrength=int($3 * 100 / 70) + if (sigstrength > 70) { + print " " sigstrength "%" + } + else if (sigstrength > 40) { + print " " sigstrength "%" + } + else if (sigstrength > 10) { + print " " sigstrength "%" + } + else { + print " " sigstrength "%" + } + break + case "down": + print "" + break + default: + print "Device "wifidev" not found..." + break + } + break + default: + print "Device "ethedev" not found..." + break +} +} diff --git a/.old/sb-internet b/.old/sb-internet new file mode 100755 index 0000000..ee1a160 --- /dev/null +++ b/.old/sb-internet @@ -0,0 +1,24 @@ +#!/bin/sh + +# Show wifi 📶 and percent strength or 📡 if none. +# Show 🌐 if connected to ethernet or ❎ if none. +# Show 🔒 if a vpn connection is active + +case $BLOCK_BUTTON in + 1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;; + 3) notify-send "🌐 Internet module" "\- Click to connect +📡: no wifi connection +📶: wifi connection with quality +❎: no ethernet +🌐: ethernet working +🔒: vpn is active +" ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +case "$(cat /sys/class/net/w*/operstate 2>/dev/null)" in + down) wifiicon="📡 " ;; + up) wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)" ;; +esac + +printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2>/dev/null)" diff --git a/.old/settitle b/.old/settitle new file mode 100755 index 0000000..7cdd7d1 --- /dev/null +++ b/.old/settitle @@ -0,0 +1,4 @@ +#!/bin/sh +xdotool set_window --class "$2" $(xdotool search --pid $1) # command chaining doesnt work for some reason +#xdotool getactivewindow set_window --class "$1" +#[ -z "$2" ] && echo -n "\e]0;$2\a" diff --git a/.old/setup b/.old/setup new file mode 100755 index 0000000..eaeec39 --- /dev/null +++ b/.old/setup @@ -0,0 +1,76 @@ +#!/bin/sh + +#interactiveopt() { +# # Usage: interactiveopt "options" "prompt" +# echo "$1" | nl -s': ' 1>&2 +# # Parse user input +# read -p "$2" choices 1>&2 \ +# && choices="$(echo $choices | cut -d' ' -f1-)" +# for choice in $choices; do +# case "$choice" in +# [0-9]*) opt="$opt $(echo "$1" | head -"$(echo $choice | tr -cd '[:digit:]')" | tail -1)";; +# *) echo "Invalid option \"$opt\"" 1>&2 ;; +# esac +# done +# echo "$opt" +#} + +# Open as root in pcmanfm +pcmanfmconf() { + pcmanfmroot=~/.local/share/file-manager/actions + mkdir -p $pcmanfmroot + echo " [Desktop Entry] +Type=Action +Tooltip=Open Folder As Root +Name=Open Folder As Root +Profiles=profile-zero; +Icon=gtk-dialog-authentication + +[X-Action-Profile profile-zero] +MimeTypes=inode/directory; +Exec=/home/timmy/.local/bin/x11/xsudo /usr/bin/pcmanfm %u +Name=Default profile" > $pcmanfmroot/root.desktop +} + +minticons() { + gitdir="/tmp/mint-y-icons" + iconsdir="$gitdir/usr/share/icons" + git clone https://github.com/linuxmint/mint-y-icons.git "$gitdir" + #iconsets="$(interactiveopt "$(ls "$iconsdir")" "Choose icon sets (if using dark theme, COPY THE NON-DARK THEME TOO): ")" + #iconsets="$iconset Mint-Y" + #for iconset in $iconsets; do + # mv "$iconsdir/$iconset" $iconsdestdir + #done + mv $iconsdir/* $iconsdestdir + gtk-update-icon-cache +} + +mintthemes() { + gitdir="/tmp/mint-themes" + themesdir="$gitdir/usr/share/themes" + #iconsdir="$gitdir/usr/share/icons" + git clone https://github.com/linuxmint/mint-themes.git "$gitdir" + curdir="$(pwd)" + cd $gitdir + make + #themes="$(interactiveopt "$(ls "$themesdir")" "Choose themes: ")" + ##iconset="$iconset Mint-Y" + #for theme in $themes; do + # mv "$themesdir/$theme" $themesdestdir + #done + #iconsets="$(interactiveopt "$(ls "$iconsdir")" "Choose icon set (if using dark theme, COPY THE NON-DARK THEME TOO): ")" + #iconset="$iconset Mint-Y" + #for iconset in $iconsets; do + # mv "$iconsdir/$iconset" $iconsdestdir + #done + #gtk-update-icon-cache + mv $themesdir/* $themesdestdir +} + +iconsdestdir=/usr/share/icons +themesdestdir=/usr/share/themes +mkdir -p $iconsdestdir $themesdestdir + +pcmanfmconf +minticons +mintthemes diff --git a/.old/setwindowtitle b/.old/setwindowtitle new file mode 100755 index 0000000..a2b9218 --- /dev/null +++ b/.old/setwindowtitle @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +#windowname="$(dmenu -p 'Enter New Window Name. Then, Select the Window to Change' <&-)" +#xdotool selectwindow set_window --class "$windowname" +##if [ -z "$1" ]; +##then +##else +## xdotool getactivewindow set_window --class "$1" +##fi +#if [ -z "$2" ]; then echo -en "\e]0;$2\a"; fi +#xsetroot -name "" diff --git a/.old/shblr b/.old/shblr new file mode 100755 index 0000000..4570afc --- /dev/null +++ b/.old/shblr @@ -0,0 +1,14 @@ +#!/bin/sh +energy_now_total=0 +energy_full_total=0 +for bat in /sys/class/power_supply/BAT?*; do + echo "`basename $bat`: \n" \ + "├─Capacity:\t\t`cat $bat/capacity`% \n" \ + "├─Energy Now:\t\t`cat $bat/energy_now` \n" \ + "├─Energy Full:\t\t`cat $bat/energy_full` \n" \ + "├─Energy Full Design:\t`cat $bat/energy_full_design` \n" \ + "└─Health:\t\t$(( (`cat $bat/energy_full` * 100) / `cat $bat/energy_full_design` ))% " + energy_now_total=$(( energy_now_total + `cat $bat/energy_now` )) + energy_full_total=$(( energy_full_total + `cat $bat/energy_full` )) +done +echo "\nTotal Capacity:\t$(( (energy_now_total * 100) / energy_full_total ))%" diff --git a/.old/sinkold b/.old/sinkold new file mode 100755 index 0000000..3022963 --- /dev/null +++ b/.old/sinkold @@ -0,0 +1,48 @@ +#!/bin/sh + +printusage() { echo "Usage: $0 [<repos> ...] (repos: all,`echo $repos | tr ' ' ','`) [up|down]" && exit; } + +repos="docs patches" + +oper=`echo $@ | sed 's/.* //'` # Get last argument +([ -z $2 ] || ([ "$oper" != "up" ] && [ "$oper" != "down" ])) && printusage + +# rync options +#fix this too +ropts="--archive --partial --progress --recursive --update --verbose" # Equivalent to: -aPrvu --delete +rdest="tjkrsync@tjkeller.xyz:" + +# Colors +BOLD="\033[1m" +NORM="\033[0m" +CYN="\033[0;36m" +RED="\033[0;31m" +GRN="\033[0;32m" + +printsyncmsg() { echo -n "$CYN[Syncing $SYNCNAME...]$NORM\n"; } +printsuccess() { echo -n "$BOLD$GRN[Successfully synced $SYNCNAME]\n"; } +printerror() { echo -n "$BOLD$RED[An error occured while syncing $SYNCNAME]\n"; } + +sync() { + [ $oper = "up" ] && SYNCNAME="$1$2 to $rdest$2" || SYNCNAME="$rdest$2 to $1$2" + printsyncmsg + (if [ $oper = "up" ]; then rsync $ropts $1$2 $rdest; else rsync $ropts --delete $rdest$2 $1; fi) \ + && printsuccess || printerror +} + +# arg1 = options + containing directory path, arg2 = file/directory name +syncdocs() { destdir="" && sync "/home/timmy/docs/" "school"; } +#syncsites() { destdir="" && sync "--exclude=pass /home/timmy/.local/src/" "sites"; } # Excludes password file +syncpatches() { destdir="" && sync "--exclude=.git /home/timmy/.local/src/programs/" "patches"; } # Excludes git files + +for arg in "$@"; do + case $arg in + all) $0 $repos $oper ;; + up|down) oper=$arg ;; + *) # Would like to use something like $repos) here but cant + for repo in $repos; do + [ "$arg" = "$repo" ] && sync$arg && break + done || printusage + ;; + esac +done diff --git a/.old/speedtest b/.old/speedtest new file mode 100755 index 0000000..913f9ef --- /dev/null +++ b/.old/speedtest @@ -0,0 +1,8 @@ +#!/usr/bin/python3.9 +# -*- coding: utf-8 -*- +import re +import sys +from speedtest import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.old/speedtest-cli b/.old/speedtest-cli new file mode 100755 index 0000000..913f9ef --- /dev/null +++ b/.old/speedtest-cli @@ -0,0 +1,8 @@ +#!/usr/bin/python3.9 +# -*- coding: utf-8 -*- +import re +import sys +from speedtest import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/.old/testtimmywm b/.old/testtimmywm new file mode 100755 index 0000000..33cda37 --- /dev/null +++ b/.old/testtimmywm @@ -0,0 +1,5 @@ +#!/bin/sh +Xephyr -br -ac -reset -screen 2160x1440 :1 & +sleep 1 +export DISPLAY=:1 +timmywm & diff --git a/.old/transtape b/.old/transtape new file mode 100755 index 0000000..a0eaaee --- /dev/null +++ b/.old/transtape @@ -0,0 +1,11 @@ +#!/bin/sh +if [ -z "$1" ]; then + exit +fi + +ffmpeg -hwaccel auto -vaapi_device /dev/dri/renderD128 \ +-i "$1" \ +-c:v hevc_vaapi \ +-vf "yadif,format=nv12,hwupload" \ +-metadata "title"="$1" \ +"$1as.mkv" diff --git a/.old/umnt b/.old/umnt new file mode 100755 index 0000000..8191047 --- /dev/null +++ b/.old/umnt @@ -0,0 +1,8 @@ +#!/bin/sh +exclude='\/efi$|\/boot$|\/home$|tbhdd$|\/$' +if mountedpartition=`lsblk --noheadings --paths --raw | awk "/part .+/ && !/$exclude/ "'{ print $1, "(on", $7 ")" }' | dmenu -p "Unmount Device... "` +then + doas umount -A "`echo $mountedpartition | sed 's/ .*//'`" \ + && notify-send --urgency low "Device Successfully Unmounted" "Partition \"$mountedpartition\" successfully unmounted" --time 120000 \ + || notify-send --urgency low "Error Unmounting Device" "Could not unmount partition \"$mountedpartition\"" +fi diff --git a/.old/virt b/.old/virt new file mode 100755 index 0000000..6d9f252 --- /dev/null +++ b/.old/virt @@ -0,0 +1,31 @@ +#!/bin/sh +virtdir=~/.local/share/virt + +halfram() { awk '/^MemTotal/ { printf "%dM\n", $2/2/1024 }' /proc/meminfo; } # Needs to be either in M or G according to man page +halfthreads() { echo $(( $(nproc) / 2 )); } +startvm() { + qemu-system-x86_64 \ + -enable-kvm \ + -cpu host \ + -m $(halfram) \ + -smp $(halfthreads) \ + -net nic \ + -display sdl,gl=on \ + -audiodev pa,id=pa1,server=/run/user/1000/pulse/native \ + -soundhw all \ + -boot menu=on \ + -drive file="$virtdir/$1.img" \ + -drive file=~/docs/oss/openbsd7.0.img \ +; } + #-vga none \ + #-nographic \ + +vms="$(ls $virtdir)" + +[ -n "$1" ] && vm="$1" || vm=$(echo "$vms" | sed 's/\.img//' | dmenu -p "Choose Virtual Machine Image or Enter Name for New Virtual Machine") + +if echo "$vms" | grep "^$vm.img$" >/dev/null; then + startvm "$vm" +else + qemu-img create -f qcow2 "$virtdir/$vm.img" $(echo -n "4G\n8G\n16G\n32G" | dmenu -p "Choose Size of Virtual Machine \"$vm\"") +fi diff --git a/.old/webcamdesktopffplay b/.old/webcamdesktopffplay new file mode 100755 index 0000000..c56d879 --- /dev/null +++ b/.old/webcamdesktopffplay @@ -0,0 +1,2 @@ +#!/bin/sh +ffplay -f v4l2 -input_format mjpeg -video_size 1920x1080 -framerate 30 -i /dev/video0 diff --git a/.old/win10 b/.old/win10 new file mode 100755 index 0000000..130df5c --- /dev/null +++ b/.old/win10 @@ -0,0 +1,4 @@ +#!/bin/sh +doas chown -R timmy:timmy /dev/shm +virsh start win10-clone +looking-glass-client -F diff --git a/.old/ytdl-dlplst b/.old/ytdl-dlplst new file mode 100755 index 0000000..f7b4a47 --- /dev/null +++ b/.old/ytdl-dlplst @@ -0,0 +1,5 @@ +#!/bin/sh +echo "Getting Video ID's..." +for id in $(youtube-dl --get-id "$1"); do + youtube-dl --newline "https://youtu.be/$id" & +done |