Krolyxon
Commit bbf5404

Branches

Refs →

aurorabbf5404

madd: show artist - title · album, bind SUPER+SHIFT+M

Author
krolyxon
Date
2026-10-26 18:11 +0530
Parent
ff7bd95
Commit
bbf5404a83113ec3eb2c13f96dee91459719d692

+22 −3

2 files changed

  1. M .config/hypr/source/keybinds.lua +1 −0
  2. M .local/bin/madd +21 −3
M .config/hypr/source/keybinds.lua View
@@ -47,6 +47,7 @@ hl.bind(mainMod .. " + SHIFT + P", hl.dsp.exec_cmd("hypr_screenshot.sh"))
4747
4848 -- Music Controls
4949 hl.bind(mainMod .. " + m", hl.dsp.exec_cmd(terminal .. " -e zsh -i -c \"rmptui\""))
50+hl.bind(mainMod .. " + SHIFT + m", hl.dsp.exec_cmd("madd </dev/null")) -- stdin is tty1 otherwise: madd would pick fzf
5051 hl.bind(mainMod .. " + p", hl.dsp.exec_cmd("mpc toggle"))
5152 hl.bind(mainMod .. " + period", hl.dsp.exec_cmd("mpc seek +10"), { repeating = true })
5253 hl.bind(mainMod .. " + comma", hl.dsp.exec_cmd("mpc seek -10"), { repeating = true })
M .local/bin/madd View
@@ -25,16 +25,34 @@ if ! mpc status >/dev/null 2>&1; then
2525 exit 1
2626 fi
2727
28−library=$(mpc listall)
28+# One "Artist - Title · Album<TAB>file" line per track (the album makes typing an
29+# album name list its songs). Untagged tracks fall back to the file name (minus
30+# extension and a leading track number), and the artist is only prefixed when
31+# that name doesn't already contain one. Singles (album = title) skip the album.
32+library=$(mpc listall -f '%artist%\t%title%\t%album%\t%file%' | awk -F'\t' '{
33+ artist = $1; title = $2; album = $3; file = $4
34+ if (title == "") {
35+ title = file
36+ sub(/.*\//, "", title); sub(/\.[^.]*$/, "", title); sub(/^[0-9]+[.)]? *-? */, "", title)
37+ if (index(title, " - ")) artist = ""
38+ }
39+ line = artist != "" ? artist " - " title : title
40+ sub(/ - (Single|EP)$/, "", album)
41+ if (album != "" && album != title) line = line " · " album
42+ print line "\t" file
43+}')
2944 if [ -z "$library" ]; then
3045 notify -u critical "MPD library is empty" "Try: mpc update"
3146 exit 1
3247 fi
3348
3449 if [ -t 0 ]; then
35− filename=$(printf '%s\n' "$library" | fzf)
50+ filename=$(printf '%s\n' "$library" | fzf -d '\t' --with-nth 1 | cut -f2)
3651 else
37− filename=$(printf '%s\n' "$library" | aurora-run -d -l 30 -p 'play: ')
52+ # aurora-run can't hide a column: show the names, map the index back to the file.
53+ n=$(printf '%s\n' "$library" | cut -f1 | aurora-run -d -l 30 -p 'play: ' --index) || exit 0
54+ [ "$n" -ge 0 ] 2>/dev/null || exit 0
55+ filename=$(printf '%s\n' "$library" | sed -n "$((n + 1))p" | cut -f2)
3856 fi
3957
4058 # Cancelled (Esc): nothing to do.