User Tools

Site Tools


cd-rip-mfk
#!/bin/bash
 
# Prompts user for Audio CD ripping action
# Mithat Konar, 2009
 
# requires zenity, abcde, urxvt
 
#=== CONSTANTS =========================================================
 
# Menu entries
RIP_CD="Rip with abcde"
EDIT_CFG="  Edit configuration file"
NEW_CFG="  Create configuration file"
RIP_ROX="Rip with ROX's Ripper"
PLAY_CD="Play CD"
 
# Prompts and other GUI strings
MAIN_TITLE="Audio CD"
MAIN_PROMPT="What do you want to do?"
OPTIONS="Options:"
CHOOSE_CFG="Choose a configuration file"
NEW_CFG_NAME="Create a new configuration file"
 
# Misc
CONFIGS_DIR=$HOME/.abcde-configs
THE_ICON=/usr/share/icons/gnome/16x16/devices/drive-optical.png
 
#=== FUNCTIONS =========================================================
 
function rip-it()
# starts a rip using config file $1 if found
{
	cfgfile=`zenity --file-selection \
	--window-icon "$THE_ICON" \
	--title "$CHOOSE_CFG" \
	--filename="${CONFIGS_DIR}/"`
 
	if [[ $? == 1 ]] ; then
		echo "User cancelled" 1>&2
		return 1
	fi
 
	#~ xterm -geometry 96x32 -fa "" -fs 9 -T "CD Ripper (abcde)" -name "CD Ripper (abcde)" -e "abcde -c \"$cfgfile\" ; echo ; read -sn 1 -p \"Press any key to continue...\"" &
	#~ urxvt -geometry 96x32 -sr -fn "7x14,xft:Bitstream Vera Sans Mono" -title "CD Ripper (abcde)" -name "CD Ripper (abcde)" -e bash -c "abcde -c \"$cfgfile\" ; echo ; read -sn 1 -p \"Press any key to continue...\""
	urxvt -geometry 120x40 -sr -title "CD Ripper (abcde)" -name "CD Ripper (abcde)" -e bash -c "abcde -c \"$cfgfile\" ; echo ; read -sn 1 -p \"Press any key to continue...\""
 
}
 
function edit-config()
# prompts user for config file to edit
{
	cfgfile=`zenity --file-selection \
	--window-icon "$THE_ICON" \
	--title "$CHOOSE_CFG" \
	--filename="${CONFIGS_DIR}/"`
 
	if [[ $? == 1 ]] ; then
		echo "User cancelled" 1>&2
		return 1
	fi
 
	geany "$cfgfile"
}
 
function new-config()
# prompts user for new config file
{
	cfgfile=`zenity --file-selection \
	--window-icon "$THE_ICON" \
	--title "$NEW_CFG_NAME" \
	--confirm-overwrite \
	--save \
	--filename="${CONFIGS_DIR}/new.conf"`
 
	if [[ $? == 1 ]] ; then
		echo "User cancelled" 1>&2
		return 1
	fi
 
	cp /etc/abcde.conf "$cfgfile"
	geany "$cfgfile"
}
 
#=== MAIN ==============================================================
 
cd ~
 
isDone=1
while [[ $isDone != 0 ]] 
do
	action=`zenity --list \
	--height=220 \
	--window-icon "$THE_ICON" \
	--title "$MAIN_TITLE" \
	--text "$MAIN_PROMPT" \
	--column "$OPTIONS" \
		"$RIP_CD" \
		"$EDIT_CFG" \
		"$NEW_CFG" \
		"$RIP_ROX" \
		"$PLAY_CD" \
	`
 
	if [[ $? == 1 ]] ; then
		echo "User cancelled" 1>&2
		exit
	fi
 
	case "$action" in
 
		"$RIP_CD" )
			rip-it
			nautilus ~/Music
			isDone=0
			;;		
 
		"$EDIT_CFG" )
			edit-config
			isDone=1
			;;
 
		"$NEW_CFG" )
			new-config
			isDone=1
			;;
 
		"$RIP_ROX" )
			rox "$HOME/Apps/ROX Apps/Ripper"
			isDone=0
			;;
 
		"$PLAY_CD" )
			#exaile --play-cd &
			#vlc cdda:// &
			audacious cdda:// &
			isDone=0
			;;
 
		* )
			echo "command not found: $action" 1>&2
			zenity --error --title "Command not found" --text "I can't find a command called \"$action\"."
			exit 1
			;;
	esac
done
cd-rip-mfk.txt · Last modified: 2009-10-06 15:25 by mithat