summaryrefslogtreecommitdiff
path: root/play
diff options
context:
space:
mode:
Diffstat (limited to 'play')
-rwxr-xr-xplay59
1 files changed, 34 insertions, 25 deletions
diff --git a/play b/play
index ff792a8..2738725 100755
--- a/play
+++ b/play
@@ -6,21 +6,26 @@
# set the exit code right for quitting
# echo "q quit 255" >> ~/.mpv/input.conf
-function remove(){
- if [ ! $2 ]; then
- read -p "Removing the origin? [Y/n] " verify
- if [ ! $verify ] || [ $verify = "ja" ] || [ $verify = "yes" ] || [ $verify = "j" ] || [ $verify = "y" ] || [ $verify = "Y" ]; then
- rm -v "$1"
- else
- echo "Okay, we don't remove $1."
- fi
+file="$@"
+
+if [ ! -d $ARCHIV ]; then
+ echo "Note: Variable \$ARCHIV couldn't be found. It will play the file fine, but you should consider to organize your collection."
+fi
+
+if [ -d /tmp ] && [ -w /tmp ]; then
+ tmp="/tmp"
+ cp "$file" /tmp &
+else
+ read -p "Please name the directory (without the trailing slash!) to cache the file: " tmp
+ if [ -d $tmp ] && [ -w $tmp ]; then
+ cp "$file" "$tmp" &
else
- rm -v "$1"
+ echo "Directory doesn't exist or you don't have write permission."
+ exit 1
fi
-}
+fi
-cp "$@" /tmp &
-echo -n "Preparing the awesomeness! Starting playback in.."
+echo -n "Preparing the awesome! Starting playback in.."
echo -n " 3"
sleep 1
echo -n " 2"
@@ -29,33 +34,37 @@ echo -n " 1"
sleep 1
echo " Start!"
-mpv /tmp/"$@"
+mpv $tmp/"$file"
if [ $? -eq 0 ]; then
- if [ -d $ARCHIV ]; then
- echo "Finished $@ succesfull."
- read -p "Should we move to the Archiv? ($ARCHIV) [Y/n/rm/other] " verify
+ if [ -d $ARCHIV ] && [ -w $ARCHIV ]; then
+ echo "Finished $file succesfull."
+ read -p "Should we move everything to the Archiv? ($ARCHIV) [Y/n/rm/other] " verify
if [ ! $verify ] || [ $verify = "ja" ] || [ $verify = "yes" ] || [ $verify = "j" ] || [ $verify = "y" ] || [ $verify = "Y" ]; then
- echo "Moving the stuff to $ARCHIV"
- mv /tmp/"$@" "$ARCHIV"
- remove "$@" "verify"
+ echo "Moving the stuff to $ARCHIV."
+ mv -v $tmp/"$file" "$ARCHIV"
+ if [ $? -eq 0 ]; then
+ rm -v "$file"
+ fi
elif [ $verify = "other" ] || [ $verify = "o" ] || [ $verify = "O" ] || [ $verify = "OTHER" ]; then
read -p "Please tell us the absolute path: " path
- if [ -d $path ]; then
+ if [ -d $path ] && [ -w $path ]; then
echo "Moving to $path."
- mv /tmp/"$@" "$path"
- remove "$@"
+ mv -v $tmp/"$file" "$path"
+ if [ $? -eq 0 ]; then
+ rm -v "$file"
+ fi
else
echo "Sorry, \"$path\" doesn't exist."
exit 1
fi
elif [ $verify = "r" ] || [ $verify = "rm" ] || [ $verify = "remove" ] || [ $verify = "RM" ] || [ $verify = "R" ]; then
- echo "Cleaning the mess up. Removing file from /tmp."
- rm -v /tmp/"$@"
+ echo "Cleaning the mess up. Only removing files from $tmp."
+ rm -v $tmp/"$file"
else
echo "Okay, don't touching the files."
fi
else
- echo "Can't move to \"$ARCHIV\". Directory doesn't exist."
+ echo "Can't move to \"$ARCHIV\". Directory doesn't exist or you don't have write permission."
exit 1
fi
else