From 868fbb687b9be7b3107370a3499e30ccc679b7fb Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Wed, 22 Feb 2023 19:17:52 +0100 Subject: [PATCH] Generic update. --- recorder | 46 ++++++++++++++++++++++++++++++++++++++++++++++ sync-backup | 2 +- task-notify | 4 ++-- vpn | 17 +++++++++++++++++ watcher | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 107 insertions(+), 3 deletions(-) create mode 100755 recorder create mode 100755 vpn create mode 100755 watcher diff --git a/recorder b/recorder new file mode 100755 index 0000000..6f5989f --- /dev/null +++ b/recorder @@ -0,0 +1,46 @@ +#!/bin/sh + +record () { + ## Options + frameRate=60 # FPS + audioQuality=10 # Opus Qual - Bad 0 <> 10 Good + videoQuality=15 # H264 QVal - Lower is better + recordLocation=~/vids/yt + + ## Auto-Config - Use the last render device which should be the Intel GPU + currentRes=$(xdpyinfo | grep dimensions | awk '{print $2}') + + ffmpeg -loglevel 16 -threads 6 -probesize 10M -framerate ${frameRate} -vsync 1 \ + -thread_queue_size 512 -f x11grab -s ${currentRes} -r ${frameRate} -i :0.0 \ + -thread_queue_size 512 -f pulse -ac 2 -channel_layout stereo -i default -c:a libopus -vbr on -compression_level ${audioQuality} \ + -c:v h264_nvenc -qp ${videoQuality} "${recordLocation}/$(date +%y%m%d%H%M%S).mkv" > /tmp/recorder.log & + printf '%s\n' "$!" > /tmp/recording.pid + + if [ "$?" -ne "0" ]; then + quick-notify "Recorder" "Failed to start recording" + quick-notify "Recorder" "Error: $(cat /tmp/recorder.log)" + else + touch /tmp/recording.lock + quick-notify "Recorder" "Started recording" + fi +} + +stop () { + pid=$(cat /tmp/recording.pid) + + kill $pid + + if [ "$?" -ne "0" ];then + quick-notify "Recorder" "Failed to stop recording" + else + quick-notify "Recorder" "Stopped recording" + fi + + rm /tmp/recording.pid /tmp/recording.lock /tmp/recorder.log +} + +if [ -f "/tmp/recording.lock" ]; then + stop +else + record +fi diff --git a/sync-backup b/sync-backup index 3e82e8b..482f6a0 100755 --- a/sync-backup +++ b/sync-backup @@ -26,7 +26,7 @@ printf '%s\n' "$password" | sudo -S mount /dev/mapper/luks /mnt/encrypted while read Line; do echo "Syncing $(basename $Line)" - rsync -ahAX -v --delete "$Line" $HOME/.local/backup + rsync -ahAX -v --delete "$Line" /mnt/encrypted done <<< "$(cat $HOME/.config/rsync/backup-list)" printf '\n%s\n\n' "Unmounting encrypted drive" diff --git a/task-notify b/task-notify index 000ffeb..5b3631b 100755 --- a/task-notify +++ b/task-notify @@ -2,7 +2,7 @@ tasks=$(task status:pending -notified due export | jq -r '.[].description') [ -z "$tasks" ] && exit 0 -for task in $tasks; do +while read task; do notify-send 'A task is due.' "$task" -done +done <<< "$(echo $tasks)" task rc.bulk=0 rc.confirmation=off status:pending -notified due modify +notified diff --git a/vpn b/vpn new file mode 100755 index 0000000..efca126 --- /dev/null +++ b/vpn @@ -0,0 +1,17 @@ +#!/bin/sh + +up () { + transmission-remote --exit + sudo wg-quick up myvpn + exit +} + +down () { + sudo wg-quick down myvpn + start-program transmission-daemon + exit +} + +[ "$1" = "up" ] && up +[ "$1" = "down" ] && down +exit 1 diff --git a/watcher b/watcher new file mode 100755 index 0000000..e4e4c0f --- /dev/null +++ b/watcher @@ -0,0 +1,41 @@ +#!/bin/sh + +watch () { + mpv "$1" + clear + read -p 'Did you finish watching? [Y/n]: ' yn + while true; do + if [ -z "$yn" ] || [ "$yn" = "Y" ] || [ "$yn" = "y" ]; then + name=$(printf '%s\n' "$1" | sed 's:./::g') + printf '%s\n' "$name" >> "$2" + break + elif [ "$yn" = "N" ] || [ "$yn" = "n" ]; then + break + fi + read -p 'Try again? [Y/n]: ' yn + done +} + +# check () { +# +# } + +# config +[ ! -d "$HOME/.config/watcher" ] && mkdir -p "$HOME/.config/watcher/" +[ ! -f "$HOME/.config/watcher/config" ] && touch "$HOME/.config/watcher/config" +directory=$(cat $HOME/.config/watcher/config | grep 'directory' | cut -d= -f 2) +exclude=$(printf '! -name %s ' $(cat $HOME/.config/watcher/config | grep 'exclude' | cut -d= -f 2 | sed 's/;/\n/g')) + +# watchlist +[ ! -f '$HOME/.cache/watchlist' ] && touch "$HOME/.cache/watchlist" +[ -s "$HOME/.cache/watchlist" ] && watchlist=$(printf '! -name %s ' $(cat $HOME/.cache/watchlist)) || watchlist="" + +cd $directory + +while true; do + current_dir=$(basename $(pwd)) + choice=$(find -maxdepth 1 -mindepth 1 $exclude $watchlist | sort | fzf -i --prompt "Current directory: $current_dir ") + [ -z "$choice" ] && clear && exit + [ -d "$choice" ] && cd "$choice" + [ -f "$choice" ] && watch "$choice" "$HOME/.cache/watchlist" && watchlist=$(printf '! -name %s ' $(cat $HOME/.cache/watchlist)) +done