index

A music clipboard for making playlist on a whim

Focus is precious. Whenever I’m on work mode, I usually opt for calmed, structured music that hides in the background, like [[furniture music]]; e.g. synthwave, lofi or something like that.

I am also a sucker for videogame soundtracks —specially [[Japanese-style RPG (JRPG)]]— which is a bummer! I’m not usually in the mood for tension and beats for killing deities1 when I’m recovering a server from a backup because oh-no-we-have-screwed-up-latest-deploy. That means that I am either (1) skipping the song entirely or (2) picking up a work-oriented playlist.

Unfortunately, my song library —hosted on my homelab with [[Navidrome]]— happens to be both my glory and shame. I love watching it grow overtime, carefully selecting albums I’m emotionally attached to, making my own playlists and so son — but this also implies that I am my own curator. And, as much as I love pressing the random button on the whole Hollow Knight franchise, it’s not the right time for dancing with Karmelita.

So I’ve made the only logical thing a person can do in this circunstance: think about this papercut —for far, far too long— and come up with a solution — usually in the form of a program, which here is: ask the operative system for the currently playing son, clip its name and artist, and add it to the daily music clipboard. Set a keyboard shortcut on that, and voilà — hyper - m now stores in a file what songs I’ve liked throughout the day. This means that, if I’m enjoying a particular song, I can save it and make a playlist with all of them later on2. Neat!

#!/bin/bash

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Clip currently playing song
# @raycast.mode silent

# Optional parameters:
# @raycast.icon 📻

# Documentation:
# @raycast.description Append the currently playing song and artist to today's music clipboard note

output_folder="/choose/this/one/yourself/kiddo"
separator=" | "

today=$(date +"%Y-%m-%d")
file="$output_folder/$today music clipboard.md"

info=$(nowplaying-cli get --json title artist)
song=$(echo "$info" | plutil -extract title raw -o - -)
artist=$(echo "$info" | plutil -extract artist raw -o - -)

if [ -z "$song" ]; then
	echo "Nothing is currently playing."
	exit 1
fi

if [ ! -f "$file" ]; then
	cat >"$file" <<-EOF
	---
	categories:
	  - "[[music-clipboard]]"
	---
	song${separator}artist
	EOF
fi

echo "${song}${separator}${artist}" >>"$file"

echo "Clipped: $song"

Nonetheless I will still reach for [[Lofi Girl]] because I’m a sucker for that mood. Guilty pleasures in an stubborn rebelion against art rentals.

Footnotes

  1. Looking at you Mechanical Rythm from [[Xenoblade Chronicles 1]].

  2. Counterpoint: I have to notice those songs, which isn’t as easy as it sounds —haha sounds get it— when you’re in deep focus.