scripts

My personal collection of scripts
git clone git://src.gearsix.net/scripts
Log | Files | Refs | Atom | README | LICENSE

commit 34549fd5f891b1c94e6bea75069dc2184c4e8413
parent c30556b2fcb2807ae1599b4e827a2bf021a329d0
Author: gearsix <gearsix@tuta.io>
Date:   Mon, 26 Dec 2022 18:02:13 +0000

added -h options to all posix scripts

Diffstat:
Msrc/posix/catrm.sh | 9++++++++-
Msrc/posix/compress-pdf.sh | 2++
Msrc/posix/flac2mp3.sh | 2++
Msrc/posix/gnome-shell-cycle-wallpaper.sh | 7+++++++
Msrc/posix/openurl.sh | 8++++++++
Msrc/posix/pyserve.sh | 10++++++++++
6 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/posix/catrm.sh b/src/posix/catrm.sh @@ -2,11 +2,18 @@ # cat & remove # description: cat $@ and prompt to rm +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + echo "Usage: 'catrm FILEPATHS...'" + echo "" + echo "prompt to remove listed files, with an option to (c)at them" + exit +fi + ync= for f in $@; do unset ync while [ ! $ync ]; do - read -p "read remove '$(readlink -f $f)' [y/n/c]? " -n 1 ync + read -p "remove '$(readlink -f $f)' [y/n/c]? " -n 1 ync echo "" if [ "$ync" == "y" ]; then rm $f elif [ "$ync" == "c" ]; then cat $f; unset ync diff --git a/src/posix/compress-pdf.sh b/src/posix/compress-pdf.sh @@ -10,6 +10,8 @@ if [ -z $1 ] || [ -z $2 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "for SETTINGS options, see https://web.mit.edu/ghostscript/www/Ps2pdf.htm#Options" echo "INPUT should provide the filepath of a PDF to compress" echo "OUTPUT should provided the filepath of the compressed PDF (default: ./compressed.pdf)" + echo "" + echo "Dependencies: ghostscript" exit fi diff --git a/src/posix/flac2mp3.sh b/src/posix/flac2mp3.sh @@ -8,6 +8,8 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "Usage: flac2mp3 DIRECTORY" echo "" echo "use ffmpeg to convert a directory of .flac files to .mp3 files" + echo "" + echo "Dependencies: ffmpeg" exit fi diff --git a/src/posix/gnome-shell-cycle-wallpaper.sh b/src/posix/gnome-shell-cycle-wallpaper.sh @@ -5,6 +5,13 @@ . "$HOME/.config/user-dirs.dirs" WALLPAPERS_DIR=$XDG_PICTURES_DIR/wallpapers/ +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + echo "usage: ./gnome-shell-cycle-wallpaper.sh" + echo "" + echo "change the wallpaper on a GNOME desktop to a random file from $WALLPAPERS_DIR" + exit +fi + selection=$(find "$WALLPAPERS_DIR" -type f | shuf -n1) gsettings set org.gnome.desktop.background picture-uri "file://$selection" gsettings set org.gnome.desktop.background picture-uri-dark "file://$selection" diff --git a/src/posix/openurl.sh b/src/posix/openurl.sh @@ -3,8 +3,16 @@ # description: xdg-open all urls found in $@ # e.g.$ openurl saved-links.txt +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + echo "usage: ./openurl.sh FILEPATHS..." + echo "" + echo "open all links existing in contents of listed files" + exit +fi + for f in $@; do for url in "$(grep -o -E 'https?://[^"]+' $f)"; do xdg-open "$url"; done done + diff --git a/src/posix/pyserve.sh b/src/posix/pyserve.sh @@ -1,5 +1,15 @@ #!/usr/bin/env sh +if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + echo "usage: ./pyserve.sh [DIRECTORY] [PORT]" + echo "" + echo "Shorthand for 'python3 -m http.server --directory DIRECTORY PORT'" + echo "" + echo "DIRECTORY (default: '.') The directory to use as the root directory of the webserver" + echo "PORT (default: 8001) The port to use for the webserver" + exit +fi + dir="." port="8001"