
Thank you to all those who took the trouble to reply to my post. Further consideration convinced me that I needed an application additional to xmms to do what I ultimately wanted to do. (What I ultimately wanted to do was to be able to convert files in .wma format to .mp3 format.) That additional application was xmmsctrl and it worked to close xmms. The script I was working on is now in the following form and does do the necessary conversion: #### #!/bin/bash sed -i "s/libOSS.so/libdisk_writer.so/g" ~/.xmms/config for i in *.wma do filename=`basename "$i" .wma` echo "Converting $i to .wav" xmmsctrl launch xmms "$i" while `xmmsctrl playing`; do sleep 1 done xmmsctrl quit lame "${i/wma/wav}" "${i/wma/mp3}" && rm -f ${i/wma/wav} done sed -i "s/libdisk_writer.so/libOSS.so/g" ~/.xmms/config #### Everything of any worth in the script has been derived from others, but I'm sure that the way in which I've put those things together breaks most, if not all, the rules about correct script writing. At least the script works (for now!). Thanks again, Leslie

* Leslie Katz <lesliek(a)ozemail.com.au> [2006-05-23 07:45]:
#!/bin/bash
sed -i "s/libOSS.so/libdisk_writer.so/g" ~/.xmms/config
for i in *.wma do filename=`basename "$i" .wma`
You never use this value.
echo "Converting $i to .wav" xmmsctrl launch xmms "$i" while `xmmsctrl playing`; do
The backticks are bad style here: you’re not actually capturing output, only using the exit code.
sleep 1 done xmmsctrl quit
It’s not actually necessary to launch/quit XMMS constantly.
lame "${i/wma/wav}" "${i/wma/mp3}" && rm -f ${i/wma/wav}
Unless XMMS actually creates unwritable files, use just `rm`. In general, things like `rm -f`, `kill -9` etc. that are there “just to be sure” are dangerous and should be avoided unless explicitly necessary.
done
sed -i "s/libdisk_writer.so/libOSS.so/g" ~/.xmms/config
It’d be conceptually simpler to keep a copy of the original state of the file instead of editing back and forth, and just moving it back into place once you’re done. ---- In all: #!/bin/bash CFG=~/.xmms/config mv "$CFG" "$CFG".orig || { echo "Couldn't back up $CFG" 1>&2 ; exit 1 ; } sed 's/libOSS.so/libdisk_writer.so/g' "$CFG".orig > "$CFG" xmmsctrl launch for src in *.wma ; do base="${src%.wmv}" temp="$base".wav echo "$src => $temp" xmmsctrl clear +file "$src" play while xmmsctrl playing ; do sleep 1 ; done lame "$temp" "$base".mp3 && rm "$temp" done xmmsctrl quit mv "$CFG".orig "$CFG" One problem that remains is that [Repeat] may be set… xmmsctrl lets you toggle it, but gives you no way to query it (very useful). Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>
participants (2)
-
A. Pagaltzis
-
Leslie Katz