#! /bin/bash # # ptgdp-rofi # Uses rofi to select a ptgdp playlist in ~/Music/Playlists # Copyright (C) 2019 Vintage Salt # # 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" choice="$(rofi -dmenu -i -p "$prompt" <<< "$playlists" 2>/dev/null)" [ -z "$choice" ] && exit 2 exec ptgdp -p "$playlistdir"/"$choice".gdp