diff options
author | David P <megver83@parabola.nu> | 2022-07-17 19:06:09 -0400 |
---|---|---|
committer | David P <megver83@parabola.nu> | 2022-07-17 19:06:09 -0400 |
commit | 8a9034ad31023dfb70cd6b48b7bcb52ac7e9ef40 (patch) | |
tree | e6251887150fbbf8b765139b138df0939f24413d /nonsystemd | |
parent | e0d7c1febf84dd2a7e647b0eba6b6112214724b5 (diff) | |
download | abslibre-8a9034ad31023dfb70cd6b48b7bcb52ac7e9ef40.tar.gz abslibre-8a9034ad31023dfb70cd6b48b7bcb52ac7e9ef40.tar.bz2 abslibre-8a9034ad31023dfb70cd6b48b7bcb52ac7e9ef40.zip |
addpkg: nonsystemd/alsa-utils-openrc 20210505-2
Signed-off-by: David P <megver83@parabola.nu>
Diffstat (limited to 'nonsystemd')
-rw-r--r-- | nonsystemd/alsa-utils-openrc/PKGBUILD | 24 | ||||
-rw-r--r-- | nonsystemd/alsa-utils-openrc/alsasound.confd | 15 | ||||
-rw-r--r-- | nonsystemd/alsa-utils-openrc/alsasound.initd | 87 |
3 files changed, 126 insertions, 0 deletions
diff --git a/nonsystemd/alsa-utils-openrc/PKGBUILD b/nonsystemd/alsa-utils-openrc/PKGBUILD new file mode 100644 index 000000000..397a9bf25 --- /dev/null +++ b/nonsystemd/alsa-utils-openrc/PKGBUILD @@ -0,0 +1,24 @@ +# Maintainer: artoo <artoo@artixlinux.org> + +pkgname=alsa-utils-openrc +pkgver=20210505 +pkgrel=2 +pkgdesc="OpenRC alsa-utils init script" +arch=('any') +url="https://gitea.artixlinux.org/artixlinux/packages-openrc" +license=('GPL2') +groups=('openrc-world') +provides=('init-alsa-utils') +depends=('openrc' 'alsa-utils') +conflicts=('init-alsa-utils') +backup=('etc/conf.d/alsasound') +source=("alsasound.confd" + "alsasound.initd") +sha256sums=('d1c55400b701a72dcb8bb85e016b5013fa3eb6a2766ffc20dae278d0ee4c1a43' + '40c9f0e8d00b88ebd28bba9dcd91323549a77aeda12a5a86c532bddca7dae8d1') + +package() { + install -Dm755 "${srcdir}"/alsasound.initd "${pkgdir}"/etc/init.d/alsasound + install -Dm644 "${srcdir}"/alsasound.confd "${pkgdir}"/etc/conf.d/alsasound +} + diff --git a/nonsystemd/alsa-utils-openrc/alsasound.confd b/nonsystemd/alsa-utils-openrc/alsasound.confd new file mode 100644 index 000000000..6fec8f593 --- /dev/null +++ b/nonsystemd/alsa-utils-openrc/alsasound.confd @@ -0,0 +1,15 @@ +# RESTORE_ON_START: +# Do you want to restore your mixer settings? If not, your cards will be +# muted. +# no - Do not restore state +# yes - Restore state + +RESTORE_ON_START="yes" + +# SAVE_ON_STOP: +# Do you want to save changes made to your mixer volumes when alsasound +# stops? +# no - Do not save state +# yes - Save state + +SAVE_ON_STOP="yes" diff --git a/nonsystemd/alsa-utils-openrc/alsasound.initd b/nonsystemd/alsa-utils-openrc/alsasound.initd new file mode 100644 index 000000000..5d866f6cc --- /dev/null +++ b/nonsystemd/alsa-utils-openrc/alsasound.initd @@ -0,0 +1,87 @@ +#!/usr/bin/openrc-run +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +alsastatedir=/var/lib/alsa +alsascrdir=/etc/alsa.d +alsahomedir=/run/alsasound + +extra_commands="save restore" + +depend() { + need localmount + after bootmisc modules isapnp coldplug hotplug +} + +restore() { + ebegin "Restoring Mixer Levels" + + checkpath -q -d -m 0700 -o root:root ${alsahomedir} || return 1 + + if [ ! -r "${alsastatedir}/asound.state" ] ; then + ewarn "No mixer config in ${alsastatedir}/asound.state, you have to unmute your card!" + eend 0 + return 0 + fi + + local cards="$(sed -n -e 's/^ *\([[:digit:]]*\) .*/\1/p' /proc/asound/cards)" + local CARDNUM + for cardnum in ${cards}; do + [ -e /dev/snd/controlC${cardnum} ] || sleep 2 + [ -e /dev/snd/controlC${cardnum} ] || sleep 2 + [ -e /dev/snd/controlC${cardnum} ] || sleep 2 + [ -e /dev/snd/controlC${cardnum} ] || sleep 2 + alsactl -E HOME="${alsahomedir}" -I -f "${alsastatedir}/asound.state" restore ${cardnum} \ + || ewarn "Errors while restoring defaults, ignoring" + done + + for ossfile in "${alsastatedir}"/oss/card*_pcm* ; do + [ -e "${ossfile}" ] || continue + # We use cat because I'm not sure if cp works properly on /proc + local procfile=${ossfile##${alsastatedir}/oss} + procfile="$(echo "${procfile}" | sed -e 's,_,/,g')" + if [ -e /proc/asound/"${procfile}"/oss ] ; then + cat "${ossfile}" > /proc/asound/"${procfile}"/oss + fi + done + + eend 0 +} + +save() { + ebegin "Storing ALSA Mixer Levels" + + checkpath -q -d -m 0700 -o root:root ${alsahomedir} || return 1 + + mkdir -p "${alsastatedir}" + if ! alsactl -E HOME="${alsahomedir}" -f "${alsastatedir}/asound.state" store; then + eerror "Error saving levels." + eend 1 + return 1 + fi + + for ossfile in /proc/asound/card*/pcm*/oss; do + [ -e "${ossfile}" ] || continue + local device=${ossfile##/proc/asound/} ; device=${device%%/oss} + device="$(echo "${device}" | sed -e 's,/,_,g')" + mkdir -p "${alsastatedir}/oss/" + cp "${ossfile}" "${alsastatedir}/oss/${device}" + done + + eend 0 +} + +start() { + if [ "${RESTORE_ON_START}" = "yes" ]; then + restore + fi + + return 0 +} + +stop() { + if [ "${SAVE_ON_STOP}" = "yes" ]; then + save + fi + return 0 +} |