From 4d0bd914e7c1ee65f4036e60149a7b891906a5d3 Mon Sep 17 00:00:00 2001 From: George Abbott Date: Tue, 31 Oct 2023 17:54:07 +0000 Subject: Commit all to date. --- util/bkdir | 12 ++++++++++++ util/comment: | 4 ++++ util/git-push-all | 6 ++++++ util/isflag | 13 +++++++++++++ util/music-dl | 14 ++++++++++++++ util/process-img | 23 +++++++++++++++++++++++ util/pvd | 4 ++++ util/rd | 10 ++++++++++ util/rdpdf | 7 +++++++ util/s6-restart | 5 +++++ util/track-parcel | 7 +++++++ util/wv | 20 ++++++++++++++++++++ util/yt-suffix | 12 ++++++++++++ 13 files changed, 137 insertions(+) create mode 100755 util/bkdir create mode 100755 util/comment: create mode 100755 util/git-push-all create mode 100755 util/isflag create mode 100755 util/music-dl create mode 100755 util/process-img create mode 100755 util/pvd create mode 100755 util/rd create mode 100755 util/rdpdf create mode 100755 util/s6-restart create mode 100755 util/track-parcel create mode 100755 util/wv create mode 100755 util/yt-suffix (limited to 'util') diff --git a/util/bkdir b/util/bkdir new file mode 100755 index 0000000..9bd7e3b --- /dev/null +++ b/util/bkdir @@ -0,0 +1,12 @@ +#!/bin/sh + +# Backup a directory using GPG. +# Usage: bkdir directory-name +# Requires: tar, gpg, sha256sum (i.e. GNU/Linux). + +DIRECTORY="$1" + +tar czvf "$DIRECTORY.tar.gz" "$DIRECTORY" +gpg --encrypt --armor --symmetric --output "$DIRECTORY.tar.gz.gpg" "$DIRECTORY.tar.gz" +sha256sum "$DIRECTORY.tar.gz.gpg" | cut -c1-64 > "$DIRECTORY.tar.gz.sum" + diff --git a/util/comment: b/util/comment: new file mode 100755 index 0000000..ae5a7be --- /dev/null +++ b/util/comment: @@ -0,0 +1,4 @@ +#!/bin/sh +# Does nothing. But you can write: +# comment: I am so cool, sunnavabitch +# So you can write comments. diff --git a/util/git-push-all b/util/git-push-all new file mode 100755 index 0000000..ffa3ff5 --- /dev/null +++ b/util/git-push-all @@ -0,0 +1,6 @@ +#!/bin/sh +# git-push-all: Iterate through all git remotes, and push to each of them. + +for rem in $(git remote) ; do + git push "$rem" +done diff --git a/util/isflag b/util/isflag new file mode 100755 index 0000000..214a989 --- /dev/null +++ b/util/isflag @@ -0,0 +1,13 @@ +#!/bin/sh +# Pass a flag name, and "$@", and this will check if the flag was passed. +# Example: isflag '-p' "$@" +# will check if the -p flag was passed to the program. + +term="$1" +shift +for arg; do + if [ "$arg" = "$term" ] ; then + return 0 + fi +done +return 1 diff --git a/util/music-dl b/util/music-dl new file mode 100755 index 0000000..21d0358 --- /dev/null +++ b/util/music-dl @@ -0,0 +1,14 @@ +#!/bin/sh +# Grab the audio track via yt-dlp, and place in the music folder. + +musicdir="/var/lib/mpd/music/yt-dlp" +record="$musicdir/dlrecord" + +mkdir -p "$musicdir" + +notify-send "Downloading..." "Downloading $1"& +yt-dlp "$1" --format bestaudio -P "$musicdir" -o "%(title)s.%(ext)s" +echo "$1" >> "$record" +notify-send "Song downloaded!" "$1 is now downloaded." & + +mpd update diff --git a/util/process-img b/util/process-img new file mode 100755 index 0000000..88e426b --- /dev/null +++ b/util/process-img @@ -0,0 +1,23 @@ +#!/bin/sh +# Process images in the directory. Creates: +# - A directory large/, with all the images in full. +# - A directory small/, with all the images 600x400. +# - An output file, images.html, with the figcaptions for each of them. +# The href of the large will be $1/large/image.jpg. +# +# TODO +# - Make it so it doesn't add entries for large/ and small/ dirs. + + +URL_PREFIX="$1" + +mkdir -p small +mkdir -p large + +for file in * +do + echo "Currently on: ", $file + cp "$file" "large/$file" + convert -resize 600X400 "$file" "small/$file" + echo "
\n\t\n
TODO
\n
\n\n" >> images.html +done diff --git a/util/pvd b/util/pvd new file mode 100755 index 0000000..dc1b9fd --- /dev/null +++ b/util/pvd @@ -0,0 +1,4 @@ +#!/bin/sh +# mpv all files with an asterisk. + +mpv *$1* diff --git a/util/rd b/util/rd new file mode 100755 index 0000000..1917fa0 --- /dev/null +++ b/util/rd @@ -0,0 +1,10 @@ +#!/bin/sh +# rd: rename current directory +# rd "new-name" + + +[ "$1" = "" ] && echo "rd: rename directory: new name missing" && return +curr="$(basename "$(pwd)")" +cd .. +mv "$curr" "$1" +cd "$1" || return diff --git a/util/rdpdf b/util/rdpdf new file mode 100755 index 0000000..65c8d9b --- /dev/null +++ b/util/rdpdf @@ -0,0 +1,7 @@ +#!/bin/sh +# Locate PDFs and read them. +# Requires: locate, fzf, zathura. + +f="$(locate .pdf | fzf)" +[ -z "$f" ] && exit +zathura "$f" diff --git a/util/s6-restart b/util/s6-restart new file mode 100755 index 0000000..4e0e5e4 --- /dev/null +++ b/util/s6-restart @@ -0,0 +1,5 @@ +#!/bin/sh + +sudo s6-rc -d change $1 +sudo s6-rc -u change $1 + diff --git a/util/track-parcel b/util/track-parcel new file mode 100755 index 0000000..f298e9b --- /dev/null +++ b/util/track-parcel @@ -0,0 +1,7 @@ +#!/bin/sh +# Given a tracking reference either as first argument or piped in, +# open in $BROWSER, or xdg-open, the tracking site for that reference. + +# TODO: actually finish implementing. +xdg-open "https://www.evri.com/track/parcel/$1/details" +xdg-open "https://www.royalmail.com/track-your-item#/tracking-results/$1" diff --git a/util/wv b/util/wv new file mode 100755 index 0000000..d5a8a13 --- /dev/null +++ b/util/wv @@ -0,0 +1,20 @@ +#!/bin/sh +# Watch video: it downloads it into $WV_DIRECTORY, then plays it. If no +# argument passed, it will select a video in $WV_DIRECTORY. + +if [ -z "$WV_DIRECTORY" ] ; then + echo "WV_DIRECTORY not set" + exit 1 +fi + +mkdir -p "$WV_DIRECTORY" + +if [ -z "$1" ] ; then + # No args. + echo "No args: TODO: implement selecting video in WV_DIRECTORY" + exit 1 +fi + +yt-dlp "$1" -P "$WV_DIRECTORY" -o "%(title)s.%(ext)s" -f "bv*[height<=720]+ba/b[height<=720] / wv*+ba/w" +fn="$(yt-dlp "$1" -P "$WV_DIRECTORY" -o "%(title)s.%(ext)s" --print filename)" +mpv "$fn" diff --git a/util/yt-suffix b/util/yt-suffix new file mode 100755 index 0000000..fc9ccb4 --- /dev/null +++ b/util/yt-suffix @@ -0,0 +1,12 @@ +#!/bin/sh +# Get the suffix from a Youtube video, or Invidious instance. +# https://youtube.com/watch?v=dQw4w9WgXcQ -> dQw4w9WgXcQ +# Pass the -w flag if you want to keep the watch?v= +# Usage: +# yt-suffix PATH (-w) + +if isflag '-w' "$@" ; then + echo "watch?v=" +fi + +echo $1 | awk -F'/' '{print $4}' | awk -F'=' '{print $2}' -- cgit v1.2.1