jptgdp: Rename to ptgdp, move Music folder and use a symlink instead
This commit is contained in:
parent
9ef02493c7
commit
87804313f2
@ -1,6 +1,6 @@
|
||||
#! /bin/bash
|
||||
#
|
||||
# jptgdp - Just Play the Goddamn Playlist
|
||||
# ptgdp - Play the Goddamn Playlist
|
||||
# Copyright (C) 2019 Vintage Salt <rehashedsalt@cock.li>
|
||||
#
|
||||
# Distributed under terms of the MIT license.
|
||||
@ -16,7 +16,8 @@ _tmpdir="${XDG_CACHE_HOME:-$HOME/.cache}/$_name"
|
||||
_tmpfile="$_tmpdir/tmpfile"
|
||||
_xdguserdirs="${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs"
|
||||
[ -f "$_xdguserdirs" ] && source "$_xdguserdirs"
|
||||
_musicdir="${XDG_MUSIC_DIR:-$HOME/Music}/JPTGDP Songs"
|
||||
_musicdir="${XDG_DATA_HOME:-$HOME/.local/share}/$_name"
|
||||
_musiclink="${XDG_MUSIC_DIR:-$HOME/Music}/PTGDP Songs"
|
||||
|
||||
# Helper functions
|
||||
log() {
|
||||
@ -106,6 +107,15 @@ playlist() {
|
||||
[ -z "$1" ] && return 1
|
||||
[ -f "$1" ] || error "Attempted to access non-file playlist \"$1\"" 50
|
||||
[ -r "$1" ] || error "Cannot read playlist \"$1\"" 51
|
||||
if ! [ -f "$_musicdir/.symlink" ]; then
|
||||
if ln -s "$_musicdir" "$_musiclink" > /dev/null 2>&1; then
|
||||
log "Made symlink to music directory"
|
||||
touch "$_musicdir/.symlink"
|
||||
else
|
||||
log "Failed to make symlink to music directory"
|
||||
log "Music can be found at \"$_musicdir\""
|
||||
fi
|
||||
fi
|
||||
while read line; do
|
||||
[ -z "$line" ] && continue
|
||||
rm "$_tmpfile"* > /dev/null 2>&1
|
Loading…
Reference in New Issue
Block a user