All pastes #417257 Raw Edit

Unnamed

public shellscript v1 · immutable
#417257 ·published 2007-03-30 19:27 UTC
rendered paste body
#!/bin/bash#Author: 		Copyright Jelle de Jong <jelledejong@powercraft.nl>#Note:			Please send me an email if you enhanced the script#Version:		0.0.2#Date:			23-07-2006 / 18-01-2007 / 29-03-07#System:		Xubuntu 7.04#Information:		man mpg123#Category		Thunar scripts#Name:			Play MP3#Description:		Play a directory full with mp3 files#Command:		xfce4-terminal -x ~/scripts/thunar/play-mp3.sh %F#Information:		http://www.grymoire.com/Unix/Quote.html#Information:		http://www.tldp.org/LDP/abs/html/arrays.html#Information:		http://rafb.net/p/WOTlt235.html#Pattern:		*#Selection:		Directories; Audio Files# This software is free software; you can redistribute it and/or modify it# under the terms of the GNU General Public License as published by the# Free Software Foundation; either version 2, or (at your option) any# later version.## This software is distributed in the hope that it will be useful, but# WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU# General Public License for more details.cecho(){	if [ "$1" = "black" ]; then		echo -ne "\E[30m"	elif [ "$1" = "red" ]; then		echo -ne "\E[31m"	elif [ "$1" = "green" ]; then		echo -ne "\E[32m"	elif [ "$1" = "yellow" ]; then		echo -ne "\E[33m"	elif [ "$1" = "blue" ]; then		echo -ne "\E[34m"	elif [ "$1" = "magenta" ]; then		echo -ne "\E[35m"	elif [ "$1" = "cyan" ]; then		echo -ne "\E[36m"	fi	echo "$2" "$3"	tput sgr0}play_file(){	mpg123 -C -v -a /dev/dsp "$@"	#mpg123 -C -v -a /dev/dsp1 "$1"}check_program(){	#whereis pdftk	if [ ! -e /usr/bin/$1 ]	then		cecho "red" "$1 not found, installing now"		sudo apt-get install "$1"	fi}scan_directory(){	#step 1: is there a mp3 in the folder 	#step 2: query that mp3	#step 3: check for other folders	#step 4: scan that folder and repeat		#query+=$(find "$1" -name *.mp3)	#var1="test one.mp3";var2="test two.mp3";unset query;set -x;query+=("$var1");query+=("$var2");mpg123 -C -v -a /dev/dsp "${query[@]}"	for file in "$1"/*	do		if [ -f "$file" ]		then			[[ "$file" = *.mp3 ]] && query+=("$file")					fi				if [ -d "$file" ]		then			scan_directory "$file"		fi		done}cecho "green" "processing:"for I in "$@" do	filename=${I##*/}	cecho "blue" "$filename"donececho "blue" "---------------"for I in "$@" do	cecho "green" "starting: "	check_program mpg123		filename=${I##*/}	if [ -d "$I" ]	then		unset query		scan_directory "$I"				if [ -n "$query" ]		then			play_file "${query[@]}"		fi	fi	if [ -f "$I" ]	then		play_file "$I"	fi	cecho "green" "completed:"	cecho "blue" "---------------"donececho "green" "done, closing after 3 seconds"sleep 3exit