diff options
author | Tim Keller <tjkeller.xyz> | 2024-11-17 23:34:54 -0600 |
---|---|---|
committer | Tim Keller <tjkeller.xyz> | 2024-11-17 23:34:54 -0600 |
commit | 09ada24d4ec23cf24ab136141b354953d1bbc2fa (patch) | |
tree | 2c41e87c71ad3f3cd67a8bea0c1413efbab4087d /.old | |
parent | 090a3a31683eb08b91351e4d1508a0a73a310a38 (diff) | |
download | scripts-09ada24d4ec23cf24ab136141b354953d1bbc2fa.tar.xz scripts-09ada24d4ec23cf24ab136141b354953d1bbc2fa.zip |
reorganize scripts
Diffstat (limited to '.old')
-rwxr-xr-x | .old/d8concat | 164 | ||||
-rwxr-xr-x | .old/d8integrity | 9 | ||||
-rwxr-xr-x | .old/dmenu_runapp | 4 | ||||
-rwxr-xr-x | .old/dmenunametag | 30 | ||||
-rwxr-xr-x | .old/dnfu | 10 | ||||
-rwxr-xr-x | .old/dockfanctl | 10 | ||||
-rw-r--r-- | .old/dvgrabscript | 1 | ||||
-rwxr-xr-x | .old/emu | 57 | ||||
-rwxr-xr-x | .old/enablecoredumps | 3 | ||||
-rwxr-xr-x | .old/music | 28 | ||||
-rwxr-xr-x | .old/rectape | 16 | ||||
-rwxr-xr-x | .old/rectapehevc | 15 | ||||
-rwxr-xr-x | .old/rectapevaapi | 13 | ||||
-rwxr-xr-x | .old/screenrec | 24 | ||||
-rwxr-xr-x | .old/shows | 26 | ||||
-rwxr-xr-x | .old/sinkswitch | 15 | ||||
-rwxr-xr-x | .old/sync/griff | 64 | ||||
-rwxr-xr-x | .old/sync/pull | 57 | ||||
-rwxr-xr-x | .old/sync/pushsite | 8 | ||||
-rwxr-xr-x | .old/sync/sink | 47 | ||||
-rwxr-xr-x | .old/vaapiencode | 9 | ||||
-rwxr-xr-x | .old/viewintensitypro | 7 | ||||
-rwxr-xr-x | .old/viewwebcam | 2 | ||||
-rwxr-xr-x | .old/volcon | 3 | ||||
-rwxr-xr-x | .old/volume | 27 | ||||
-rwxr-xr-x | .old/wgconnect | 40 |
26 files changed, 689 insertions, 0 deletions
diff --git a/.old/d8concat b/.old/d8concat new file mode 100755 index 0000000..bf8b608 --- /dev/null +++ b/.old/d8concat @@ -0,0 +1,164 @@ +#!/bin/sh + +[ -d "$1" ] || exit 1 # Exit with error if not pointing to a directory + +# Misc +duration() { ffprobe -i "$1" -show_entries format=duration -v quiet -of csv="p=0" | tr -d . ; } +timebase="1/1000000" # duration function gives microseconds + +safename() { echo "$1" | tr -d '<>:"/\|?*' ; } + +# Temp dirs +workdir="$(mktemp -d "${TMPDIR:-/tmp}/combinetapesworkdir.XXXXXX")" + +cleanup() { rm -rf "$workdir" ; } +trap cleanup EXIT INT HUP QUIT TERM ALRM USR1 + +# Loop vars +current_date=0 +duration_total=0 +chapter_start=0 +chapter_time=0 +last_chapter_concurrent=0 + +# TODO this relys on the for loop looping in order + +# Either can be ran on single dv containing directory, or many dv containing directories +for dir in "$1"/ "$1"/*/; do + dir="${dir%/}" # Remove trailing slash + title="" + + if [ "$dir" != "$1" ]; then + title="$(basename "$dir")" + fi + if echo "$dir" | grep '/\*' >/dev/null; then + break + fi + + for tape in "$dir"/*.dv; do + date="$(echo "$(basename "$tape")" | grep -o '[0-9]*\.[0-9]*\.[0-9]*' | tr '.' '-')" + time="$(echo "$(basename "$tape")" | grep -o '[0-9]*-[0-9]*-[0-9]*' | tr '-' ':')" + + if [ "$title$date" != "$current_date" ]; then + # Reset vars + current_date="$title$date" + duration_total=0 + chapter_start=0 + chapter_time=0 + last_chapter_concurrent=0 + + # Create dirs + date_dir="$workdir/$current_date" + mkdir -p "$date_dir" + + files="$date_dir/files" + chapters="$date_dir/chapters" + + # Init chapters file + printf ";FFMETADATA1\n\n" > "$chapters" + + # title file + if [ "$title" ]; then + echo "$title" > "$date_dir/title" + fi + fi + + # Concat files + echo "file '$(realpath "$tape" | sed "s/'/'\\\\''/g")'" >> "$files" + + # Chapter marker + tape_duration=$(duration "$tape" | grep -o "[1-9][0-9]*") + duration_total=$(( $duration_total + $tape_duration )) + + # Only insert chapter marker if recordings are not concurrent. dvgrab + # splits files into 1gb chunks, or 291557933 microseconds of raw dv footage + # (with digital 8) + if [ $last_chapter_concurrent = 0 ]; then + chapter_time=$time + fi + if [ $tape_duration = 291557933 ]; then + last_chapter_concurrent=1 + continue + else + last_chapter_concurrent=0 + fi + + echo "[CHAPTER]" >> "$chapters" + echo "TIMEBASE=$timebase" >> "$chapters" + echo "START=$chapter_start" >> "$chapters" + echo "END=$duration_total" >> "$chapters" + echo "title=Section starts at $chapter_time" >> "$chapters" + echo >> "$chapters" + + chapter_start=$duration_total + done +done + + +# ffmpeg combine +out_dir=export +default_title=Untitled +mkdir -p "$out_dir" + +for date_dir in "$workdir"/*; do + date="$(echo "$date_dir" | grep -o "[0-9][0-9][0-9][0-9]-[0-9]*-[0-9]*")" + origin_tape="$(basename "$1")" + + # Files + title="$date_dir/title" + files="$date_dir/files" + chapters="$date_dir/chapters" + + # Nicely title + if [ -e "$title" ]; then + # title file + output_title="$(cat "$title")" + #elif echo "$origin_tape" | grep "^[^0-9].*[0-9]*-[0-9]*-[0-9]*" >/dev/null; then + # # Beginning descriptor + # output_title="$(echo "$origin_tape" | sed 's/ [0-9#].*//')" + #elif echo "$origin_tape" | grep "$date [A-Z]" >/dev/null; then + # # Date range or list of dates with titles (Title must be capitalized, 'to' must be made lowercase + # output_title="$(echo "$origin_tape" | sed "s/.*$date //; s/ to [0-9].*//; s/;.*//")" + else + # default + output_title=$default_title + fi + + output_title="$(echo "$output_title" | sed 's/\s*#[0-9]*$//')" # Remove sequence numbers + + # File name + if [ "$output_title" = "$default_title" ]; then + output_name="$date" + else + output_name="$date $output_title" + fi + + if [ -e "$out_dir/$output_name.mp4" ]; then + output=$(ls "$out_dir" | grep "$output_name *[0-9]*.mp4" | while read -r file; do + file_tape="$(mediainfo "$out_dir/$file" | sed -n 's/Comment.* - Origin tape: //p')" + if [ "$origin_tape" = "$file_tape" ]; then + echo 0 + break + fi + done) + if [ "$output" = 0 ]; then + continue + fi + output_name="$output_name $(ls "$out_dir" | grep "$output_name *[0-9]*.mp4" | wc -l)" + fi + + # Convert + #-c copy \ + #-metadata "title=$output_title" \ # Dont set title since it will be stuck if file is renamed + ffmpeg -hide_banner -nostdin \ + -n \ + -f concat -safe 0 -i "$files" \ + -i "$chapters" -map_metadata 1 \ + -c:v libx264 -crf 22 -preset medium -tune grain \ + -vf yadif \ + -c:a aac -b:a 320k \ + -metadata "date=$date" \ + -metadata "comment=tapes.tjkeller.xyz - Origin tape: $origin_tape" \ + "$out_dir/$output_name.mp4" + #"$out_dir/$output_name.mkv" +done diff --git a/.old/d8integrity b/.old/d8integrity new file mode 100755 index 0000000..717032b --- /dev/null +++ b/.old/d8integrity @@ -0,0 +1,9 @@ +#!/bin/sh + +find . -type f -name "*.dv" | while read file; do + ffmpeg -v error -i "$file" 2>&1 | grep "Concealing bitstream errors" >/dev/null && echo "$file" +done + +find . -type f -name "*.dv" | while read file; do + ffmpeg -v error -i "$file" -f null - 2>&1 | grep "Concealing bitstream errors" >/dev/null && echo "$file" +done diff --git a/.old/dmenu_runapp b/.old/dmenu_runapp new file mode 100755 index 0000000..4d7a45e --- /dev/null +++ b/.old/dmenu_runapp @@ -0,0 +1,4 @@ +#!/bin/sh +apps="$(echo ${XDG_DATA_DIRS:-/usr/share}: | sed 's/:/\/applications\/*.desktop /g')" +name="$(grep -Rhm1 '^Name=' $apps 2>/dev/null | cut -d'=' -f2- | sort | uniq | dmenu "$@")" +[ -n "$name" ] && gtk-launch $(basename `grep -Rlm1 "^Name=$name$" $apps 2>/dev/null`) & diff --git a/.old/dmenunametag b/.old/dmenunametag new file mode 100755 index 0000000..0458c79 --- /dev/null +++ b/.old/dmenunametag @@ -0,0 +1,30 @@ +#!/bin/sh +numtags=9 +rcn="Remove Current Name" +defnames="$rcn\nCode\nCompile\nTest\nDebug\nEdit" +while !([ $tagnum -ge 1 2>/dev/null ] && [ $tagnum -le $numtags ]); do + tagnum=$(seq $numtags | dmenu -p "Choose tag: ") + [ "$tagnum" = "" ] && exit +done +name="$(echo -n "$defnames" | dmenu -p "Rename tag $tagnum to: ")" +[ "$name" = "$rcn" ] \ + && nametag $tagnum r \ + || nametag $tagnum n "$name" + +# Force bar to update by setting the root name to itself since there is currently a bug in the window manager +#xsetroot -name "$(xprop -root WM_NAME | sed -n 's/^WM_NAME(STRING) = \"\(.*\)\"/\1/p')" + +# Old mode +#while [ "$action" != "Rename" ] && [ "$action" != "Remove" ]; do +# action=$(echo -n "Rename\nRemove" | dmenu -p "Would you like to rename or remove this tag $tagnum's label? ") +# [ "$action" = "" ] && exit +#done +#case $action in +# Rename) +# name="$(echo -n "$defnames" | dmenu -p "Rename tag $tagnum to: ")" +# [ "$name" = "" ] && exit +# nametag $tagnum n "$name" +# ;; +# Remove) nametag $tagnum r ;; +# *) exit ;; +#esac diff --git a/.old/dnfu b/.old/dnfu new file mode 100755 index 0000000..9f6a9cb --- /dev/null +++ b/.old/dnfu @@ -0,0 +1,10 @@ +#!/bin/sh +sudo ln -sf /bin/bash /bin/sh + +sudo dnf update $@ + +sudo dnf remove $@ --oldinstallonly --setopt installonly_limit=2 kernel + +sudo dnf autoremove $@ + +sudo ln -sf /bin/dash /bin/sh diff --git a/.old/dockfanctl b/.old/dockfanctl new file mode 100755 index 0000000..f422b3e --- /dev/null +++ b/.old/dockfanctl @@ -0,0 +1,10 @@ +#!/bin/sh +hub=$(doas uhubctl | grep -B3 'Port 3: .* highspeed enable connect .* Lenovo USB2.0 Hub' | grep -o -m1 '[0-9][^ ]*' | head -n1) +! [ "$hub" ] && exit 1 + +echo $hub + +case $1 in + off) doas uhubctl -a off -p 4 -l $hub ;; + on) doas uhubctl -a on -p 4 -l $hub ;; +esac diff --git a/.old/dvgrabscript b/.old/dvgrabscript new file mode 100644 index 0000000..d82ba55 --- /dev/null +++ b/.old/dvgrabscript @@ -0,0 +1 @@ +sudo dvgrab -autosplit -rewind -timestamp -format raw -csize 100000000 diff --git a/.old/emu b/.old/emu new file mode 100755 index 0000000..87c0e2a --- /dev/null +++ b/.old/emu @@ -0,0 +1,57 @@ +#!/bin/sh +# This only works for collections with a common extension. You can rename all your roms to use the same extension and (in any decent emulator at least) they should work regardless of the actual header type +gamedir=${XDG_DATA_HOME:-$HOME/.local/share}/games +dmenuprompt="dmenu -l 25" +resolution() { cat /sys/class/drm/*/modes | head -1; } +case "$1" in + 2600) + #dmenucolors="-nb #111 -nf #e4963c -sb #6c3b17 -sf #fff -nhb #121212 -nhf #fc5231 -shb #804f2d -shf #fc5231" + dmenucolors="-nb #111 -nf #e4963c -sb #6c3b17 -sf #fff" + emulator="stella" + ext=bin + ;; + 3ds) + #dmenucolors="-nb #111 -nf #888 -sb #999 -sf #F00 -nhb #111 -nhf #fff -shb #999" + dmenucolors="-nb #111 -nf #888 -sb #999 -sf #F00" + emulator="citra" + ext=3ds + ;; + nes) + #dmenucolors="-nb #6d6a6d -nf #fff -sb #dfdcdd -sf #c1121c -nhb #222 -nhf #dc444d -shb #a29fa3 -shf #dc444d" + dmenucolors="-nb #6d6a6d -nf #fff -sb #dfdcdd -sf #c1121c" + emulator="fceux" + ext=nes + ;; + snes) + #dmenucolors="-nb #b2b4b2 -nf #000 -sb #514689 -sf #fff -nhb #707372 -nhf #fff -shb #a7a4e0 -shf #000" + dmenucolors="-nb #b2b4b2 -nf #000 -sb #514689 -sf #fff" + emulator="launch snes" + ext=sfc + ;; + n64) + #dmenucolors="-nb #223 -nf #fff -sb #069330 -sf #fff -nhb #c20d02 -nhf #ffc001 -shb #011da9 -shf #ffc001" + dmenucolors="-nb #223 -nf #fff -sb #069330 -sf #fff" + emulator="mupen64plus --fullscreen --gfx mupen64plus-video-glide64mk2 --resolution $(resolution)" + ext=z64 + ;; + gcn) + #dmenucolors="-nb #4d3b7c -nf #ddd -sb #000 -sf #fff -nhb #4d3b7c -nhf #eba982 -shb #000 -shf #eba982" + dmenucolors="-nb #4d3b7c -nf #ddd -sb #000 -sf #fff" + emulator="dolphin-emu -b" + ext=iso + ;; + nds) + #dmenucolors="-nb #ccc -nf #000 -sb #52398d -sf #fff -nhb #888 -nhf #fff -shb #52398d" + dmenucolors="-nb #ccc -nf #000 -sb #52398d -sf #fff" + emulator="desmume --3d-engine 2" + ext=nds + ;; + *) + console=`ls $gamedir | dmenu -l 25` && ($0 $console || $0) # Allows going back to select a different console + exit + ;; +esac + +gamedir="$gamedir/$1" && [ -e "$gamedir" ] \ + && selgame="`ls "$gamedir" | sed -n "s/\.$ext$//p" | $dmenuprompt $dmenucolors`.$ext" \ + && $emulator "$gamedir/$selgame" diff --git a/.old/enablecoredumps b/.old/enablecoredumps new file mode 100755 index 0000000..e435cc7 --- /dev/null +++ b/.old/enablecoredumps @@ -0,0 +1,3 @@ +#!/bin/sh +ulimit -c unlimited +sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t diff --git a/.old/music b/.old/music new file mode 100755 index 0000000..cb78257 --- /dev/null +++ b/.old/music @@ -0,0 +1,28 @@ +#!/bin/sh +albumsdir=/media/4tbhdd/Music +dmenucolors="-l 25" + +playsong() { + list="`find $albumsdir -type f -name '*mka' | sort | sed 's/.*\/\(.*\) - \(.*\)\/[0-9]*: \(.*\).mka$/\3\t\1\t\2/' | awk -F '\t' '{ printf "%-120s %-60s %s\n", $1, $2, $3 }'`" + selection="`echo "$list" | dmenu $dmenucolors -p 'Song:'`" + selection="`echo "$selection" | sed 's/\(.*\) *\(.*\) *\(.*\)/\2 - \3\/[0-9]*: \1-/'`" + echo "$selection" +} + +playalbum() { + list="`find $albumsdir -type d -mindepth 1 -maxdepth 1 | sort`" +} + +playartist() { + list="`find $albumsdir -type d -mindepth 1 -maxdepth 1 | sed 's/ - .*//' | sort | uniq`" + artist= + list="`find $albumsdir -type d -name "$artist*" | sort`" +} + +playshuffle() { + list="`find $albumsdir -type f -name "*mka" | sort -R`" +} + +playsong +#play="`echo "$list" | grep "$selection"`" +#echo "$play" diff --git a/.old/rectape b/.old/rectape new file mode 100755 index 0000000..238f5de --- /dev/null +++ b/.old/rectape @@ -0,0 +1,16 @@ +#!/bin/sh +if [ -z "$1" ]; then $0 untitled_$(ls | wc -l); exit; fi + +for mod in blackmagic blackmagic-io; do doas modprobe $mod; done +#doas rc-service DesktopVideoHelper start + +ffmpeg \ + -f decklink -format_code ntsc -i "Intensity Pro" \ + -c:v libx264 \ + -preset medium \ + -qmin 6 -qmax 18 -qdiff 4 \ + -vf yadif \ + -c:a aac -b:a 384k \ + -metadata "title"="$1" \ + -metadata "comment=tapes.tjkeller.xyz" \ + "$1.mkv" diff --git a/.old/rectapehevc b/.old/rectapehevc new file mode 100755 index 0000000..c44d6d9 --- /dev/null +++ b/.old/rectapehevc @@ -0,0 +1,15 @@ +#!/bin/sh +if [ -z "$1" ]; then $0 untitled_$(ls | wc -l); exit; fi + +for mod in blackmagic blackmagic-io; do doas modprobe $mod; done +#doas rc-service DesktopVideoHelper start + +ffmpeg \ + -f decklink -format_code ntsc -i "Intensity Pro" \ + -c:v libx265 \ + -qmin 6 -qmax 18 -qdiff 4 \ + -vf yadif \ + -c:a flac \ + -metadata "title"="$1" \ + -metadata "comment=tapes.tjkeller.xyz" \ + "$1.mkv" diff --git a/.old/rectapevaapi b/.old/rectapevaapi new file mode 100755 index 0000000..91c0709 --- /dev/null +++ b/.old/rectapevaapi @@ -0,0 +1,13 @@ +#!/bin/sh +[ -z "$1" ] && $0 untitled_$(ls | wc -l) + +for mod in blackmagic blackmagic-io; do doas modprobe $mod; done +doas rc-service DesktopVideoHelper start + +ffmpeg -hwaccel auto -vaapi_device /dev/dri/renderD128 \ + -f decklink -format_code ntsc -i "Intensity Pro" \ + -c:v hevc_vaapi \ + -vf "yadif,format=nv12,hwupload" \ + -c:a libopus -b:a 384k \ + -metadata "title"="$1$title" \ + "$1$title.mkv" diff --git a/.old/screenrec b/.old/screenrec new file mode 100755 index 0000000..8f65514 --- /dev/null +++ b/.old/screenrec @@ -0,0 +1,24 @@ +#!/bin/sh +newname() { defname="video"; name=$defname`ls | grep "^$defname[0-9]*" | wc -l | tr -d '[:blank:]'`.mkv; } +[ -z "$1" ] && newname || name="$1" +# Get screen info. I suspect this script wouldn't work too well with multiple screens. Somebody else can add that +resinfo="$(xrandr | grep '*' | tr -s ' ')" +vs="$(echo "$resinfo" | cut -d' ' -f2)" +fr="$(echo "$resinfo" | sed 's/.*\s\([0-9]*\.[0-9]*\)\*.*/\1/')" +# -i is screen coordinates for top-leftmost screen +# Encoder settings are basically lossless and optimized for good speed, decent size, and great quality +# yuv444p colorspace is needed for a 24 bit rgb monitor, change for hdr. yuv420p is the default and is good for video, but is inadequate for screencasts +ffmpeg -hide_banner \ + -video_size $vs \ + -framerate $fr \ + -f x11grab \ + -i :0.0+0,0 \ + -f alsa -channels 1 -sample_rate 48000 \ + -i hw:3 \ + -c:v libx264 \ + -c:a libopus \ + -b:a 128k \ + -preset ultrafast \ + -qp 1 \ + -pix_fmt yuv444p \ + "$name" diff --git a/.old/shows b/.old/shows new file mode 100755 index 0000000..a0cb8a6 --- /dev/null +++ b/.old/shows @@ -0,0 +1,26 @@ +#!/bin/sh +showsdir=/media/4tbhdd/Videos/Shows +dmenucolors="-l 25" + +playvid() { [ -e "$1" ] && mpv --fullscreen "$1" || exit 1; } + +# Select show +show="`ls "$showsdir" | dmenu $dmenucolors -p "Show:"`" || exit 1 + +# Select season or special option +allep="Show All Episodes" +randep="Play Random Episode" +season="`echo "$allep\n$randep\n$(ls "$showsdir/$show")" | dmenu $dmenucolors -p "Season:"`" || exit 1 + +# Select episode +case "$season" in + $allep) + ep="$(find "$showsdir/$show" -type f | sort | sed 's/.* \([0-9]*\)\/\(.*\)\.mkv$/S\1E\2/' | dmenu $dmenucolors -p "Episode:")" + playvid "$showsdir/$show/$(echo "$ep" | sed 's/^S\([0-9]*\)E/Season \1\//').mkv" + ;; + $randep) playvid "$(find "$showsdir/$show" -type f | shuf -n1)" ;; + *) + ep="$(ls "$showsdir/$show/$season" | sed 's/\.mkv$//' | dmenu $dmenucolors -p "Episode:")" + playvid "$showsdir/$show/$season/$ep.mkv" + ;; +esac diff --git a/.old/sinkswitch b/.old/sinkswitch new file mode 100755 index 0000000..3046498 --- /dev/null +++ b/.old/sinkswitch @@ -0,0 +1,15 @@ +#!/bin/sh +[ $(hostname) != 'T495' ] && echo "Not T495. Exiting" && exit 1 + +status="$(wpctl status)" + +headphones_sink=$(echo "$status" | grep -m1 'ThinkPad USB-C Dock Gen2 USB Audio Analog Stereo \[vol:' | grep -m1 -o '[0-9]*') +speakers_sink=$( echo "$status" | grep -m1 'Raven/Raven2/Fenghuang HDMI/DP Audio Controller Digital Stereo (HDMI 2) \[vol:' | grep -m1 -o '[0-9]*') + +selected_sink=$(echo "$status" | grep -m1 '\*\s*[0-9]*' | grep -o '[0-9]*') + +case $selected_sink in + $headphones_sink) wpctl set-default $speakers_sink && echo "Switched to speakers" ;; + $speakers_sink) wpctl set-default $headphones_sink && echo "Switched to headphones" ;; + *) echo "Cannot find correct sink. Exiting" && exit 1 ;; +esac diff --git a/.old/sync/griff b/.old/sync/griff new file mode 100755 index 0000000..549b108 --- /dev/null +++ b/.old/sync/griff @@ -0,0 +1,64 @@ +#!/bin/sh +home=$(echo $HOME | sed 's/\//\\\//g') +repos="$(grep -v '#' | sed "s/\~/$home/")" << REPOS +#~/.local/src/programs/blr +~/.local/src/programs/dmenu +~/.config +~/.local/bin +~/.local/src/programs/st +~/.local/src/programs/timmywm +REPOS +#echo "$repos" | cut -f1 + +# Colors +BOLD="\033[1m" +NORM="\033[0m" +CYN="\033[0;36m" +RED="\033[0;31m" +GRN="\033[0;32m" +MAG="\033[0;35m" + +me() { echo $0 | sed 's/.*\///'; } +repocheck() { [ -z "$repos" ] && echo "No repos have been added!\nUse \"$(me) add\" or edit the script file to add a new repo!" && exit; } + +reponame() { sed -n 's/^\s*url.*\/\(.*\)\.git/\1/p' $1/.git/config; } + +rddiff() { + repocheck + for repo in $repos; do + name="$(reponame $repo)" + if cd $repo 2>/dev/null; then + if git diff --quiet HEAD $REF -- $DIR; then + echo "$GRN[Repo $name is unchanged!]$NORM" + else + echo "$CYN[Repo $name has changed:]$NORM" + git status | grep -v '(use' + read -p "Would you like to view the changes? [y/n]: " viewchange + case $viewchange in + y|yes|Y|Yes) git diff HEAD $REF -- $DIR ;; + esac + read -p "Would you like to push these changes? [y/n]: " pushchange + case $pushchange in + y|yes|Y|Yes) + while [ -z "$commitmsg" ]; do + read -p "Enter a commit message: " commitmsg + done + git add . && git commit -m "$commitmsg" && git push \ + && echo "$GRN[Changes to repo $name successfully pushed!]$NORM" \ + || echo "$RED[An error occured while pushing changes to repo $name!]$NORM" + commitmsg="" + ;; + esac + fi + else + echo "$BOLD$RED[Repo $name does not exist at $dir!]$NORM" + fi + done +} + +drdiff() { echo impl; } + +case $1 in + add) echo "add this in" ;; + *) rddiff ;; +esac diff --git a/.old/sync/pull b/.old/sync/pull new file mode 100755 index 0000000..f52ec5e --- /dev/null +++ b/.old/sync/pull @@ -0,0 +1,57 @@ +#!/bin/sh + +printusage() { echo "Usage: $0 [-b,--build] [<repo> ...] (repos: all,`echo $repos | tr ' ' ','`)" && exit; } + +repos=$repos"blr dmenu dotconfig scripts st timmywm" #repos=$repos"dotconfig|dwmpatches|scripts|st|timmywm" + +[ -z $1 ] || [ `echo "$@" | tr ' ' '\n' | grep -v -c '\-'` = 0 ] && printusage + +# Colors +BOLD="\033[1m" +NORM="\033[0m" +CYN="\033[0;36m" +RED="\033[0;31m" +GRN="\033[0;32m" +MAG="\033[0;35m" + +printsyncmsg() { echo "$CYN[Pulling repo '$arg'...]$NORM"; } +printsuccess() { echo "$BOLD$GRN[Successfully pulled repo '$arg']$NORM"; } +printerror() { echo "$BOLD$RED[Failed to pull repo '$arg']$NORM"; } + +#change colors +printmakemsg() { echo "$MAG[Building repo '$arg'...]$NORM"; } +printmakesuccess() { echo "$BOLD$GRN[Successfully built repo '$arg']$NORM"; } +printmakeerror() { echo "$BOLD$RED[Failed to build repo '$arg']$NORM"; } + +pullrepo() { + printsyncmsg + cd $1 && git pull --verbose \ + && printsuccess || printerror +} +makerepo() { + if echo "$opts" | grep '\-b'; then + printmakemsg + ${SUDO:-sudo} make clean install \ + && printmakesuccess || printmakeerror + fi +} +makeautoconf() { make autoconfig && echo "$BOLD$GRN[Automatically configured '$repo']$NORM"; } + +pullblr() { pullrepo ~/.local/src/programs/blr; } +pulldmenu() { pullrepo ~/.local/src/programs/dmenu && makeautoconf && makerepo; } +pulldotconfig() { pullrepo ~/.config; } +pullscripts() { pullrepo ~/.local/bin; } +pullst() { pullrepo ~/.local/src/programs/st && makeautoconf && makerepo; } +pulltimmywm() { pullrepo ~/.local/src/programs/timmywm && makeautoconf && makerepo; } + +for arg in "$@"; do + case $arg in + -b|--build) opts="$opts-b" ;; + all) $0 $opts $repos ;; + *) # Would like to use something like $repos) here but cant + for repo in $repos; do + [ "$arg" = "$repo" ] && pull$arg && break + done || printusage + ;; + esac +done diff --git a/.old/sync/pushsite b/.old/sync/pushsite new file mode 100755 index 0000000..1a1cbc3 --- /dev/null +++ b/.old/sync/pushsite @@ -0,0 +1,8 @@ +#!/bin/sh +ssh root@tjkeller.xyz << EOF +cd /var/www/tjkeller/ +git pull +cd articles +git pull +./tssg -r tssgmd . template.html +EOF diff --git a/.old/sync/sink b/.old/sync/sink new file mode 100755 index 0000000..b11b492 --- /dev/null +++ b/.old/sync/sink @@ -0,0 +1,47 @@ +#!/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="rsync@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/vaapiencode b/.old/vaapiencode new file mode 100755 index 0000000..ae079f2 --- /dev/null +++ b/.old/vaapiencode @@ -0,0 +1,9 @@ +#!/bin/sh +ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128 \ + -ss 60 \ + -i "$1" \ + -t 60 \ + -c:v h264_vaapi \ + -b:v 1000k \ + -c:a libopus -b:a 128k \ + "h264_$1.mkv" diff --git a/.old/viewintensitypro b/.old/viewintensitypro new file mode 100755 index 0000000..cd2d73d --- /dev/null +++ b/.old/viewintensitypro @@ -0,0 +1,7 @@ +#!/bin/sh +#for mod in blackmagic blackmagic-io; do doas modprobe $mod; done +#doas rc-service DesktopVideoHelper start + +ffplay \ +-f decklink -format_code ntsc -i "Intensity Pro" \ +-vf yadif diff --git a/.old/viewwebcam b/.old/viewwebcam new file mode 100755 index 0000000..c56d879 --- /dev/null +++ b/.old/viewwebcam @@ -0,0 +1,2 @@ +#!/bin/sh +ffplay -f v4l2 -input_format mjpeg -video_size 1920x1080 -framerate 30 -i /dev/video0 diff --git a/.old/volcon b/.old/volcon new file mode 100755 index 0000000..9940c67 --- /dev/null +++ b/.old/volcon @@ -0,0 +1,3 @@ +#!/bin/sh +amixer -D pipewire sset Master $1 > /dev/null +dwmsbup 10 diff --git a/.old/volume b/.old/volume new file mode 100755 index 0000000..4a4b4a8 --- /dev/null +++ b/.old/volume @@ -0,0 +1,27 @@ +#!/usr/bin/awk -f + +BEGIN { +cmd="amixer -D pipewire sget Master" +FS="[][]" +while (cmd | getline) { + if (NF > 1) { + vol=int($2) + if ($4 == "off") + icon="" + else if (vol > 70) + icon="" + else if (vol > 40) + icon="" + else if (vol > 10) + icon="" + else + icon="" + #printf "%s %s | %05.2fdB", icon, $2, $4 + print icon" "$2 + } +} +} + +##!/bin/sh +##amixer sget Master | awk -F'[][]' '/%/{print $2" | "$4 " [" $6 "]"}' +#amixer -M sget Master | sed -n 's/.*Playback [0-9]* \[//; s/. ./ | /; s/\] .off\]/ \[mute\]/p; s/\] .on.//p' diff --git a/.old/wgconnect b/.old/wgconnect new file mode 100755 index 0000000..de8f307 --- /dev/null +++ b/.old/wgconnect @@ -0,0 +1,40 @@ +#!/bin/sh +# Connect to/disconnect from wireguard tunnel using dmenu + +sudo="${SUDO:-sudo}" +pass="$(xsudo --get-pass)" + +ssudo() { echo "$pass" | $sudo $@ ; } + +dmenu_confirm_continue() { + case "$(echo "yes\nno" | dmenu -p "$1")" in + yes) + ;; + *) exit 0 ;; + esac +} + +curtun="$(ssudo wg show | sed 's/interface: //;q')" + +# Ask to disconnect from current interface +if [ -n "$curtun" ]; then + dmenu_confirm_continue "Currently connected to tunnel $curtun. Disconnect?" + + output="$(ssudo wg-quick down "$curtun" 2>&1)" + notify-send "Disconnected from $curtun" "$output" + + dmenu_confirm_continue "Connect to another interface?" +fi + +# Connect to new interface +tundir=/etc/wireguard + +tun="$tundir/$(ssudo ls "$tundir" | grep "\.conf$" | dmenu -p "Connect to which tunnel?")" + +if ! ssudo cat $tun >/dev/null 2>/dev/null; then + notify-send "Couldn't connect to tunnel $tun" + exit 1 +fi + +output="$(ssudo wg-quick up "$tun" 2>&1)" +notify-send "Connected to $tun" "$output" |