From 09ada24d4ec23cf24ab136141b354953d1bbc2fa Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Sun, 17 Nov 2024 23:34:54 -0600 Subject: reorganize scripts --- .old/d8concat | 164 +++++++++++++++++++++++++++++++++++++++++++++++++ .old/d8integrity | 9 +++ .old/dmenu_runapp | 4 ++ .old/dmenunametag | 30 +++++++++ .old/dnfu | 10 +++ .old/dockfanctl | 10 +++ .old/dvgrabscript | 1 + .old/emu | 57 +++++++++++++++++ .old/enablecoredumps | 3 + .old/music | 28 +++++++++ .old/rectape | 16 +++++ .old/rectapehevc | 15 +++++ .old/rectapevaapi | 13 ++++ .old/screenrec | 24 ++++++++ .old/shows | 26 ++++++++ .old/sinkswitch | 15 +++++ .old/sync/griff | 64 +++++++++++++++++++ .old/sync/pull | 57 +++++++++++++++++ .old/sync/pushsite | 8 +++ .old/sync/sink | 47 ++++++++++++++ .old/vaapiencode | 9 +++ .old/viewintensitypro | 7 +++ .old/viewwebcam | 2 + .old/volcon | 3 + .old/volume | 27 ++++++++ .old/wgconnect | 40 ++++++++++++ bar/volume | 27 -------- bar/wmip | 2 - keyboard/dmenunametag | 30 --------- keyboard/dockfanctl | 10 --- keyboard/sinkswitch | 15 ----- keyboard/volcon | 3 - keyboard/wgconnect | 40 ------------ launch/dmenu_runapp | 4 -- launch/emu | 57 ----------------- launch/launch | 110 --------------------------------- launch/music | 28 --------- launch/shows | 26 -------- misc/dnfu | 10 --- misc/enablecoredumps | 3 - misc/launch | 110 +++++++++++++++++++++++++++++++++ misc/verifoo | 110 --------------------------------- misc/wmip | 2 + sync/griff | 64 ------------------- sync/pull | 57 ----------------- sync/pushsite | 8 --- sync/sink | 47 -------------- video/d8concat | 164 ------------------------------------------------- video/d8integrity | 9 --- video/dvgrabscript | 1 - video/rectape | 16 ----- video/rectapehevc | 15 ----- video/rectapevaapi | 13 ---- video/screenrec | 24 -------- video/vaapiencode | 9 --- video/viewintensitypro | 7 --- video/viewwebcam | 2 - 57 files changed, 801 insertions(+), 911 deletions(-) create mode 100755 .old/d8concat create mode 100755 .old/d8integrity create mode 100755 .old/dmenu_runapp create mode 100755 .old/dmenunametag create mode 100755 .old/dnfu create mode 100755 .old/dockfanctl create mode 100644 .old/dvgrabscript create mode 100755 .old/emu create mode 100755 .old/enablecoredumps create mode 100755 .old/music create mode 100755 .old/rectape create mode 100755 .old/rectapehevc create mode 100755 .old/rectapevaapi create mode 100755 .old/screenrec create mode 100755 .old/shows create mode 100755 .old/sinkswitch create mode 100755 .old/sync/griff create mode 100755 .old/sync/pull create mode 100755 .old/sync/pushsite create mode 100755 .old/sync/sink create mode 100755 .old/vaapiencode create mode 100755 .old/viewintensitypro create mode 100755 .old/viewwebcam create mode 100755 .old/volcon create mode 100755 .old/volume create mode 100755 .old/wgconnect delete mode 100755 bar/volume delete mode 100755 bar/wmip delete mode 100755 keyboard/dmenunametag delete mode 100755 keyboard/dockfanctl delete mode 100755 keyboard/sinkswitch delete mode 100755 keyboard/volcon delete mode 100755 keyboard/wgconnect delete mode 100755 launch/dmenu_runapp delete mode 100755 launch/emu delete mode 100755 launch/launch delete mode 100755 launch/music delete mode 100755 launch/shows delete mode 100755 misc/dnfu delete mode 100755 misc/enablecoredumps create mode 100755 misc/launch delete mode 100755 misc/verifoo create mode 100755 misc/wmip delete mode 100755 sync/griff delete mode 100755 sync/pull delete mode 100755 sync/pushsite delete mode 100755 sync/sink delete mode 100755 video/d8concat delete mode 100755 video/d8integrity delete mode 100644 video/dvgrabscript delete mode 100755 video/rectape delete mode 100755 video/rectapehevc delete mode 100755 video/rectapevaapi delete mode 100755 video/screenrec delete mode 100755 video/vaapiencode delete mode 100755 video/viewintensitypro delete mode 100755 video/viewwebcam 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] [ ...] (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: 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" diff --git a/bar/volume b/bar/volume deleted file mode 100755 index 4a4b4a8..0000000 --- a/bar/volume +++ /dev/null @@ -1,27 +0,0 @@ -#!/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/bar/wmip b/bar/wmip deleted file mode 100755 index 56fe23d..0000000 --- a/bar/wmip +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ip a | awk '!/ (lo|dummy|virbr)/ && /inet / { sub(/\/.*/, "", $2); printf "%-12s %s\n", $NF":", $2 }' diff --git a/keyboard/dmenunametag b/keyboard/dmenunametag deleted file mode 100755 index 0458c79..0000000 --- a/keyboard/dmenunametag +++ /dev/null @@ -1,30 +0,0 @@ -#!/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/keyboard/dockfanctl b/keyboard/dockfanctl deleted file mode 100755 index f422b3e..0000000 --- a/keyboard/dockfanctl +++ /dev/null @@ -1,10 +0,0 @@ -#!/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/keyboard/sinkswitch b/keyboard/sinkswitch deleted file mode 100755 index 3046498..0000000 --- a/keyboard/sinkswitch +++ /dev/null @@ -1,15 +0,0 @@ -#!/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/keyboard/volcon b/keyboard/volcon deleted file mode 100755 index 9940c67..0000000 --- a/keyboard/volcon +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -amixer -D pipewire sset Master $1 > /dev/null -dwmsbup 10 diff --git a/keyboard/wgconnect b/keyboard/wgconnect deleted file mode 100755 index de8f307..0000000 --- a/keyboard/wgconnect +++ /dev/null @@ -1,40 +0,0 @@ -#!/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" diff --git a/launch/dmenu_runapp b/launch/dmenu_runapp deleted file mode 100755 index 4d7a45e..0000000 --- a/launch/dmenu_runapp +++ /dev/null @@ -1,4 +0,0 @@ -#!/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/launch/emu b/launch/emu deleted file mode 100755 index 87c0e2a..0000000 --- a/launch/emu +++ /dev/null @@ -1,57 +0,0 @@ -#!/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/launch/launch b/launch/launch deleted file mode 100755 index 5947ae7..0000000 --- a/launch/launch +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/sh -awk=awk -me() { basename "$0"; } - -printhelp() { -cat << HELPDOC -Usage: - $(me): [-gh] [COMMAND] [COMMAND ARGS]... - -Args: - -g, --gen-cache : Force generate cache - -h, --help : show this help message - -Config Syntax: - +host [HOSTNAME] - Add a new host. Hosts can be referenced using their number starting with 1. - [COMMAND] - launch [COMMAND] will start the process specified for the specific hostname. Aliases are separated by |. - [TAB][SHELL] - Run this shell command when the above [COMMAND] is specified. In order of hostnames. Can be a number to reference to a hostname, a '-' to disregard this command for the specific host, or a '^' to reference the previous command. -HELPDOC -} - -# Make sure user is using GNU Awk (gawk) -checkawk() { - if ! ($awk -V >/dev/null 2>/dev/null && $awk -V | grep "GNU Awk" >/dev/null); then - if command -v gawk > /dev/null; then - awk=gawk - else - echo "$(me) requires GNU Awk (gawk) to function properly. Please install GNU Awk and try again." - exit 0 - fi - fi -} - -gencache() { -$awk ' -BEGIN { - print "run=\"$1\"; shift" - print "case \"$run\" in" -} -{ - sub(/#.*/, "") # Remove comments - if (!/^\s*$/) { - if (/^\+host/) { - sub(/\s*\+host\s*/, "") - h++ - hosts[h] = $0 - } - else { - if (!/^\t/) { - hostnum = 1 - o++ - opts[o] = $0 - } - else { - sub(/^\t/, "") - if ($0 == "^") - $0 = cache - else if ($0 ~ /^[0-9]*$/) - $0 = cmds[hosts[$0]":"opts[o]] - cmds[hosts[hostnum]":"opts[o]] = cache = $0 - hostnum++ - } - } - } -} -END { - for (host in hosts) { - if (hosts[host] != "'`hostname`'") - continue - for (cmd in cmds) { - if (cmd ~ hosts[host] && cmds[cmd] && cmds[cmd] != "-") { - i = cmd - sub(/.*:/, "", cmd) - print "\t"cmd") "cmds[i]" \"$@\" & ;;" - } - } - } - print "\t*) command -v \"$run\" >/dev/null && exec \"$run\" \"$@\" || echo \"\\`$run${@:+ $@}\\` Does not exist or exited with an error\" ;;" - print "esac" -} -' $conf > $cache -chmod +x $cache -} - -# Config file setup -confdir=${XDG_CONFIG_HOME:-~/.config}/launch -conf=$confdir/config -if [ ! -e $conf ]; then - mkdir -p $confdir - echo "#HOSTS\n+host $(hostname)\n\n#OPTS\ntest\n\techo \"Tested!\"" > $conf - echo "No config file exists! new config file created at $conf! Exiting\n" - printhelp - exit 1 -fi - -# Cache file setup -cachedir=${XDG_CACHE_HOME:-~/.cache}/launch -cache=$cachedir/cache -[ ! -e $cache ] && mkdir -p $cachedir && gencache -[ $conf -nt $cache ] && gencache - -# Command line options -checkawk -case "$1" in - -g|--gen-cache) echo "Generating new cache: $cache"; gencache && cat $cache ;; - -h|--help|'') printhelp ;; - *) exec $cache "$@" ;; # Run -esac diff --git a/launch/music b/launch/music deleted file mode 100755 index cb78257..0000000 --- a/launch/music +++ /dev/null @@ -1,28 +0,0 @@ -#!/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/launch/shows b/launch/shows deleted file mode 100755 index a0cb8a6..0000000 --- a/launch/shows +++ /dev/null @@ -1,26 +0,0 @@ -#!/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/misc/dnfu b/misc/dnfu deleted file mode 100755 index 9f6a9cb..0000000 --- a/misc/dnfu +++ /dev/null @@ -1,10 +0,0 @@ -#!/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/misc/enablecoredumps b/misc/enablecoredumps deleted file mode 100755 index e435cc7..0000000 --- a/misc/enablecoredumps +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -ulimit -c unlimited -sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t diff --git a/misc/launch b/misc/launch new file mode 100755 index 0000000..5947ae7 --- /dev/null +++ b/misc/launch @@ -0,0 +1,110 @@ +#!/bin/sh +awk=awk +me() { basename "$0"; } + +printhelp() { +cat << HELPDOC +Usage: + $(me): [-gh] [COMMAND] [COMMAND ARGS]... + +Args: + -g, --gen-cache : Force generate cache + -h, --help : show this help message + +Config Syntax: + +host [HOSTNAME] + Add a new host. Hosts can be referenced using their number starting with 1. + [COMMAND] + launch [COMMAND] will start the process specified for the specific hostname. Aliases are separated by |. + [TAB][SHELL] + Run this shell command when the above [COMMAND] is specified. In order of hostnames. Can be a number to reference to a hostname, a '-' to disregard this command for the specific host, or a '^' to reference the previous command. +HELPDOC +} + +# Make sure user is using GNU Awk (gawk) +checkawk() { + if ! ($awk -V >/dev/null 2>/dev/null && $awk -V | grep "GNU Awk" >/dev/null); then + if command -v gawk > /dev/null; then + awk=gawk + else + echo "$(me) requires GNU Awk (gawk) to function properly. Please install GNU Awk and try again." + exit 0 + fi + fi +} + +gencache() { +$awk ' +BEGIN { + print "run=\"$1\"; shift" + print "case \"$run\" in" +} +{ + sub(/#.*/, "") # Remove comments + if (!/^\s*$/) { + if (/^\+host/) { + sub(/\s*\+host\s*/, "") + h++ + hosts[h] = $0 + } + else { + if (!/^\t/) { + hostnum = 1 + o++ + opts[o] = $0 + } + else { + sub(/^\t/, "") + if ($0 == "^") + $0 = cache + else if ($0 ~ /^[0-9]*$/) + $0 = cmds[hosts[$0]":"opts[o]] + cmds[hosts[hostnum]":"opts[o]] = cache = $0 + hostnum++ + } + } + } +} +END { + for (host in hosts) { + if (hosts[host] != "'`hostname`'") + continue + for (cmd in cmds) { + if (cmd ~ hosts[host] && cmds[cmd] && cmds[cmd] != "-") { + i = cmd + sub(/.*:/, "", cmd) + print "\t"cmd") "cmds[i]" \"$@\" & ;;" + } + } + } + print "\t*) command -v \"$run\" >/dev/null && exec \"$run\" \"$@\" || echo \"\\`$run${@:+ $@}\\` Does not exist or exited with an error\" ;;" + print "esac" +} +' $conf > $cache +chmod +x $cache +} + +# Config file setup +confdir=${XDG_CONFIG_HOME:-~/.config}/launch +conf=$confdir/config +if [ ! -e $conf ]; then + mkdir -p $confdir + echo "#HOSTS\n+host $(hostname)\n\n#OPTS\ntest\n\techo \"Tested!\"" > $conf + echo "No config file exists! new config file created at $conf! Exiting\n" + printhelp + exit 1 +fi + +# Cache file setup +cachedir=${XDG_CACHE_HOME:-~/.cache}/launch +cache=$cachedir/cache +[ ! -e $cache ] && mkdir -p $cachedir && gencache +[ $conf -nt $cache ] && gencache + +# Command line options +checkawk +case "$1" in + -g|--gen-cache) echo "Generating new cache: $cache"; gencache && cat $cache ;; + -h|--help|'') printhelp ;; + *) exec $cache "$@" ;; # Run +esac diff --git a/misc/verifoo b/misc/verifoo deleted file mode 100755 index 34089cb..0000000 --- a/misc/verifoo +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/sh - -help() { -cat << HELPDOC -usage: $(basename "$0") [options] [file]... - -OPTIONS: - -h, --help show this menu - -c, --check read and verify checksums from file - -r, --recursive produce a checksum for all files in a directory recursively - --recursive-sum produce a checksum for a directory. sensitive to filenames - --recursive-sum-nopath produce a checksum for a directory. not sensitive to filenames/placement - -s, --silent produce no output to stderr - -v, --verbose output a progress bar of hash progress if pv is avaliable (wip) - -MODES: - -S, --sha use sha1sum for checksums - -M, --md5 use md5sum for checksums - -X, --xxh use xxhsum for checksums (default if avaliable with sha1sum as fallback) -HELPDOC -} - -# set defaults -cat="pv -F'%r_[%b]_[%t]_[%e]_%p'" -! command -v pv >/dev/null && cat=cat - -hash=xxhsum -! command -v xxhsum >/dev/null && hash=sha1sum - -hashfiles="" -verbose=1 -recursive="" -outputfile="" - -while true; do - case "$1" in - -c|--check) [ -n "$2" ] && hashfiles="$hashfiles $2" && shift ;; - -s|--silent) verbose=0 ;; - -v|--verbose) verbose=2 ;; - --recursive|-r) recursive=3 ;; - --recursive-sum) recursive=2 ;; - --recursive-sum-nopath) recursive=1 ;; - -S|--sha) hash=sha1sum ;; - -M|--md5) hash=md5sum ;; - -X|--xxh) hash=xxhsum ;; - -h|--help) help; exit 0 ;; - -*) help; exit 1 ;; - *) break ;; - esac - shift -done - -case $verbose in - 0) cat=cat ;; - 1) cat=cat ;; -esac - -# run hash -while [ -n "$1" ]; do - if [ -d "$1" ]; then # is directory - # check if using -r flag - case "$recursive" in - 1) - # get hash of all files, sort hashes, hash hashes - # TODO make pv work in this mode - - #catd="$cat" - #if [ $verbose -ge 2 ] && [ "$catd" != "cat" ]; then - # total_files=$(du -a "$1" | wc -l) - # catd="pv -l -s$total_files -F'[%b/$total_files]_[%t]_[%e]_%p'" - #fi - #sum=`find "$1" -type f -print0 | xargs -r0 $hash | $catd | cut -d' ' -f1 | sort | $hash | cut -d' ' -f1` 2>/dev/null - sum=`find "$1" -type f -print0 | xargs -r0 $hash | cut -d' ' -f1 | sort | $hash | cut -d' ' -f1` 2>/dev/null - echo "r/$sum $1" - ;; - 2) - # hash sorted filenames - # sort all filenames w/ full path and hash - # hash those sums together - # `tar -c -f - "$1" | $hash` is a good idea but it doesn't work since changes to the fs affect tar - filehash=`find "$1" -type f -print0 | sort -z | xargs -r0 $cat | $hash | cut -d' ' -f1` - pathhash=`find "$1" -printf "%P\0" | sort -z | $hash | cut -d' ' -f1` - sum=`printf "$filehash$pathhash" | $hash | cut -d' ' -f1` - echo "p/$sum $1" - ;; - 3) - # sort files and hash each one in sequence - # TODO make pv work in this mode - find "$1" -type f -print0 | sort -z | xargs -r0 $hash - ;; - *) - [ $verbose -ge 1 ] && echo "-r not specified for directory $1. Exiting" - exit 1 - ;; - esac - else # is file - if ! [ -f "$1" ]; then - [ $verbose -gt 1 ] && echo "File $1 does not exist. Exiting" - exit 1 - fi - files="$1" - - while [ -f "$2" ]; do - files="$files\0$2" - shift - done - printf "$files" | xargs -r0 $hash - fi - shift -done diff --git a/misc/wmip b/misc/wmip new file mode 100755 index 0000000..56fe23d --- /dev/null +++ b/misc/wmip @@ -0,0 +1,2 @@ +#!/bin/sh +ip a | awk '!/ (lo|dummy|virbr)/ && /inet / { sub(/\/.*/, "", $2); printf "%-12s %s\n", $NF":", $2 }' diff --git a/sync/griff b/sync/griff deleted file mode 100755 index 549b108..0000000 --- a/sync/griff +++ /dev/null @@ -1,64 +0,0 @@ -#!/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/sync/pull b/sync/pull deleted file mode 100755 index f52ec5e..0000000 --- a/sync/pull +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh - -printusage() { echo "Usage: $0 [-b,--build] [ ...] (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/sync/pushsite b/sync/pushsite deleted file mode 100755 index 1a1cbc3..0000000 --- a/sync/pushsite +++ /dev/null @@ -1,8 +0,0 @@ -#!/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/sync/sink b/sync/sink deleted file mode 100755 index b11b492..0000000 --- a/sync/sink +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -printusage() { echo "Usage: $0 [ ...] (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/video/d8concat b/video/d8concat deleted file mode 100755 index bf8b608..0000000 --- a/video/d8concat +++ /dev/null @@ -1,164 +0,0 @@ -#!/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/video/d8integrity b/video/d8integrity deleted file mode 100755 index 717032b..0000000 --- a/video/d8integrity +++ /dev/null @@ -1,9 +0,0 @@ -#!/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/video/dvgrabscript b/video/dvgrabscript deleted file mode 100644 index d82ba55..0000000 --- a/video/dvgrabscript +++ /dev/null @@ -1 +0,0 @@ -sudo dvgrab -autosplit -rewind -timestamp -format raw -csize 100000000 diff --git a/video/rectape b/video/rectape deleted file mode 100755 index 238f5de..0000000 --- a/video/rectape +++ /dev/null @@ -1,16 +0,0 @@ -#!/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/video/rectapehevc b/video/rectapehevc deleted file mode 100755 index c44d6d9..0000000 --- a/video/rectapehevc +++ /dev/null @@ -1,15 +0,0 @@ -#!/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/video/rectapevaapi b/video/rectapevaapi deleted file mode 100755 index 91c0709..0000000 --- a/video/rectapevaapi +++ /dev/null @@ -1,13 +0,0 @@ -#!/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/video/screenrec b/video/screenrec deleted file mode 100755 index 8f65514..0000000 --- a/video/screenrec +++ /dev/null @@ -1,24 +0,0 @@ -#!/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/video/vaapiencode b/video/vaapiencode deleted file mode 100755 index ae079f2..0000000 --- a/video/vaapiencode +++ /dev/null @@ -1,9 +0,0 @@ -#!/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/video/viewintensitypro b/video/viewintensitypro deleted file mode 100755 index cd2d73d..0000000 --- a/video/viewintensitypro +++ /dev/null @@ -1,7 +0,0 @@ -#!/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/video/viewwebcam b/video/viewwebcam deleted file mode 100755 index c56d879..0000000 --- a/video/viewwebcam +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -ffplay -f v4l2 -input_format mjpeg -video_size 1920x1080 -framerate 30 -i /dev/video0 -- cgit v1.2.3