aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Krier <cedk@gentoo.org>2010-07-17 06:44:22 +0000
committerCédric Krier <cedk@gentoo.org>2010-07-17 06:44:22 +0000
commit1e001ecc9971be6c8855c113d951330a9a94768c (patch)
tree955fa877d94caec44fb599a6bc3af9726cb859d8
parentIncorporate the include dir patches and updates from Michal Gorny (sedzimir). (diff)
downloadeselect-1e001ecc9971be6c8855c113d951330a9a94768c.tar.gz
eselect-1e001ecc9971be6c8855c113d951330a9a94768c.tar.bz2
eselect-1e001ecc9971be6c8855c113d951330a9a94768c.zip
Add miniaudicle module
svn path=/trunk/extern/; revision=771
-rw-r--r--modules/miniaudicle.eselect143
1 files changed, 143 insertions, 0 deletions
diff --git a/modules/miniaudicle.eselect b/modules/miniaudicle.eselect
new file mode 100644
index 0000000..256873a
--- /dev/null
+++ b/modules/miniaudicle.eselect
@@ -0,0 +1,143 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+DESCRIPTION="Manage /usr/bin/miniAudicle audio engine"
+MAINTAINER="cedk@gentoo.org"
+
+# find a list of miniAudicle symlink targets, best first
+find_targets() {
+ local f
+ for f in \
+ ${ROOT}/usr/bin/miniAudicle-alsa \
+ ${ROOT}/usr/bin/miniAudicle-jack \
+ ${ROOT}/usr/bin/miniAudicle-oss \
+ ; do
+ if [[ -f ${f} ]] ; then
+ echo $(basename ${f} )
+ fi
+ done
+}
+
+# try to remove the miniAudicle symlink
+remove_symlinks() {
+ rm -f "${ROOT}"/usr/bin/miniAudicle &>/dev/null
+}
+
+# set the miniAudicle symlink
+set_symlinks() {
+ local target="${1}" targets
+ if is_number "${target}" && [[ ${target} -ge 1 ]] ; then
+ targets=( $(find_targets ) )
+ target=${targets[$(( ${target} - 1 ))]}
+ fi
+ if [[ -f "${ROOT}/usr/bin/${target}" ]] ; then
+ remove_symlinks
+
+ # it's not okay if these fail
+ ln -s "${ROOT}/usr/bin/${target}" "${ROOT}/usr/bin/miniAudicle" || \
+ die "Couldn't set ${target} /usr/bin/miniAudicle symlink"
+ else
+ die -q "Target \"${1}\" doesn't appear to be valid!"
+ fi
+}
+
+### show action ###
+
+describe_show() {
+ echo "Show the current miniAudicle audio engine"
+}
+
+do_show() {
+ [[ -z "${@}" ]] || die -q "Too many parameters"
+
+ write_list_start "Current miniAudicle audio engine:"
+ if [[ -L "${ROOT}/usr/bin/miniAudicle" ]] ; then
+ write_kv_list_entry "$(basename $(canonicalise ${ROOT}/usr/bin/miniAudicle ) )" ""
+ elif [[ -e "${ROOT}/usr/bin/miniAudicle" ]] ; then
+ write_kv_list_entry "(not a symlink)" ""
+ else
+ write_kv_list_entry "(unset)" ""
+ fi
+}
+
+### list action ###
+
+describe_list() {
+ echo "List available miniAudicle audio engines"
+}
+
+do_list() {
+ [[ -z "${@}" ]] || die -q "Too many parameters"
+
+ local i targets
+ targets=( $(find_targets ) )
+ write_list_start "Available miniAudicle audio engines:"
+ for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do
+ [[ ${targets[${i}]} == $(basename $(canonicalise ${ROOT}/usr/bin/miniAudicle- ) ) ]] && \
+ targets[${i}]=$(highlight_maker "${targets[${i}]}")
+ done
+ write_numbered_list -m "(none found)" "${targets[@]}"
+}
+
+### set action ###
+
+describe_set() {
+ echo "Set a new miniAudicle audio engines"
+}
+
+describe_set_options() {
+ echo "target : Target name or number (from 'list' action)"
+}
+
+describe_set_parameters() {
+ echo "<target>"
+}
+
+do_set() {
+ if [[ -z "${1}" ]] ; then
+ die -q "You didn't give me an audio engine"
+
+ elif [[ -n "${2}" ]] ; then
+ die -q "Too many parameters"
+
+ elif [[ -L "${ROOT}/usr/bin/miniAudicle" ]] ; then
+ if ! remove_symlinks ; then
+ die -q "Can't remove existing provider"
+ elif ! set_symlinks "${1}" ; then
+ die -q "Can't set new provider"
+ fi
+
+ elif [[ -e "${ROOT}/usr/bin/miniAudicle" ]] ; then
+ die -q "Sorry, ${ROOT}/usr/bin/miniAudicle confuses me"
+
+ else
+ set_symlinks "${1}" || die -q "Can't set a new audio engine"
+ fi
+}
+
+### update action ###
+
+describe_update() {
+ echo "Automatically update the audio engine"
+}
+
+describe_update_options() {
+ echo "--if-unset : Do not override existing audio engine"
+}
+
+do_update() {
+ [[ -z "${1}" ]] || ( [[ -z "${2}" ]] && [[ "${1}" == "--if-unset" ]] ) || \
+ die -q "Usage error"
+
+ if [[ -L "${ROOT}/usr/bin/miniAudicle" ]] ; then
+ [[ ${1} == "--if-unset" ]] && return
+ remove_symlinks || die -q "Can't remove existing link"
+ fi
+ if [[ -e "${ROOT}/usr/bin/miniAudicle" ]] ; then
+ die -q "Can't set a new provider"
+ elif ! [[ -z $(find_targets ) ]] ; then
+ set_symlinks 1 || die -q "Can't set a new provider"
+ fi
+}
+
+# vim: set ft=eselect :