dotfiles

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.margiolis.net/dotfiles.git
Log | Files | Refs | README | LICENSE

commit 6d49fe2bd6a66726138b414d6e33363b4ab00885
parent 6cc7ac04270c2eac2ef89f81cf050dc3be5ae9be
Author: Christos Margiolis <christos@margiolis.net>
Date:   Sat, 20 Nov 2021 04:23:36 +0200

script fixes again

Diffstat:
Mfreebsd/rc.conf.desktop | 2+-
Dscripts/.local/bin/albumsplit | 38--------------------------------------
Ascripts/.local/bin/ausplit | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mscripts/.local/bin/extr | 3++-
Mscripts/.local/bin/irssi_torconf | 13++++++++-----
Mscripts/.local/bin/setscreens | 13++++++++++++-
Mscripts/.local/bin/tag | 109+++++++++++++++++++++++++++++++++++++++----------------------------------------
7 files changed, 151 insertions(+), 101 deletions(-)

diff --git a/freebsd/rc.conf.desktop b/freebsd/rc.conf.desktop @@ -6,7 +6,7 @@ dumpdev="AUTO" zfs_enable="YES" kld_list="linux nvidia nvidia modeset fuse sound snd_hda snd_ich snd_uadio" sndiod_enable="YES" -tor_enable="NO" +tor_enable="YES" jail_enable="NO" # bhyve shit diff --git a/scripts/.local/bin/albumsplit b/scripts/.local/bin/albumsplit @@ -1,38 +0,0 @@ -#!/bin/sh - -# Requires ffmpeg (audio splitting) and my `tag` wrapper script. -[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit -echo "Enter the album/book title:"; read -r albumtitle -echo "Enter the artist/author:"; read -r author -echo "Enter the publication year:"; read -r year - -inputaudio="$1" - -# Get a safe file name from the book. -escbook="$(echo "$albumtitle" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")" -mkdir -p "$escbook" || echo "Do you have write access in this directory?" && exit 1 - -# As long as the extension is in the tag script, it'll work. -ext="mp3" -#ext="${1#*.}" - -# Get the total number of tracks from the number of lines. -total="$(wc -l < "$2")" -while read -r x; do - end="$(echo "$x" | cut -d' ' -f1)" - [ -n "$start" ] && - echo "From $start to $end; $track $title" - file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext" - [ -n "$start" ] && echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn "$file" && - echo "Tagging \"$title\"..." && tag -a "$author" -A "$albumtitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file" - title="$(echo "$x" | cut -d' ' -f 2-)" - esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")" - track="$((track+1))" - start="$end" -done < "$2" - -# The last track must be done outside the loop. -echo "From $start to the end: $title" -file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext" -echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn "$file" && - echo "Tagging \"$title\"..." && tag -a "$author" -A "$albumtitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file" diff --git a/scripts/.local/bin/ausplit b/scripts/.local/bin/ausplit @@ -0,0 +1,74 @@ +#!/bin/sh + +# ffmpeg and my `tag` script required. +main() +{ + test ${#} -ne 2 && usage + + auin="${1}" + tfile="${2}" + total="$(wc -l < "${tfile}")" + # The extension must exist in `tag`. + ext="${1#*.}" + + xread "Album/book title: " altitle + xread "Artist/author: " author + xread "Publication year: " year + + namefmt="$(fmt_name "${altitle}")" + mkdir -p "${namefmt}" || exit 1 + + while read -r line; do + end="$(echo "${line}" | cut -d' ' -f1)" + test -n "${start}" && split_file + title="$(echo "${line}" | cut -d' ' -f 2-)" + titlefmt="$(fmt_name "${title}")" + track="$((track+1))" + start="${end}" + done < "${2}" + + # The last track must be done outside the loop. + split_file +} + +usage() +{ + echo "usage: ${0##*/} audio timecode_file" 1>&2 && exit 1 +} + +xread() +{ + printf "%s" "${1}" && read -r ${2} +} + +fmt_name() +{ + echo "${1}" | iconv -cf UTF-8 -t ASCII//TRANSLIT | + tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | + sed "s/-\+/-/g;s/\(^-\|-\$\)//g" +} + +split_file() +{ + echo "From ${start} to ${end}; ${track} ${title}" + echo "Splitting \"${title}\"..." + ofile="${namefmt}/$(printf "%.2d" "${track}")-${titlefmt}.${ext}" + ffmpeg \ + -nostdin -y -loglevel -8 \ + -i "${auin}" \ + -ss "${start}" \ + `test ${track} -eq ${total} || echo "-to ${end}"` \ + -vn -c copy \ + "${ofile}" && + echo "Tagging \"${title}\"..." && + tag \ + -a "${author}" \ + -A "${altitle}" \ + -t "${title}" \ + -n "${track}" \ + -N "${total}" \ + -d "${year}" \ + "${ofile}" +} + +main "${@}" diff --git a/scripts/.local/bin/extr b/scripts/.local/bin/extr @@ -1,6 +1,7 @@ #!/bin/sh -usage() { +usage() +{ echo "usage: ${0##*/} [-d dir] file" 1>&2 && exit 1 } diff --git a/scripts/.local/bin/irssi_torconf b/scripts/.local/bin/irssi_torconf @@ -1,13 +1,16 @@ #!/bin/sh -echo "mapaddress 10.40.40.40 ajnvpgl6prmkb7yktvue6im5wiedlz2w32uhcwaamdiecdrfpwwgnlqd.onion" >> /usr/local/etc/tor/torrc +echo "mapaddress 10.40.40.40 libera75jm6of4wxpxt4aynol3xjmbtxgfyjpu34ss4d7r7q2v5zrpyd.onion" >> /usr/local/etc/tor/torrc service tor restart mkdir -p ~/.irssi/certs && cd ~/.irssi/certs -openssl req -x509 -sha256 -new -newkey rsa:4096 -days 1000 -nodes -out freenode.pem -keyout freenode.pem +openssl req -x509 -sha256 -new -newkey rsa:4096 -days 1000 -nodes -out libera.crt -keyout libera.key +cat libera.crt libera.key > ~/.irssi/certs/libera.pem +chmod 600 libera.pem +rm libera.key libera.crt printf "/msg NickServ CERT ADD " -openssl x509 -in ~/.irssi/certs/freenode.pem -outform der | sha1 | cut -d' ' -f1 -echo "/network add -sasl_username crm -sasl_password crmsasl -sasl_mechanism EXTERNAL FreenodeTor" -echo "/server add -ssl -ssl_cert ~/.irssi/certs/freenode.pem -net FreenodeTor 10.40.40.40 6697" +openssl x509 -in ~/.irssi/certs/libera.pem -outform der | sha1 | cut -d' ' -f1 +echo "/network add -sasl_username cmrg -sasl_password cmrgsasl -sasl_mechanism EXTERNAL LiberaTor" +echo "/server add -ssl -ssl_cert ~/.irssi/certs/libera.pem -net LiberaTor 10.40.40.40 6697" echo "/ignore * CTCPS" echo "/save" echo "/quit" diff --git a/scripts/.local/bin/setscreens b/scripts/.local/bin/setscreens @@ -1,2 +1,13 @@ #!/bin/sh -xrandr --output DVI-I-0 --mode 1280x1024 --pos 1920x56 --rotate normal --output HDMI-0 --off --output DVI-D-0 --primary --mode 1920x1080 --pos 0x0 --rotate normal +xrandr \ + --output DVI-I-0 \ + --mode 1280x1024 \ + --pos 1920x56 \ + --rotate normal \ + --output HDMI-0 \ + --off \ + --output DVI-D-0 \ + --primary \ + --mode 1920x1080 \ + --pos 0x0 \ + --rotate normal diff --git a/scripts/.local/bin/tag b/scripts/.local/bin/tag @@ -1,64 +1,63 @@ #!/bin/sh -err() { echo "Usage: - tag [OPTIONS] file -Options: - -a: artist/author - -t: song/chapter title - -A: album/book title - -n: track/chapter number - -N: total number of tracks/chapters - -d: year of publication - -g: genre - -c: comment -You will be prompted for title, artist, album and track if not given." && exit 1 ;} +usage() +{ + echo "usage: ${0##*/} [-a artist] [-A album_title] [-c comment]" 1>&2 + echo " [-d year] [-g genre] [-n trackno] [-N totalno]" 1>&2 + echo " [-t song_title] file" 1>&2 + exit 1 +} -while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in - a) artist="${OPTARG}" ;; - t) title="${OPTARG}" ;; - A) album="${OPTARG}" ;; - n) track="${OPTARG}" ;; - N) total="${OPTARG}" ;; - d) date="${OPTARG}" ;; - g) genre="${OPTARG}" ;; - c) comment="${OPTARG}" ;; - f) file="${OPTARG}" ;; - *) printf "Invalid option: -%s\\n" "$OPTARG" && err ;; -esac done +xread() +{ + printf "%s" "${1}" && read -r ${2} +} +while getopts "a:t:A:n:N:d:g:c:f:" arg; do +case "${arg}" in + a) artist="${OPTARG}" ;; + t) title="${OPTARG}" ;; + A) album="${OPTARG}" ;; + n) track="${OPTARG}" ;; + N) total="${OPTARG}" ;; + d) date="${OPTARG}" ;; + g) genre="${OPTARG}" ;; + c) comment="${OPTARG}" ;; + f) file="${OPTARG}" ;; + *) usage ;; +esac +done shift $((OPTIND - 1)) -file="$1" +file="${1}" +test ! -f "${file}" && echo "${0##*/}: file not found" && usage + +test -z "${title}" && xread "Title: " title +test -z "${artist}" && xread "Artist: " artist +test -z "${album}" && xread "Album: " album +test -z "${track}" && xread "Track number: " track + +info="Title=${title} +Artist=${artist} +Album=${album} +Track=${track} +Total=${total} +Date=${date} +Genre=${genre} +Comment=${comment}" -[ ! -f "$file" ] && echo "Provide file to tag." && err -[ -z "$title" ] && echo "Enter a title." && read -r title -[ -z "$artist" ] && echo "Enter an artist." && read -r artist -[ -z "$album" ] && echo "Enter an album." && read -r album -[ -z "$track" ] && echo "Enter a track number." && read -r track +echo "${info}" -case "$file" in - *.mp3) echo "Title=$title -Artist=$artist -Album=$album -Track=$track -Total=$total -Date=$date -Genre=$genre -Comment=$comment - *.mp3) echo "Title=$title -Artist=$artist -Album=$album -Track=$track -Total=$total -Date=$date -Genre=$genre -Comment=$comment ;; - *.mp3) eyeD3 -Q --remove-all \ - -a "$artist" \ - -A "$album" \ - -t "$title" \ - -n "$track" \ - -N "$total" \ - -Y "$date" "$file" ;; - *) echo "File type not implemented yet." ;; +case "${file}" in + *.ogg) echo "${info}" | vorbiscomment -w "${file}" ;; + *.opus) echo "${info}" | opustags -i -S "${file}" ;; + *.mp3) eyeD3 -Q --remove-all \ + -a "${artist}" \ + -A "${album}" \ + -t "${title}" \ + -n "${track}" \ + -N "${total}" \ + -Y "${date}" \ + "${file}" ;; + *) echo "${0##*/}: file type not implemented yet" ;; esac