aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/common/.local/bin/any2opus
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-02 12:16:38 -0500
committerCraig Jennings <c@cjennings.net>2026-06-02 12:16:38 -0500
commitb10cba594db836c0747066addad48bda4d30cd02 (patch)
tree063119a623fa3f7139feda4ef302896d8f5f934c /dotfiles/common/.local/bin/any2opus
parent49c2ba9c4510bf6e1acd306687473bc8ba9ad8dd (diff)
downloadarchsetup-b10cba594db836c0747066addad48bda4d30cd02.tar.gz
archsetup-b10cba594db836c0747066addad48bda4d30cd02.zip
refactor: drop in-repo dotfiles/, move stow tooling to the dotfiles repo
Since the installer clones DOTFILES_REPO into ~/.dotfiles and stows from there, the in-repo dotfiles/ tree was dead weight. Nothing reads it at install time. I removed it (831 files) now that both machines are migrated. The Makefile's stow / restow / reset / unstow / import targets and the dotfile-script unit suites moved to the dotfiles repo. They sit alongside the scripts they manage and run standalone (cd ~/.dotfiles && make ...). This Makefile keeps the VM-integration targets and the installer-helper suite (safe-rm-rf). I updated CLAUDE.md and README.md so stow operations run from ~/.dotfiles, and the dotfile-management, theme, and unit-test sections point at the standalone repo. The README was already describing the old in-repo model from before the installer switched to cloning. This brings it in line.
Diffstat (limited to 'dotfiles/common/.local/bin/any2opus')
-rwxr-xr-xdotfiles/common/.local/bin/any2opus102
1 files changed, 0 insertions, 102 deletions
diff --git a/dotfiles/common/.local/bin/any2opus b/dotfiles/common/.local/bin/any2opus
deleted file mode 100755
index c5a7dbd..0000000
--- a/dotfiles/common/.local/bin/any2opus
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/env bash
-# Craig Jennings <c@cjennings.net>
-# convenience utility to convert all media files not in opus format in current directory to opus.
-# flags for recursive or specific filename supported.
-
-# Default values of arguments
-delete_after_conversion=false
-filename=""
-recursive=false
-
-# Usage info
-show_help() {
- cat << EOF
-Usage: ${0##*/} [-h] [-d] [-r] [-f FILE]
-Convert audio/video files to the Opus format.
-
- -h display this help and exit
- -d delete source files after conversion
- -r convert files recursively in current and subdirectories
- -f FILE convert a specific file.
-
-Note: The '-f' and '-r' options are mutually exclusive.
- If no file is given, works on all non-opus media files in the current directory.
- Requires the ffmpeg installation.
-EOF
-}
-
-# Check for the existence of ffmpeg
-if ! command -v ffmpeg &> /dev/null; then
- echo "Cannot proceed: ffmpeg not found on path."
- exit 1
-fi
-
-# Identify arguments; quit if invalid argument
-while getopts ":df:rh" opt; do
- case ${opt} in
- d)
- delete_after_conversion=true
- ;;
- f)
- filename=$OPTARG
- ;;
- r)
- recursive=true
- ;;
- h)
- show_help
- exit 0
- ;;
- \?)
- echo "Invalid option: -$OPTARG" >&2
- show_help
- exit 1
- ;;
- esac
-done
-
-# Display error and quit if incompatible arguments
-if [ "$recursive" = true ] && [ -n "$filename" ]
-then
- echo "The -f and -r options cannot be used together."
- show_help
- exit 1
-fi
-
-# Convert function checks mime-type and converts/deletes a single file
-convert() {
- f=$1
- # Check the mime-type of the file
- mime_type=$(file -b --mime-type "$f")
- # If the file is an audio or video file and not already in opus format then convert it to opus
- if [[ $mime_type == video/* || $mime_type == audio/* ]] && [[ $f != *.opus ]]; then
- ffmpeg -i "$f" "${f%.*}.opus"
- # If the '-d' option was specified, delete the original file after conversion
- if $delete_after_conversion; then
- rm "$f"
- fi
- fi
-}
-
-# Use above convert function based on user's intended set of files
-if [ "$recursive" = true ]
-then
- # convert all media files in current and child directories
- find . -type f -exec bash -c 'convert "$0"' {} \;
-elif [[ -n $filename ]]
-then
- # if filename is not empty, convert only this file
- convert $filename
-else
- # Convert all
- echo "All non-opus media files in the current directory will be converted. Originals are kept."
- read -p "Proceed? (Y/n) " -n 1 -r
- echo
- if [[ $REPLY =~ ^[Yy]$ ]]
- then
- # Iterate over each file in the directory and convert
- for f in *; do
- convert $f
- done
- fi
-fi