Git Repos / dotfiles / commit b111cb6
Commit: b111cb67e9084664d1d4f52be3398c14b179c806
Parent: 6a60919816171e613a5a45942e2f78d7e6295416
Author: Cameron Vanderzanden, 2022-01-30 18:15
Committer: Cameron Vanderzanden, 2022-01-30 18:15
Commit Message
Import scs4tool and tag_audio, change conky scale Add scs4tool.sh and tag_audio.sh. The former prepares tracks for playback on the Stanton SCS.4DJ, the latter is a frontend to the tagging programs metaflac and mid3v2. Also change the loadavg threshholds in my conky script a little bit.
Change List
? | File | Add | Del |
---|---|---|---|
M | bin/aliases.sh | +1 | |
A | bin/scs4tool.sh | +284 | |
A | bin/tag_audio.sh | +464 | |
M | config/conky/conky.conf | +2 | -2 |
Diff bin/aliases.sh
diff --git a/bin/aliases.sh b/bin/aliases.sh
index 87edc70..d461926 100644
--- a/bin/aliases.sh
+++ b/bin/aliases.sh
@@ -55,6 +55,7 @@ alias mplayer="/usr/local/bin/mpv --quiet"
alias mpt="$HOME/bin/mpt_single.sh"
alias scs="$HOME/bin/scs4tool.sh"
alias sss="$HOME/bin/sox_spectrogram.sh"
+alias tag_audio="$HOME/bin/tag_audio.sh"
alias tag_bpm="$HOME/bin/tag_bpm.sh"
alias tag_cover="$HOME/bin/tag_cover.sh"
alias tag_key="$HOME/bin/tag_key.sh"
Return to the top of this page or return to the overview of this repo.
Diff bin/scs4tool.sh
diff --git a/bin/scs4tool.sh b/bin/scs4tool.sh
new file mode 100755
index 0000000..4d971f7
--- /dev/null
+++ b/bin/scs4tool.sh
@@ -0,0 +1,284 @@
+#!/bin/sh
+#
+# Copyright (c) 2015-2022, Cameron Vanderzanden. Available under the
+# terms of the 2-clause BSD license. Please see the file "LICENSE" in
+# the root dir of this repository for more information.
+#
+#- scs4tool.sh 2015/03/28 cev
+## Usage: scs4tool.sh [-3hHlv] [-a dir] [-d dir] [-r dir]
+##
+## Manage a file tree for use on the Stanton SCS.4DJ music player. Performs
+## a function similar to Stanton's Quickgrid software.
+##
+## This script requires a working installation of wine and "djanalyze.exe",
+## which can be found in the latest version of Stanton Quickgrid for Windows.
+## This script also requires ffmpeg, flac/libFlac, and sox.
+##
+## Top level options:
+## -3 Convert flac files to mp3 before copying.
+## -a Add a directory to the destination.
+## -d Destination directory.
+## -h Show help.
+## -H Print the "hashes.dat" hashtable.
+## -l View output log when finished.
+## -r Remove a directory at the destination.
+## -V Print version info.
+##
+#
+
+if [ -x $HOME/bin/cev_print.sh ]; then
+ . $HOME/bin/cev_print.sh
+else
+ print_help() { grep "^## " "$0" | cut -c 4-; }
+ print_version() { grep "^#- " "$0" | cut -c 4-; }
+fi
+
+self="${0##*/}"
+prefix="${SCS4_PREFIX:-/y}"
+wine="/usr/local/bin/wine"
+database="${SCS4_DATABASE_PREFIX:-${prefix}/SCS.4DJ_Database}"
+hashtable="${SCS4_HASHTABLE_PATH:-${database}/hashes.dat}"
+tmpdir=""
+logfile=""
+viewlog=""
+flactomp3="N"
+flacapplyrg="Y"
+
+[ -z "$WINEPREFIX" ] && WINEPREFIX="/z/juarez/SCS4_DjAnalyze"
+[ -z "$WINEDEBUG" ] && WINEDEBUG="-all"
+export WINEPREFIX WINEDEBUG
+export WINEARCH=win32
+djanalyze="/z/juarez/SCS4_DjAnalyze/djanalyze.exe"
+
+cleanup() {
+ [ -n "$logfile" -a -f "$logfile" ] && rm $logfile
+ [ -n "$tmpdir" -a -d "$tmpdir" ] && rmdir $tmpdir
+}
+
+close() {
+ code=$1 && shift
+ [ $code -eq 1 ] && printf "%b%s:%b \"%s\" %bnot found.%b\n" \
+ "$_self" "$self" "$_error" "$@" "$_norm" "$_clear"
+ [ -n "$viewlog" ] && $PAGER $logfile
+ exit $code
+}
+
+# https://stackoverflow.com/questions/642464/convert-unix-path-to-dos-path
+unix_to_dos_path() { printf 'z:%s\n' "$@" | sed 's/\//\\/g'; }
+
+change_prefix() {
+ prefix="$@"
+ database="${prefix}/SCS.4DJ_Database"
+ hashtable="${database}/hashes.dat"
+}
+
+add_analysis() {
+ dosfile="$(unix_to_dos_path "$@")"
+ dostmpdir="$(unix_to_dos_path "$tmpdir")"
+ printf "wine %s %s %s %s\n" \
+ "$djanalyze" "$dosfile" "$dostmpdir" "$hash" 1>>$logfile 2>&1
+ $wine "$djanalyze" "$dosfile" "$dostmpdir" "$hash" 1>>$logfile 2>&1
+ # djanalyze.exe creates a folder named 'SCS.8DJ_Database' by default.
+ # wildcard our way into it.
+ cp -vr $tmpdir/*/analysis/* "${database}/analysis/" 2>&1 1>>$logfile
+ rm -rfv $tmpdir/SCS.?DJ* 2>&1 1>>$logfile
+}
+
+add_hashtable_entry() {
+ # five fields, seperated by tab:
+ # filename (unescaped)\t MD5 hash\t st_atime+'000'\t st_size\t 0
+ name="${@##*${prefix}}"
+ printf "%s\t%s\t%s\t%s\t%s\n" \
+ "$name" "$hash" "${st_atime}000" "$st_size" "0" >>$tmpdir/hashes.dat
+ cat $tmpdir/hashes.dat >> "$hashtable"
+ rm $tmpdir/hashes.dat
+}
+
+add_file_end() {
+ # GNU md5sum, FreeBSD/OSX md5 -q, NetBSD md5 (two field output)
+ hash="$(md5 -q "$@")"
+ # FreeBSD/NetBSD/OSX stat -s, GNU stat (different format)
+ eval $(stat -s "$@")
+ add_hashtable_entry "$@"
+ add_analysis "$@"
+}
+
+add_file_convertflactomp3() {
+ bl="$(basename "$@")"
+ printf "%b%s:%b converting %b%.52s...%b\n" \
+ "$_self" "$self" "$_norm" "$_high" "$bl" "$_clear"
+ tl="$(basename "$@" flac)"
+ fl="$(printf "%s\n" "$@" | sed "s/\.flac/\.mp3/")"
+ flac_to_mp3.sh -r -o "$tmpdir/${tl}mp3" "$l"
+ # TODO error checking
+ printf "%b%s:%b adding %b%.56s...%b\n" \
+ "$_self" "$self" "$_norm" "$_high" "${tl}mp3" "$_clear"
+ cp -pv "$tmpdir/${tl}mp3" "$prefix/$fl" 2>/dev/null 1>>$logfile
+ add_file_end "$prefix/$fl"
+ [ -f "$tmpdir/${tl}mp3" ] && \
+ rm -v "$tmpdir/${tl}mp3" 2>/dev/null 1>>$logfile
+}
+
+add_file_flacresample() {
+ pat="bits_per_sample\|sample_rate"
+ # TODO error checking; maybe check filename and make sure it's a .wav ?
+ # TODO probably shouldn't be using eval here
+ eval $(ffprobe -v quiet -show_streams "$@" | /usr/bin/grep "$pat")
+ if [ "$sample_rate" -ne "44100" -o "$bits_per_sample" -ne "16" ]; then
+ if [ "$sample_rate" -eq "44100" ]; then
+ printf "%b%s:%b changing bit depth...%b\n" \
+ "$_self" "$self" "$_norm" "$_clear"
+ sox "$@" -b 16 "$@.rs.wav" 2>/dev/null 1>>$logfile
+ else
+ printf "%b%s:%b resampling to 44.1khz 16bps...%b\n" \
+ "$_self" "$self" "$_norm" "$_clear"
+ sox "$@" -b 16 "$@.rs.wav" rate -v 44.1k 2>/dev/null 1>>$logfile
+ fi
+ mv -v "$@.rs.wav" "$@" 2>/dev/null 1>>$logfile
+ fi
+ unset sample_rate && unset bits_per_sample
+}
+
+add_file_applyflacreplaygain() {
+ bl="$(basename "$@")"
+ # reencode flac files and apply replaygain; written 2020/11/03
+ tl="$(basename "$@" flac)"
+ printf "%b%s:%b adding %b%.56s...%b\n" \
+ "$_self" "$self" "$_norm" "$_high" "$bl" "$_clear"
+ flac --apply-replaygain-which-is-not-lossless=-2tLn1 \
+ --totally-silent -d -o "$tmpdir/${tl}wav" "$@"
+ add_file_flacresample "$tmpdir/${tl}wav"
+ flac --totally-silent -o "$prefix/$@" "$tmpdir/${tl}wav"
+ metaflac --no-utf8-convert \
+ --export-tags-to="$tmpdir/${tl}tags" "$@"
+ sed -i '' '/REPLAY/d' "$tmpdir/${tl}tags"
+ metaflac --remove-all-tags \
+ --import-tags-from="$tmpdir/${tl}tags" "$prefix/$@"
+ # TODO: transfer cover
+ [ -f "$tmpdir/${tl}wav" ] && rm -v "$tmpdir/${tl}wav" 2>/dev/null 1>>$logfile
+ [ -f "$tmpdir/${tl}tags" ] && rm -v "$tmpdir/${tl}tags" 2>/dev/null 1>>$logfile
+ add_file_end "$prefix/$@"
+}
+
+add_file() {
+ [ ! -e "$@" ] && close 1 "$@"
+ find "$@" -print | while read l; do
+ if [ -d "$l" ]; then
+ printf "%b%s:%b creating %b%.54s...%b\n" \
+ "$_self" "$self" "$_norm" "$_high" "$l" "$_clear"
+ mkdir -p "$prefix/$l" 2>&1 1>>$logfile
+ else
+ bl="$(basename "$l")"
+ if [ "${bl##*.}" = "flac" -a "$flactomp3" = "Y" ]; then
+ add_file_convertflactomp3 "$l"
+ elif [ "${bl##*.}" = "flac" -a "$flacapplyrg" = "Y" ]; then
+ add_file_applyflacreplaygain "$l"
+ elif [ "${bl##*.}" = "flac" -o "${bl##*.}" = "mp3" ]; then
+ printf "%b%s:%b adding %b%.56s...%b\n" \
+ "$_self" "$self" "$_norm" "$_high" "$bl" "$_clear"
+ cp -pv "$l" "$prefix/$l" 2>/dev/null 1>>$logfile
+ add_file_end "$prefix/$l"
+ fi
+ fi
+ done
+}
+
+cmd_add() {
+ [ ! -d "$database" ] && mkdir -p "$database"
+ [ ! -d "$database/analysis" ] && mkdir -p "$database/analysis"
+ [ ! -e "$hashtable" ] && printf "Hash Helper v1\n" > "$hashtable" # heh
+ # a trailing "/" will mess up hashtable.dat. The SCS.4DJ will not match
+ # "/dir//file" and "/dir/file".
+ if [ "$(printf "%s\n" "$@" | rev | cut -c 1)" = "/" ]; then
+ f="${@%?}"
+ else
+ f="$@"
+ fi
+ tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/${self}.XXXXXXXX)
+ logfile="$tmpdir/log" && touch $logfile
+ trap cleanup EXIT
+ add_file "$f"
+ close 0
+}
+
+# delete analysis files based on md5sum
+del_analysis() {
+ # first two characters of hash remaining characters of hash
+ h1="$(printf "%s\n" "$@" | cut -c 1-2)"; h2="${@#??*}"
+ if [ -d $database/analysis/$h1 ]; then
+ rm -v $database/analysis/$h1/$h2.sar 2>&1 1>>$logfile
+ rm -v $database/analysis/$h1/$h2.sek 2>&1 1>>$logfile
+ rm -v $database/analysis/$h1/$h2.wfv 2>&1 1>>$logfile
+ fi
+}
+
+# delete hashtable entry based on md5sum
+del_hashtable_entry() {
+ sed "/$@/d" $hashtable > $tmpdir/hashes.dat \
+ && cp -v $tmpdir/hashes.dat $hashtable 2>&1 1>>$logfile \
+ && rm $tmpdir/hashes.dat
+}
+
+del_file() {
+ [ ! -e "$@" ] && close 1 "$@"
+ find "$@" -d -print | while read l; do
+ if [ -d "$l" ]; then
+ printf "%b%s:%b removing %b%.54s...%b\n" \
+ "$_self" "$self" "$_norm" "$_high" "${l##${prefix}/}" "$_clear"
+ rm -dv "$l" 2>&1 1>>$logfile
+ else
+ printf "%b%s:%b removing %b%.54s...%b\n" \
+ "$_self" "$self" "$_norm" "$_high" "${l##${prefix}/}" "$_clear"
+ hash="$(md5 -q "$l")"
+ rm -v "$l" 2>&1 1>>$logfile
+ del_analysis "$hash"
+ [ -f "$hashtable" ] && del_hashtable_entry "$hash"
+ fi
+ done
+}
+
+# delete file, delete related analysis files, delete any hashes.dat entries.
+cmd_del() {
+ f="$prefix/$@"
+ tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/${self}.XXXXXXXX)
+ logfile="$tmpdir/log" && touch $logfile
+ trap cleanup EXIT
+ del_file "$f"
+ close 0
+}
+
+# TODO this is left hanging; hook this back into the option block or delete it
+cmd_clear() {
+ [ "$1" = "hash" ] && rm -v "$hashtable"
+}
+
+cmd_hashtable() {
+ if [ -f "$hashtable" ]; then
+ cat $hashtable;
+ else
+ printf "%b%s:%b no hashtable in %s prefix.%b\n" \
+ "$_self" "$self" "$_norm" "${prefix}" "$_clear"
+ exit 1
+ fi
+}
+
+cmd_list() { ls "$prefix/$@"; }
+
+# top level options
+while getopts "3a:d:hHlr:V?" option; do
+ case $option in
+ 3) flactomp3="Y" ;;
+ a) cmd_add "$OPTARG" && exit 0;;
+ d) change_prefix "$OPTARG" ;;
+ h) print_help && exit 0 ;;
+ H) cmd_hashtable && exit 0 ;;
+ l) viewlog="Y" ;;
+ r) cmd_del "$OPTARG" && exit 0 ;;
+ V) print_version && exit 0 ;;
+ "?") print_help && exit 0 ;;
+ esac
+ shift $((OPTIND - 1))
+done
+
+cmd_list "$@" && exit 0
+
Return to the top of this page or return to the overview of this repo.
Diff bin/tag_audio.sh
diff --git a/bin/tag_audio.sh b/bin/tag_audio.sh
new file mode 100755
index 0000000..495d927
--- /dev/null
+++ b/bin/tag_audio.sh
@@ -0,0 +1,464 @@
+#!/bin/sh
+#
+# Copyright (c) 2016-2022, Cameron Vanderzanden. Available under the
+# terms of the 2-clause BSD license. Please see the file "LICENSE" in
+# the root dir of this repository for more information.
+#
+#- tag_audio.sh 2016/11/04 cev
+#- tag_audio.sh 2021/07/23 cev
+## Usage: tag_audio.sh [-3fhpV] [-e tag] [-k tag] [-v value] <file>
+##
+## Edit the metadata "tags" of an audio file. Supports flac and mp3 files
+## via metaflac and mid3v2, respectively. Recognizes the following tags:
+## artist, tracktitle, albumtitle, date, genre, composer, performer, bpm,
+## initialkey, albumartist, tracknumber, tracktotal, discnumber, disctotal,
+## comment.
+##
+## -3 Operate on mp3 files
+## -e Edit <tag> of <file>
+## -f Operate on flac files
+## -h Show help
+## -k Edit <tag> of <file>. Synonymous with -e .
+## -p List recognized tags and their values as stored in <file>.
+## -v New <value> for <tag> when -e is specified. Non-interactive.
+## -V Print version info
+#
+
+[ -x $HOME/bin/cev_print.sh ] && . $HOME/bin/cev_print.sh
+
+self="${0##*'/'}"
+filetype=""
+fileext=""
+do_tag_print=""
+do_tag_edit=""
+do_tag_new_value=""
+
+# known tags / tags we care about
+artist=""
+tracktitle=""
+albumtitle=""
+year=""
+genre=""
+composer=""
+performer=""
+albumartist=""
+tracknumber=""
+tracktotal=""
+discnumber=""
+disctotal=""
+comment=""
+bpm=""
+initialkey=""
+rgrl=""
+rgag=""
+rgap=""
+rgtg=""
+rgtp=""
+
+cleanup() {
+ if [ "$ftags" -a -r "$ftags" ]; then rm "$ftags"; fi
+ if [ "$m3tags" -a -r "$m3tags" ]; then rm "$m3tags"; fi
+ if [ "$dtags" -a -r "$dtags" ]; then rm "$dtags"; fi
+}
+
+die_filenotfound() {
+ print_filenotfound "$*"
+ exit 1
+}
+
+die_directoryfiletype() {
+ print_self
+ printf "%b must specify a filetype " "$_error" >&2
+ printf "to operate on a directory!%b\n" "$_clear" >&2
+ exit 1
+}
+
+die_nofile() {
+ print_nofile
+ exit 1
+}
+
+die_unknownfiletype() {
+ shortname="$(basename "$*")"
+ print_unknownfiletype "$shortname"
+ exit 1
+}
+
+is_flac() { test_mimetype.sh -t "audio/flac" "$@" ; }
+
+is_mp3() {
+ if test_mimetype.sh -t "audio/mpeg" "$@"; then
+ return 0
+ else
+ # test file extension
+ tmpname="$(basename "$@" ".mp3")"
+ tmpname2="${@##$tmpname}"
+ if [ "$tmpname2" = ".mp3" ]; then
+ return 0
+ fi
+ fi
+ return 1
+}
+
+flac_readtags() {
+ local flacname="$*"
+ ftags=$(mktemp ${TMPDIR:-/tmp}/${self}.ftags.XXXXXXXX)
+ metaflac --no-utf8-convert --export-tags-to="$ftags" "$flacname"
+ while read l; do
+ k=$(printf "%s" "$l" | cut -d '=' -f 1)
+ # convert ':' into '_' because ':' will mess up mp3 comments.
+ # shows up most often in URLs; example: 'visit http://'... comments
+ v=$(printf "%s" "$l" | cut -d '=' -f 2- | tr ':' '_')
+ case $k in
+ album|ALBUM) albumtitle="$v" ;;
+ albumartist|ALBUMARTIST) albumartist="$v" ;;
+ artist|ARTIST) artist="$v" ;;
+ comment|COMMENT) comment="$v" ;;
+ bpm|BPM) bpm="$v" ;;
+ date|DATE) year="$v" ;;
+ genre|GENRE) genre="$v" ;;
+ composer|COMPOSER) composer="$v" ;;
+ performer|PERFORMER) performer="$v" ;;
+ initialkey|INITIALKEY) initialkey="$v" ;;
+ title|TITLE) tracktitle="$v" ;;
+ tracknumber|TRACKNUMBER) tracknumber="$v" ;;
+ tracktotal|TRACKTOTAL) tracktotal="$v" ;;
+ discnumber|DISCNUMBER) discnumber="$v" ;;
+ disctotal|DISCTOTAL) disctotal="$v" ;;
+ replaygain_reference_loudness|REPLAYGAIN_REFERENCE_LOUDNESS)
+ rgrl="$v"
+ ;;
+ replaygain_album_gain|REPLAYGAIN_ALBUM_GAIN) rgag="$v" ;;
+ replaygain_album_peak|REPLAYGAIN_ALBUM_PEAK) rgap="$v" ;;
+ replaygain_track_gain|REPLAYGAIN_TRACK_GAIN) rgtg="$v" ;;
+ replaygain_track_peak|REPLAYGAIN_TRACK_PEAK) rgtp="$v" ;;
+ esac
+ unset k v
+ done < $ftags
+ rm $ftags
+}
+
+flac_setartist() {
+ metaflac --remove-tag=ARTIST --set-tag="ARTIST=$artist" "$*"
+}
+
+flac_settracktitle() {
+ metaflac --remove-tag=TITLE --set-tag="TITLE=$tracktitle" "$*"
+}
+
+flac_setalbumtitle() {
+ metaflac --remove-tag=ALBUM --set-tag="ALBUM=$albumtitle" "$*"
+}
+
+flac_setyear() {
+ metaflac --remove-tag=DATE --set-tag="DATE=$year" "$*"
+}
+
+flac_setgenre() {
+ metaflac --remove-tag=GENRE --set-tag="GENRE=$genre" "$*"
+}
+
+flac_setcomposer() {
+ metaflac --remove-tag=COMPOSER --set-tag="COMPOSER=$composer" "$*"
+}
+
+flac_setperformer() {
+ metaflac --remove-tag=PERFORMER --set-tag="PERFORMER=$performer" "$*"
+}
+
+flac_setbpm() {
+ metaflac --remove-tag=BPM --set-tag="BPM=$bpm" "$*"
+}
+
+flac_setinitialkey() {
+ metaflac --remove-tag=INITIALKEY --set-tag="INITIALKEY=$initialkey" "$*"
+}
+
+flac_setalbumartist() {
+ metaflac --remove-tag=ALBUMARTIST --set-tag="ALBUMARTIST=$albumartist" "$*"
+}
+
+flac_settracknumber() {
+ metaflac --remove-tag=TRACKNUMBER --set-tag="TRACKNUMBER=$tracknumber" "$*"
+}
+
+flac_settracktotal() {
+ metaflac --remove-tag=TRACKTOTAL --set-tag="TRACKTOTAL=$tracktotal" "$*"
+}
+
+flac_setdiscnumber() {
+ metaflac --remove-tag=DISCNUMBER --set-tag="DISCNUMBER=$discnumber" "$*"
+}
+
+flac_setdisctotal() {
+ metaflac --remove-tag=DISCTOTAL --set-tag="DISCTOTAL=$disctotal" "$*"
+}
+
+flac_setcomment() {
+ metaflac --remove-tag=COMMENT --set-tag="COMMENT=$comment" "$*"
+}
+
+mp3_readtags() {
+ local mp3name="$*"
+ m3tags=$(mktemp ${TMPDIR:-/tmp}/${self}.m3tags.XXXXXXXX)
+ mid3v2 --list "$mp3name" > $m3tags
+ while read l; do
+ k=$(printf "%s" "$l" | cut -d '=' -f 1)
+ # convert ':' into '_' because ':' will mess up mp3 comments.
+ # shows up most often in URLs; example: 'visit http://'... comments
+ v=$(printf "%s" "$l" | cut -d '=' -f 2- | tr ':' '_')
+ case $k in
+ TALB) albumtitle="$v" ;;
+ TPE2) albumartist="$v" ;;
+ TPE1) artist="$v" ;;
+ COMM) comment="$v" ;;
+ TBPM) bpm="$v" ;;
+ TYER) year="$v" ;;
+ TDRC) year="$v" ;;
+ TCON) genre="$v" ;;
+ TCOM) composer="$v" ;;
+ TOPE) performer="$v" ;;
+ TKEY) initialkey="$v" ;;
+ TIT2) tracktitle="$v" ;;
+ TRCK)
+ tracknumber="$(printf "%s\n" "$v" | cut -d'/' -f 1)"
+ tracktotal="$(printf "%s\n" "$v" | cut -d'/' -f 2)"
+ ;;
+ TPOS)
+ discnumber="$(printf "%s\n" "$v" | cut -d'/' -f 1)"
+ disctotal="$(printf "%s\n" "$v" | cut -d'/' -f 2)"
+ ;;
+ TXXX)
+ k2="$(printf "%s\n" "$v" | cut -d'=' -f 1)"
+ v2="$(printf "%s\n" "$v" | cut -d'=' -f 2-)"
+ case $k2 in
+ replaygain_reference_loudness) rgrl="$v2" ;;
+ replaygain_album_gain) rgag="$v2" ;;
+ replaygain_album_peak) rgap="$v2" ;;
+ replaygain_track_gain) rgtg="$v2" ;;
+ replaygain_track_peak) rgtp="$v2" ;;
+ esac
+ unset k2 v2
+ ;;
+ esac
+ unset k v
+ done < $m3tags
+ rm $m3tags
+}
+
+mp3_setartist() {
+ mid3v2 --artist="$artist" "$*"
+}
+
+mp3_settracktitle() {
+ mid3v2 --song="$tracktitle" "$*"
+}
+
+mp3_setalbumtitle() {
+ mid3v2 --album="$albumtitle" "$*"
+}
+
+mp3_setyear() {
+ mid3v2 --year="$year" "$*"
+}
+
+mp3_setgenre() {
+ mid3v2 --genre="$genre" "$*"
+}
+
+mp3_setcomposer() {
+ mid3v2 --TCOM "$composer" "$*"
+}
+
+mp3_setperformer() {
+ mid3v2 --TOPE "$performer" "$*"
+}
+
+mp3_setbpm() {
+ mid3v2 --TBPM "$bpm" "$*"
+}
+
+mp3_setinitialkey() {
+ mid3v2 --TKEY "$initialkey" "$*"
+}
+
+mp3_setalbumartist() {
+ mid3v2 --TPE2 "$albumartist" "$*"
+}
+
+mp3_settracknumber() {
+ mid3v2 --track="$tracknumber/$tracktotal" "$*"
+}
+
+mp3_settracktotal() {
+ mid3v2 --track="$tracknumber/$tracktotal" "$*"
+}
+
+mp3_setdiscnumber() {
+ mid3v2 --TPOS="$discnumber/$disctotal" "$*"
+}
+
+mp3_setdisctotal() {
+ mid3v2 --TPOS="$discnumber/$disctotal" "$*"
+}
+
+mp3_setcomment() {
+ mid3v2 -c "$comment" "$*"
+}
+
+tag_edit_change_value() {
+ local tag=$1
+ if [ -z "$do_tag_new_value" ]; then
+ eval val="\"\$${tag}\""
+ print_self
+ printf "%bcurrent %s: %b%s" "$_norm" "$tag" "$_high" "$val"
+ printf "%b\n" "$_clear"
+ print_self
+ printf "%benter new %s value:%b " "$_norm" "$tag" "$_clear"
+ eval read \$tag
+ eval val="\"\$${tag}\""
+ print_self
+ printf "%bcurrent %s: %b%s" "$_norm" "$tag" "$_high" "$val"
+ printf "%b\n" "$_clear"
+ else
+ eval $tag="\"\$do_tag_new_value\""
+ eval val="\"\$${tag}\""
+ print_self
+ printf "%b%s changed to: %s%b\n" "$_norm" "$tag" "$val" "$_clear"
+ fi
+}
+
+tag_edit() {
+ arg=$1 && shift
+ local editname="$*"
+ local tag=""
+ case $arg in
+ artist|ARTIST) tag=artist ;;
+ tracktitle|TRACKTITLE) tag=tracktitle ;;
+ albumtitle|ALBUMTITLE) tag=albumtitle ;;
+ date|DATE|year|YEAR) tag=year ;;
+ genre|GENRE) tag=genre ;;
+ composer|COMPOSER) tag=composer ;;
+ performer|PERFORMER) tag=performer ;;
+ bpm|BPM) tag=bpm ;;
+ key|KEY|initialkey|INITIALKEY) tag=initialkey ;;
+ albumartist|ALBUMARTIST) tag=albumartist ;;
+ tracknumber|TRACKNUMBER) tag=tracknumber ;;
+ tracktotal|TRACKTOTAL) tag=tracktotal ;;
+ discnumber|DISCNUMBER) tag=discnumber ;;
+ disctotal|DISCTOTAL) tag=disctotal ;;
+ comment|COMMENT) tag=comment ;;
+ esac
+ eval set_func=\${filetype}_set\${tag}
+ tag_edit_change_value $tag
+ $set_func "$editname"
+ unset tag
+}
+
+tag_print() {
+ # variable name:display text:display text field width:string output length
+ displaytags="artist:artist name:21:43
+tracktitle:track title:21:43
+albumtitle:album title:21:43
+year:date:21:43
+genre:genre:21:43
+composer:composer:21:43
+performer:performer:21:43
+bpm:bpm:21:43
+initialkey:key:21:43
+albumartist:album artist:21:43
+tracknumber:track number:21:43
+tracktotal:total tracks:21:43
+discnumber:disc number:21:43
+disctotal:total discs:21:43
+comment:comment:21:43
+rgag:replaygain_album_gain:21:43
+rgap:replaygain_album_peak:21:43
+rgtg:replaygain_track_gain:21:43
+rgtp:replaygain_track_peak:21:43
+rgrl:replaygain_reference_loudness:21:35"
+ dtags=$(mktemp ${TMPDIR:-/tmp}/${self}.dtags.XXXXXXXX)
+ printf "%s\n" "$displaytags" > "$dtags"
+
+ zIFS="$IFS" && IFS=":"
+ while read var pn pnfw prec; do
+ eval val="\"\$${var}\""
+ if [ "$val" ]; then
+ print_self
+ printf "%b%${pnfw}s:%b " "$_norm" "$pn" "$_high"
+ printf "%.${prec}s%b\n" "$val" "$_clear"
+ else
+ missing_tags="${missing_tags}${var} "
+ fi
+ done < "$dtags"
+ rm $dtags
+ IFS="$zIFS" && unset zIFS
+
+ if [ "$missing_tags" ]; then
+ print_self
+ printf "%bmissing%b %s%b\n" "$_norm" "$_error" "$missing_tags" "$_clear"
+ fi
+}
+
+tag_read() {
+ case $filetype in
+ flac) flac_readtags "$*" ;;
+ mp3) mp3_readtags "$*" ;;
+ esac
+}
+
+do_file() {
+ [ ! -f "$*" ] && die_filenotfound "$*"
+
+ if [ "$filetype" ]; then
+ # TODO FIXME
+ print_self
+ printf "%bnoop%b\n" "$_norm" "$_clear"
+ elif is_flac "$*"; then
+ filetype="flac" && fileext="flac"
+ elif is_mp3 "$*"; then
+ filetype="mp3" && fileext="mp3"
+ else
+ die_unknownfiletype "$*"
+ fi
+
+ print_self
+ printf "%bfile: %b%s%b\n" "$_norm" "$_high" "$*" "$_clear"
+
+ tag_read "$*"
+ [ "$do_tag_print" ] && tag_print "$*"
+ [ "$do_tag_edit" ] && tag_edit "$do_tag_edit" "$*"
+}
+
+while getopts "3e:fhk:pv:V?" option; do
+ case $option in
+ 3) filetype="mp3" && fileext="mp3" ;;
+ e) do_tag_edit="$OPTARG" ;;
+ f) filetype="flac" && fileext="flac" ;;
+ h) print_help && exit ;;
+ k) do_tag_edit="$OPTARG" ;;
+ p) do_tag_print="Y" ;;
+ v) do_tag_new_value="$OPTARG" ;;
+ V) print_version && exit ;;
+ "?") print_help && exit ;;
+ esac
+ shift $((OPTIND - 1))
+done
+
+[ $# -lt 1 ] && die_nofile
+[ ! -e "$*" ] && die_filenotfound "$*"
+
+trap cleanup EXIT
+
+if [ -d "$*" ]; then
+ [ -z "$fileext" ] && die_directoryfiletype
+
+ for f in "$*"/*.$fileext; do
+ printf "%s\n" "$f"
+ do_file "$f"
+ done
+else
+ do_file "$*"
+fi
+
+exit 0
Return to the top of this page or return to the overview of this repo.
Diff config/conky/conky.conf
diff --git a/config/conky/conky.conf b/config/conky/conky.conf
index d4f37e7..4115a10 100644
--- a/config/conky/conky.conf
+++ b/config/conky/conky.conf
@@ -39,9 +39,9 @@ conky.config = {
}
conky.text = [[
-${if_match "${loadavg 1}" > "2.0"}\
+${if_match "${loadavg 1}" > "3.0"}\
${lua_parse imagepath s3}\
-${else}${if_match "${loadavg 1}" > "1.0"}\
+${else}${if_match "${loadavg 1}" > "1.5"}\
${lua_parse imagepath s2}\
${else}\
${lua_parse imagepath s1}\
Return to the top of this page or return to the overview of this repo.