diff --git a/alsa-restore.service b/alsa-restore.service new file mode 100644 index 0000000000000000000000000000000000000000..c97411ffff16c79cf2df653eb6b8716b6d7158cf --- /dev/null +++ b/alsa-restore.service @@ -0,0 +1,14 @@ +# +# Note that two different ALSA card state management schemes exist and they +# can be switched using a file exist check - /etc/alsa/state-daemon.conf . +# + +[Unit] +Description=Save/Restore Sound Card State +ConditionPathExists=!/etc/alsa/state-daemon.conf + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=-/sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/lib/alsa/init/00main restore +ExecStop=/sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf store diff --git a/alsa-state.service b/alsa-state.service new file mode 100644 index 0000000000000000000000000000000000000000..6dd312bb2e0c6778ed1608f5548a1127fa1dd1cc --- /dev/null +++ b/alsa-state.service @@ -0,0 +1,13 @@ +# +# Note that two different ALSA card state management schemes exist and they +# can be switched using a file exist check - /etc/alsa/state-daemon.conf . +# + +[Unit] +Description=Manage Sound Card State (restore and store) +ConditionPathExists=/etc/alsa/state-daemon.conf + +[Service] +Type=simple +ExecStart=-/usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/lib/alsa/init/00main rdaemon +ExecStop=-/usr/sbin/alsactl -s kill save_and_quit diff --git a/alsa-utils-1.2.8.tar.bz2 b/alsa-utils-1.2.8.tar.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..8e55215c964aa0d13420c44363e87a556ac95bc8 Binary files /dev/null and b/alsa-utils-1.2.8.tar.bz2 differ diff --git a/alsa-utils.spec b/alsa-utils.spec new file mode 100644 index 0000000000000000000000000000000000000000..ba125677691cf45b57cd557a2f5ef48ea7d78d57 --- /dev/null +++ b/alsa-utils.spec @@ -0,0 +1,224 @@ +%define anolis_release 1 +%define baseversion 1.2.8 +%global _hardened_build 1 + +Summary: Advanced Linux Sound Architecture (ALSA) utilities +Name: alsa-utils +Version: %{baseversion} +Release: %{anolis_release}%{?dist} +License: GPLv2+ +URL: http://www.alsa-project.org/ +Source: ftp://ftp.alsa-project.org/pub/utils/alsa-utils-%{version}.tar.bz2 +Source4: alsaunmute +Source5: alsaunmute.1 +Source10: alsa.rules +Source11: alsactl.conf +Source20: alsa-restore.service +Source22: alsa-state.service + +BuildRequires: gcc +BuildRequires: alsa-lib-devel >= %{baseversion} +BuildRequires: libsamplerate-devel +BuildRequires: ncurses-devel +BuildRequires: gettext-devel +BuildRequires: xmlto +BuildRequires: python3-docutils +BuildRequires: systemd +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +# use latest alsa-lib - the executables in this package requires latest API +Requires: alsa-lib >= %{baseversion} +Requires: alsa-ucm >= %{baseversion} + +%description +This package contains command line utilities for the Advanced Linux Sound +Architecture (ALSA). + +%package -n alsa-ucm-utils +Summary: Advanced Linux Sound Architecture (ALSA) - Use Case Manager + +%description -n alsa-ucm-utils +This package contains Use Case Manager tools for Advanced Linux Sound +Architecture (ALSA) framework. + +%package -n alsa-topology-utils +Summary: Advanced Linux Sound Architecture (ALSA) - Topology +Requires: alsa-topology >= %{baseversion} + +%description -n alsa-topology-utils +This package contains topology tools for Advanced Linux Sound +Architecture (ALSA) framework. + +%package alsabat +Summary: Advanced Linux Sound Architecture (ALSA) - Basic Audio Tester +BuildRequires: fftw-devel +BuildRequires: make + +%description alsabat +This package contains tool for basic audio testing using Advanced Linux Sound +Architecture (ALSA) framework and Fast Fourier Transform library. + +%package doc +Summary: Documentation files for %{name} +Requires: %{name} = %{EVR} +BuildArch: noarch + +%description doc +The %{name}-doc package contains documentation files for %{name}. + +%prep +%autosetup -n %{name}-%{version} -p1 + +%build +%configure CFLAGS="$RPM_OPT_FLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" --disable-alsaconf \ + --with-udev-rules-dir=%{_prefix}/lib/udev/rules.d \ + --with-systemdsystemunitdir=%{_unitdir} +make %{?_smp_mflags} +cp %{SOURCE4} . + +%install +%global alsacfgdir %{_prefix}/lib/alsa + +make install DESTDIR=%{buildroot} +%find_lang %{name} + +# Install ALSA udev rules +mkdir -p %{buildroot}/%{_prefix}/lib/udev/rules.d +install -p -m 644 %{SOURCE10} %{buildroot}/%{_prefix}/lib/udev/rules.d/90-alsa-restore.rules +mkdir -p %{buildroot}/%{_unitdir} +install -p -m 644 %{SOURCE20} %{buildroot}/%{_unitdir}/alsa-restore.service +install -p -m 644 %{SOURCE22} %{buildroot}/%{_unitdir}/alsa-state.service + +# Install support utilities +mkdir -p -m755 %{buildroot}/%{_bindir} +install -p -m 755 %{SOURCE4} %{buildroot}/%{_bindir} +mkdir -p -m755 %{buildroot}/%{_mandir}/man1 +install -p -m 644 %{SOURCE5} %{buildroot}/%{_mandir}/man1/alsaunmute.1 + +# Move /usr/share/alsa/init to /usr/lib/alsa/init +mkdir -p -m 755 %{buildroot}%{alsacfgdir} +mv %{buildroot}%{_datadir}/alsa/init %{buildroot}%{alsacfgdir} + +# Link /usr/lib/alsa/init to /usr/share/alsa/init back +ln -s ../../lib/alsa/init %{buildroot}%{_datadir}/alsa/init + +# Create a place for global configuration +mkdir -p -m 755 %{buildroot}/etc/alsa +install -p -m 644 %{SOURCE11} %{buildroot}/etc/alsa + +# Create /var/lib/alsa tree +mkdir -p -m 755 %{buildroot}%{_sharedstatedir}/alsa + +find %{buildroot} -name "*.la" -exec rm {} \; + +%generate_compatibility_deps + +%files -f %{name}.lang +%license COPYING +%config /etc/alsa/* +%{_prefix}/lib/udev/rules.d/* +%{_unitdir}/* +%{_unitdir}/sound.target.wants/* +%{alsacfgdir}/init/* +%{_bindir}/aconnect +%{_bindir}/alsaloop +%{_bindir}/alsamixer +%{_bindir}/alsaunmute +%{_bindir}/amidi +%{_bindir}/amixer +%{_bindir}/aplay +%{_bindir}/aplaymidi +%{_bindir}/arecord +%{_bindir}/arecordmidi +%{_bindir}/aseqdump +%{_bindir}/aseqnet +%{_bindir}/axfer +%{_bindir}/iecset +%{_bindir}/speaker-test +%{_sbindir}/* +%exclude %{_sbindir}/alsabat-test.sh +%{_datadir}/alsa/ +%{_datadir}/sounds/* +%{_mandir}/man7/* +%{_mandir}/man1/alsactl.1.zst +%{_mandir}/man1/alsaloop.1.zst +%{_mandir}/man1/alsamixer.1.zst +%{_mandir}/man1/alsaunmute.1.zst +%{_mandir}/man1/amidi.1.zst +%{_mandir}/man1/amixer.1.zst +%{_mandir}/man1/aplay.1.zst +%{_mandir}/man1/aplaymidi.1.zst +%{_mandir}/man1/arecord.1.zst +%{_mandir}/man1/arecordmidi.1.zst +%{_mandir}/man1/aseqdump.1.zst +%{_mandir}/man1/aseqnet.1.zst +%{_mandir}/man1/axfer.1.zst +%{_mandir}/man1/axfer-list.1.zst +%{_mandir}/man1/axfer-transfer.1.zst +%{_mandir}/man1/iecset.1.zst +%{_mandir}/man1/speaker-test.1.zst +%{_mandir}/man1/aconnect.1.zst +%{_mandir}/man1/alsa-info.sh.1.zst + +%dir /etc/alsa/ +%dir %{alsacfgdir}/ +%dir %{alsacfgdir}/init/ +%dir %{_sharedstatedir}/alsa/ +%dir %{abidir} +%{abidir}/alsactl-option.list +%{abidir}/alsaloop-option.list +%{abidir}/alsamixer-option.list +%{abidir}/amidi-option.list +%{abidir}/amixer-option.list +%{abidir}/aplay-option.list +%{abidir}/axfer-option.list +%{abidir}/libalsatplg_module_nhlt.dump +%{abidir}/speaker-test-option.list + +%files -n alsa-ucm-utils +%{_bindir}/alsaucm +%{_mandir}/man1/alsaucm.1.zst +%{abidir}/alsaucm-option.list + +%files -n alsa-topology-utils +%{_bindir}/alsatplg +%{_mandir}/man1/alsatplg.1.zst +%{_libdir}/alsa-topology/libalsatplg_module_* +%{abidir}/alsatplg-option.list + +%files alsabat +%{_bindir}/alsabat +%{_sbindir}/alsabat-test.sh +%{_mandir}/man1/alsabat.1.zst +%{abidir}/alsabat-option.list +%{abidir}/alsabat-test.sh-option.list + +%files doc +%doc ChangeLog README.md TODO alsamixer/alsamixer.rc.example + +%pre +if [ ! -r %{_unitdir}/alsa-state.service ]; then + [ -d /etc/alsa ] || mkdir -m 0755 /etc/alsa + echo "# Remove this file to disable the alsactl daemon mode" > \ + /etc/alsa/state-daemon.conf +fi + +%post +if [ -s /etc/alsa/asound.state -a ! -s /etc/asound.state ] ; then + mv /etc/alsa/asound.state /etc/asound.state +fi +if [ -s /etc/asound.state -a ! -s %{_sharedstatedir}/alsa/asound.state ] ; then + mv /etc/asound.state %{_sharedstatedir}/alsa/asound.state +fi +%systemd_post alsa-state.service + +%preun +%systemd_preun alsa-state.service + +%postun +%systemd_postun_with_restart alsa-state.service + +%changelog +* Tue Mar 28 2023 happy_orange - 1.2.8-1 +- init package diff --git a/alsa.rules b/alsa.rules new file mode 100644 index 0000000000000000000000000000000000000000..6a4a0c37790014d7f9a8f5abe43fec2aa9e72e82 --- /dev/null +++ b/alsa.rules @@ -0,0 +1,8 @@ +ACTION=="add", SUBSYSTEM=="sound", KERNEL=="controlC*", KERNELS!="card*", GOTO="alsa_restore_go" +GOTO="alsa_restore_end" + +LABEL="alsa_restore_go" +TEST!="/etc/alsa/state-daemon.conf", RUN+="/sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/lib/alsa/init/00main restore /dev/$name" +TEST=="/etc/alsa/state-daemon.conf", RUN+="/sbin/alsactl -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf --initfile=/lib/alsa/init/00main nrestore /dev/$name" + +LABEL="alsa_restore_end" diff --git a/alsactl.conf b/alsactl.conf new file mode 100644 index 0000000000000000000000000000000000000000..71f0d8085e3f8302d788c557910e5e755c8d767b --- /dev/null +++ b/alsactl.conf @@ -0,0 +1,14 @@ +# +# ALSA library configuration file for alsactl tool +# (/usr/share/alsa tree is not necessary for alsactl) +# + +ctl.hw { + @args [ CARD ] + @args.CARD { + type string + default "0" + } + type hw + card $CARD +} diff --git a/alsaunmute b/alsaunmute new file mode 100755 index 0000000000000000000000000000000000000000..3f772eac39d371d659fb59e014077ddea576f1dc --- /dev/null +++ b/alsaunmute @@ -0,0 +1,6 @@ +#!/bin/sh + +exec /sbin/alsactl \ + -E ALSA_CONFIG_PATH=/etc/alsa/alsactl.conf \ + --initfile=/lib/alsa/init/00main \ + init diff --git a/alsaunmute.1 b/alsaunmute.1 new file mode 100644 index 0000000000000000000000000000000000000000..057ae5071d35a131f061d1c5b72da4e5ad9b3e7f --- /dev/null +++ b/alsaunmute.1 @@ -0,0 +1,28 @@ +.TH ALSAUNMUTE 1 "21 April 2010" +.SH NAME +alsaunmute \- a simple script to initialize ALSA sound devices + +.SH DESCRIPTION +\fBalsaunmute\fP is a shell script which runs the \fBalsactl(1)\fP +utility with \fIinit\fP argument (see the script for details). + +.SH OPTIONS +None + +.SS +Example: +\fBalsaunmute\fR + +.SH SEE ALSO +\fB +alsactl(1), +alsamixer(1), +amixer(1) +\fP + +.SH BUGS +None known. + +.SH AUTHOR +\fBalsaunmute\fP is by Jaroslav Kysela +