commit 899fc24ed0ee44572fcf5d3ce5ca30bf7746d602
parent f51d5566ae6515ce1eeb0748bd2da7c2a177a33e
Author: pyratebeard <root@pyratebeard.net>
Date: Mon, 22 May 2023 17:00:17 +0100
ara
Diffstat:
M | entry/ara.md | | | 51 | ++++++++++++++++++++++++++++++++++++++++++++++++++- |
1 file changed, 50 insertions(+), 1 deletion(-)
diff --git a/entry/ara.md b/entry/ara.md
@@ -1,5 +1,54 @@
It is Monday and I am in one of those rare moods when I can't decide what music to listen to while I work.
-This happens every so often but I can usually find something on Bandcamp or from my digital collection, but today I can't settle on anything. Metal, synth, Spanish guitar, even chiptune! Nothing is quenching my ear thirst.
+This happens every so often but I can usually find something on Bandcamp or from my digital collection, but today I can't settle on anything. Metal, synth, Spanish guitar, even chiptune; nothing is quenching my ear thirst.
+In a moment of desperation (or madness?), I threw together a script to pick an album at random from my digital library and add it to [cmus](TK){target="_blank" rel="noreferrer"}. Behold, `ara`
+```
+#!/bin/bash
+# ██████ ██████ ██████
+# ░░░░░░██ ░░██░░█ ░░░░░░██
+# ███████ ░██ ░ ███████
+# ██░░░░██ ░██ ██░░░░██
+# ░░████████░███ ░░████████
+# ░░░░░░░░ ░░░ ░░░░░░░░
+# a d d r a n d o m a l b u m
+# default to adding one album
+[ $# -eq 0 ] && num=1 || num=$1
+
+# set path to music and read into array
+library_dir="$HOME/lib/music/"
+readarray -d '' library < <(find ${library_dir} -mindepth 2 -maxdepth 2 -type d -print0)
+
+# get some randomness
+RANDOM=$$$(date +%s)
+
+# add _n_ random albums to cmus library
+for n in $(seq 1 ${num}) ; do
+ random_album=${library[$RANDOM % ${#library[@]}]}
+ cmus-remote -C "add ${random_album}"
+done
+```
+
+The script is simple enough. Find albums in my music library path, add them to an array, then select one or more (if specified) albums and add them to my cmus library using `cmus-remote`.
+
+The `find` command uses `-mindepth 2 -maxdepth 2` on the basis that my music library directory is organised as
+```
+artist
+└── album
+```
+
+To use I incant
+```
+ara
+```
+
+Or to add more than one random album I can incant
+```
+ara 8
+```
+
+You can view the script on my [git server](TK){target="_blank" rel="noreferrer"} or incant
+```
+curl -L git.pyratebeard.net/pub/dotfiles/cmus/bin/ara
+```