2019-09-26 17:20:32 -05:00
|
|
|
#! /bin/bash
|
|
|
|
#
|
|
|
|
# ptgdp-rofi
|
|
|
|
# Uses rofi to select a ptgdp playlist in ~/Music/Playlists
|
|
|
|
# Copyright (C) 2019 Vintage Salt <rehashedsalt@cock.li>
|
|
|
|
#
|
|
|
|
# Distributed under terms of the MIT license.
|
|
|
|
#
|
|
|
|
set -e
|
|
|
|
|
|
|
|
_xdguserdirs="${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs"
|
|
|
|
[ -z "$XDG_MUSIC_DIR" ] && [ -r "$_xdguserdirs" ] && source "$_xdguserdirs"
|
|
|
|
unset _xdguserdirs
|
|
|
|
playlistdir="${XDG_MUSIC_DIR:-$HOME/Music}/Playlists"
|
|
|
|
|
|
|
|
files=$(find "$playlistdir" -type f -name \*.gdp)
|
|
|
|
if [ -n "$files" ]; then
|
|
|
|
playlists=""
|
|
|
|
while read file; do
|
|
|
|
filebase="$(basename -- "$file")"
|
|
|
|
filebase="${filebase%.gdp}"
|
|
|
|
[ -n "$playlists" ] && playlists+=$'\n'
|
|
|
|
playlists+="$filebase"
|
|
|
|
done <<< "$files"
|
|
|
|
else
|
|
|
|
echo "No playlists found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
prompt="ptgdp"
|
2019-10-18 23:37:22 -05:00
|
|
|
choice="$(rofi -dmenu -i -no-custom -p "$prompt" <<< "$playlists" 2>/dev/null)"
|
2019-09-26 17:20:32 -05:00
|
|
|
[ -z "$choice" ] && exit 2
|
|
|
|
exec ptgdp -p "$playlistdir"/"$choice".gdp
|