From 8b34bf25c02693899b03768b0eef628eb1d7bb6e Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 10 Apr 2013 10:23:16 +0200 Subject: [PATCH] alsactl: revert back old systemd static units with the /etc/alsa/state-daemon.conf switch Signed-off-by: Jaroslav Kysela --- .gitignore | 2 ++ alsactl/90-alsa-restore.rules.in | 10 ++++++++-- alsactl/Makefile.am | 19 ++++++++++++++++--- alsactl/alsa-restore.service.in | 17 +++++++++++++++++ alsactl/alsa-state.service.in | 6 ++++++ alsactl/alsa-store.service.in | 15 +++++++++++++++ 6 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 alsactl/alsa-restore.service.in create mode 100644 alsactl/alsa-store.service.in diff --git a/.gitignore b/.gitignore index 096b126..fd5a135 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,8 @@ ABOUT-NLS alsactl/alsactl alsactl/alsactl_init.7 alsactl/alsa-state.service +alsactl/alsa-restore.service +alsactl/alsa-store.service alsaconf/alsaconf alsamixer/alsamixer amidi/amidi diff --git a/alsactl/90-alsa-restore.rules.in b/alsactl/90-alsa-restore.rules.in index fe0e1ed..3ce9a65 100644 --- a/alsactl/90-alsa-restore.rules.in +++ b/alsactl/90-alsa-restore.rules.in @@ -1,2 +1,8 @@ -ACTION=="add", SUBSYSTEM=="sound", KERNEL=="controlC*", KERNELS=="card*", \ - RUN+="@sbindir@/alsactl nrestore $attr{number}" +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+="@sbindir@/alsactl restore $attr{number}" +TEST=="/etc/alsa/state-daemon.conf", RUN+="@sbindir@/alsactl nrestore $attr{number}" + +LABEL="alsa_restore_end" diff --git a/alsactl/Makefile.am b/alsactl/Makefile.am index 0659b28..dbc00f1 100644 --- a/alsactl/Makefile.am +++ b/alsactl/Makefile.am @@ -17,15 +17,18 @@ dist_udevrules_DATA = \ if HAVE_SYSTEMD systemdsystemunit_DATA = \ - alsa-state.service + alsa-state.service \ + alsa-restore.service \ + alsa-store.service install-data-hook: $(MKDIR_P) -m 0755 \ $(DESTDIR)$(systemdsystemunitdir)/basic.target.wants \ $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants ( cd $(DESTDIR)$(systemdsystemunitdir)/basic.target.wants && \ - rm -f alsa-restore.service && \ - $(LN_S) ../alsa-restore.service alsa-restore.service ) + rm -f alsa-state.service alsa-restore.service && \ + $(LN_S) ../alsa-state.service alsa-state.service && \ + $(LN_S) ../alsa-restore.service alsa-restore.service) ( cd $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants && \ rm -f alsa-store.service && \ $(LN_S) ../alsa-store.service alsa-store.service ) @@ -38,15 +41,25 @@ edit = \ alsa-state.service: alsa-state.service.in $(edit) +alsa-restore.service: alsa-restore.service.in + $(edit) + +alsa-store.service: alsa-store.service.in + $(edit) + 90-alsa-restore.rules: 90-alsa-restore.rules.in $(edit) EXTRA_DIST += \ alsa-state.service.in \ + alsa-restore.service.in \ + alsa-store.service.in \ 90-alsa-restore.rules.in CLEANFILES = \ alsa-state.service \ + alsa-restore.service \ + alsa-store.service \ 90-alsa-restore.rules %.7: %.xml diff --git a/alsactl/alsa-restore.service.in b/alsactl/alsa-restore.service.in new file mode 100644 index 0000000..a0d752c --- /dev/null +++ b/alsactl/alsa-restore.service.in @@ -0,0 +1,17 @@ +# +# 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=Restore Sound Card State +ConditionPathExists=!/etc/alsa/state-daemon.conf +DefaultDependencies=no +After=alsa-state.service +Before=shutdown.target +Conflicts=shutdown.target + +[Service] +Type=oneshop +ExecStart=-@sbindir@/alsactl restore +StandardOutput=syslog diff --git a/alsactl/alsa-state.service.in b/alsactl/alsa-state.service.in index fc9914b..94d138b 100644 --- a/alsactl/alsa-state.service.in +++ b/alsactl/alsa-state.service.in @@ -1,5 +1,11 @@ +# +# 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 DefaultDependencies=no After=sysinit.target Before=shutdown.target diff --git a/alsactl/alsa-store.service.in b/alsactl/alsa-store.service.in new file mode 100644 index 0000000..b2e0ac9 --- /dev/null +++ b/alsactl/alsa-store.service.in @@ -0,0 +1,15 @@ +# +# 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=Store Sound Card State +ConditionPathExists=!/etc/alsa/state-daemon.conf +DefaultDependencies=no +Before=shutdown.target + +[Service] +Type=oneshot +ExecStart=@sbindir@/alsactl store +StandardOutput=syslog