
* 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/>