Remove mpd & scripts
I've switched to spotify. I don't use mpd anymore.
This commit is contained in:
parent
ab931c4667
commit
3a8a306ba9
|
@ -1,9 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Add files (relative to working directory) to current playlist.
|
||||
|
||||
local files=()
|
||||
for file in $@; do
|
||||
files+="$(realpath --relative-to="$HOME/music" "$file")"
|
||||
done
|
||||
mpc add ${files[@]}
|
|
@ -1,60 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# I frequently discover that there are crappy songs hidden in my music library.
|
||||
# I ain't havin' none o' that! So I file them away in my 1-star.m3u playlist.
|
||||
# This script reads that playlist, delete those songs, and cleans up any empty
|
||||
# folders it leaves behind. It will also remove duplicates from all playlists.
|
||||
#
|
||||
# Usage: cleanup-music
|
||||
|
||||
set -e
|
||||
shopt -s nullglob
|
||||
|
||||
music_dir=$(awk '/music_directory/ { print gensub(/"/, "", "g", $2); }' "$HOME/.config/mpd/mpd.conf")
|
||||
music_dir="${music_dir/#\~/$HOME}"
|
||||
playlist_dir=$(awk '/playlist_directory/ { print gensub(/"/, "", "g", $2); }' "$HOME/.config/mpd/mpd.conf")
|
||||
playlist_dir="${playlist_dir/#\~/$HOME}"
|
||||
|
||||
playlist_file="${playlist_dir}/1-star.m3u"
|
||||
|
||||
# Delete designated songs
|
||||
IFS=$'\n'
|
||||
declare -a to_delete=()
|
||||
while read -r song; do
|
||||
songpath="${music_dir}/${song}"
|
||||
[[ -f $songpath ]] && to_delete+=("$songpath")
|
||||
done < "$playlist_file"
|
||||
|
||||
if (( ${#to_delete[@]} == 0 )); then
|
||||
echo "Nothing to delete"
|
||||
exit
|
||||
fi
|
||||
|
||||
# List songs to delete and ask for confirmation
|
||||
printf "Deleting %s songs:\n\n%s\n\nConfirm? (y/n) " \
|
||||
"${#to_delete[@]}" \
|
||||
"$(IFS=$'\n'; printf "%s" "${to_delete[*]}")"
|
||||
read -r confirm
|
||||
case $confirm in
|
||||
y|Y)
|
||||
echo "Deleting..."
|
||||
for file in "${to_delete[@]}"; do
|
||||
rm -fv "$file"
|
||||
done
|
||||
;;
|
||||
n|N) echo "Aborted"; exit ;;
|
||||
*) echo "Invalid" ;;
|
||||
esac
|
||||
:>"$playlist_file"
|
||||
|
||||
# Remove duplicates across playlists
|
||||
for playlist in ${playlist_dir}/*.m3u; do
|
||||
awk '!seen[$0]++' "${playlist}" > "${playlist}.tmp"
|
||||
if [[ -f "${playlist}.tmp" ]]; then
|
||||
rm -f "$playlist"
|
||||
mv "${playlist}.tmp" "$playlist"
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove empty directories
|
||||
find "$music_dir" -type d -empty -delete
|
|
@ -1,66 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# A non-interactive script that creates notifications (libnotify on Linux,
|
||||
# native notifications on MacOS), announcing the currently playing song. Used by
|
||||
# ncmpcpp.
|
||||
|
||||
_color() { printf '<span fgcolor="%s">%s</span>' "$1" "$2"; }
|
||||
|
||||
if ! pgrep mpd >/dev/null; then
|
||||
>&2 echo "mpd isn't running."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
info=$(mpc current -f ";%artist%;%album%;%title%;%file%")
|
||||
if [[ ${info:0:1} != ";" ]]; then
|
||||
>&2 echo "nothing is playing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IFS=';' read -r _ artist album title file <<< "$info"
|
||||
|
||||
artist="${artist:-$(_color "#757575" "No Artist")}"
|
||||
album="${album:-$(_color "#757575" "No Album")}"
|
||||
title="${title:-$(_color "#757575" "Untitled")}"
|
||||
rating=
|
||||
|
||||
playlist_dir=$(awk '/playlist_directory/ { print gensub(/"/, "", "g", $2); }' "$HOME/.config/mpd/mpd.conf")
|
||||
playlist_dir="${playlist_dir/#\~/$HOME}"
|
||||
|
||||
case $(grep "$file" "$playlist_dir"/*-star.m3u) in
|
||||
*/1-star.m3u:*) starn=1 ;;
|
||||
*/2-star.m3u:*) starn=2 ;;
|
||||
*/3-star.m3u:*) starn=3 ;;
|
||||
*/4-star.m3u:*) starn=4 ;;
|
||||
*/5-star.m3u:*) starn=5 ;;
|
||||
esac
|
||||
if [[ -n $starn ]]; then
|
||||
star_filled_icon="★"
|
||||
star_empty_icon="☆"
|
||||
if [[ $OSTYPE == linux* ]]; then
|
||||
star_filled_icon=$(_color "#8fb1cd" "$star_filled_icon")
|
||||
star_empty_icon=$(_color "#666666" "$star_empty_icon")
|
||||
fi
|
||||
|
||||
for ((i=1;i<=5;i++)); do
|
||||
if (( "$starn" >= "$i" )); then
|
||||
rating="${rating}${star_filled_icon}"
|
||||
else
|
||||
rating="${rating}${star_empty_icon}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
[[ -n $rating ]] && rating="[$rating] "
|
||||
killall terminal-notifier
|
||||
terminal-notifier -title "$rating$title" -message "by $artist :: $album" -appIcon "/Applications/iTunes.app/Contents/Resources/iTunes.icns" &
|
||||
;;
|
||||
linux*)
|
||||
[[ -n $rating ]] && rating="$rating<br />"
|
||||
notify-send --urgency=low --icon="media-playback-start" --app-name="ncmpcpp" "$rating<b>$title</b>" "${artist}\n<i>${album}</i>" &
|
||||
;;
|
||||
esac >/dev/null 2>&1
|
||||
|
||||
exit
|
80
bin/mpd/rate
80
bin/mpd/rate
|
@ -1,80 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Rate the currently playing song in mpd.
|
||||
#
|
||||
# Under the hood, this simply appends the playing song to the
|
||||
# $playlist_directory/$N-star.m3u playlist.
|
||||
#
|
||||
# If rating = 0,
|
||||
# then clear it from all playlists
|
||||
# Else if 1 <= rating <= 5,
|
||||
# then clear it from all playlists,
|
||||
# and add it to ${rating}-star.m3u
|
||||
# Else
|
||||
# display the current rating of the playing song
|
||||
#
|
||||
# Usage: rate [N]
|
||||
|
||||
playlist_dir=$(awk '/playlist_directory/ { print gensub(/"/, "", "g", $2); }' "$HOME/.config/mpd/mpd.conf")
|
||||
playlist_dir="${playlist_dir/#\~/$HOME}"
|
||||
song_file=$(mpc current -f '%file%')
|
||||
song_title=$(mpc current)
|
||||
if [[ -z "$song_file" ]]; then
|
||||
>&2 echo 'Nothing is playing!'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
_clear_playlists() {
|
||||
# Remove the song from other playlists
|
||||
for playlist in "${playlist_dir}/"*-star.m3u; do
|
||||
if grep "^$1$" "$playlist" >/dev/null; then
|
||||
sed -i "\#^$1\$#d" "$playlist"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
_display_stars() {
|
||||
# Display new rating
|
||||
stars=""
|
||||
star_filled_icon='\033[0;32m*\033[0m'
|
||||
star_empty_icon='\033[0;30m*\033[0m'
|
||||
for ((i=1;i<=5;i++)); do
|
||||
if (( "$1" >= "$i" )); then
|
||||
stars="${stars}${star_filled_icon}"
|
||||
else
|
||||
stars="${stars}${star_empty_icon}"
|
||||
fi
|
||||
done
|
||||
echo -e "$stars"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
if (( $# != 1 )); then
|
||||
for ((i=1;i<=5;i++)); do
|
||||
if grep "^${song_file}$" "${playlist_dir}/"${i}-star.m3u >/dev/null; then
|
||||
echo "($(_display_stars $i)) $song_title"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo "($(_display_stars 0)) $song_title"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rating="$1"
|
||||
target="${playlist_dir}/${rating}-star.m3u"
|
||||
|
||||
if (( rating == 0 )); then
|
||||
_clear_playlists "$song_file"
|
||||
echo "Rating cleared"
|
||||
elif [[ ! -f "$target" ]]; then
|
||||
>&2 echo "Not a valid rating, must be between 0-5!"
|
||||
exit 2
|
||||
elif ! grep "^${song_file}$" "$target" >/dev/null; then
|
||||
_clear_playlists "$song_file"
|
||||
echo "$song_file" >> "$target"
|
||||
fi
|
||||
|
||||
# Display new rating
|
||||
echo "($(_display_stars $rating)) $song_title"
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Show a list of recently added songs, and the date they were added. This can be
|
||||
# used to compile a playlist, e.g.
|
||||
#
|
||||
# mpc clear
|
||||
# mpc add $(mpc-recent | cut -f2)
|
||||
|
||||
grep added "$HOME/.config/mpd/mpd.log" | sed 's/ : update: added /\t/g'
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Show a list of recently played songs, and the date they were played. Listed
|
||||
# from oldest to newest. This can be used to compile a playlist, e.g.
|
||||
#
|
||||
# mpc clear
|
||||
# mpc add $(mpc-recent-played | cut -f2)
|
||||
|
||||
grep played "$HOME/.config/mpd/mpd.log" | sed -r 's/ : player: played "(.+)"/\t\1/g' | tail -n${1:-20}
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
libnotify
|
||||
|
||||
(polybar.override {
|
||||
mpdSupport = true;
|
||||
pulseSupport = true;
|
||||
nlSupport = true;
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue