Permalink
Browse files

Implemented --previous :) Wooooooooooot

  • Loading branch information...
1 parent d3ec692 commit 47ef2e6ff53be5e96fc7bc3735d074aed0b108bd Aldis Berjoza committed Nov 20, 2010
Showing with 22 additions and 1 deletion.
  1. +22 −1 bin/playd.sh
View
@@ -34,7 +34,7 @@
# project email: playd@bsdroot.lv
# 1}}}
-readonly PLAYD_VERSION='1.10.0'
+readonly PLAYD_VERSION='1.11.0'
readonly PLAYD_NAME="${0##*/}"
readonly PLAYD_FILE_FORMATS='mp3|flac|og[agxmv]|wv|aac|mp[421a]|wav|aif[cf]?|m4[abpr]|ape|mk[av]|avi|mpf|vob|di?vx|mpga?|mov|3gp|wm[av]|midi?'
readonly PLAYD_PLAYLIST_FORMATS='plst?|m3u8?|asx|xspf|ram|qtl|wax|wpl'
@@ -503,6 +503,27 @@ while [ $# -gt 0 ]; do
'next' | '--next' | '-n' )
playd_put "seek 100 1"
;;
+
+ 'previous' | '--previous' | 'prev' | '--prev' )
+ if [ -f "$PLAYD_PLAYLIST" ]; then
+ current_id=$(awk 'BEGIN { XMATCH=0 }; /^'"`playd_current_file_escaped`"'$/ && XMATCH == 0 { XMATCH=1; print NR }' "$PLAYD_PLAYLIST")
+ if [ "x$current_id" != 'x' ]; then
+ if [ $current_id -ne 1 ]; then
+ current_id=$(($current_id - 1))
+ awk 'NR >= '"$current_id"' { print $0 }' "$PLAYD_PLAYLIST" > "$PLAYD_PLAYLIST.tmp"
+ playd_put "loadlist '$PLAYD_PLAYLIST.tmp' $playd_append"
+ else
+ playd_warn "You're on first track."
+ playd_put "loadlist '$PLAYD_PLAYLIST' $playd_append"
+ fi
+ playd_append=1
+ else
+ playd_warn "Can't figure current track. Sorry"
+ fi
+ else
+ playd_warn "Default playlist doesn't exist."
+ fi
+ ;;
'status' | '--status' )
playd_check \

0 comments on commit 47ef2e6

Please sign in to comment.