mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-23 03:36:31 +01:00
alsactl: move systemd config to the daemon mode
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
46cb355d4f
commit
e05b903b1f
8 changed files with 33 additions and 36 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -25,6 +25,7 @@ ABOUT-NLS
|
||||||
|
|
||||||
alsactl/alsactl
|
alsactl/alsactl
|
||||||
alsactl/alsactl_init.7
|
alsactl/alsactl_init.7
|
||||||
|
alsactl/alsa-state.service
|
||||||
alsaconf/alsaconf
|
alsaconf/alsaconf
|
||||||
alsamixer/alsamixer
|
alsamixer/alsamixer
|
||||||
amidi/amidi
|
amidi/amidi
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
ACTION=="add", SUBSYSTEM=="sound", KERNEL=="controlC*", KERNELS=="card*", \
|
ACTION=="add", SUBSYSTEM=="sound", KERNEL=="controlC*", KERNELS=="card*", \
|
||||||
RUN+="@sbindir@/alsactl restore $attr{number}"
|
RUN+="@sbindir@/alsactl nrestore $attr{number}"
|
||||||
|
|
|
@ -8,7 +8,7 @@ endif
|
||||||
EXTRA_DIST=alsactl.1 alsactl_init.xml
|
EXTRA_DIST=alsactl.1 alsactl_init.xml
|
||||||
|
|
||||||
alsactl_SOURCES=alsactl.c state.c lock.c utils.c init_parse.c daemon.c
|
alsactl_SOURCES=alsactl.c state.c lock.c utils.c init_parse.c daemon.c
|
||||||
alsactl_CFLAGS=$(AM_CFLAGS) -DSYS_ASOUNDRC=\"$(ASOUND_STATE_DIR)/asound.state\"
|
alsactl_CFLAGS=$(AM_CFLAGS) -DSYS_ASOUNDRC=\"$(ASOUND_STATE_DIR)/asound.state\" -DSYS_PIDFILE=\"$(ALSACTL_PIDFILE_DIR)/alsactl.pid\"
|
||||||
noinst_HEADERS=alsactl.h list.h init_sysdeps.c init_utils_string.c init_utils_run.c init_sysfs.c
|
noinst_HEADERS=alsactl.h list.h init_sysdeps.c init_utils_string.c init_utils_run.c init_sysfs.c
|
||||||
|
|
||||||
dist_udevrules_DATA = \
|
dist_udevrules_DATA = \
|
||||||
|
@ -17,8 +17,7 @@ dist_udevrules_DATA = \
|
||||||
if HAVE_SYSTEMD
|
if HAVE_SYSTEMD
|
||||||
|
|
||||||
systemdsystemunit_DATA = \
|
systemdsystemunit_DATA = \
|
||||||
alsa-store.service \
|
alsa-state.service
|
||||||
alsa-restore.service
|
|
||||||
|
|
||||||
install-data-hook:
|
install-data-hook:
|
||||||
$(MKDIR_P) -m 0755 \
|
$(MKDIR_P) -m 0755 \
|
||||||
|
@ -36,23 +35,18 @@ endif
|
||||||
edit = \
|
edit = \
|
||||||
$(SED) -r 's,@sbindir\@,$(sbindir),g' < $< > $@ || rm $@
|
$(SED) -r 's,@sbindir\@,$(sbindir),g' < $< > $@ || rm $@
|
||||||
|
|
||||||
alsa-store.service: alsa-store.service.in
|
alsa-state.service: alsa-state.service.in
|
||||||
$(edit)
|
|
||||||
|
|
||||||
alsa-restore.service: alsa-restore.service.in
|
|
||||||
$(edit)
|
$(edit)
|
||||||
|
|
||||||
90-alsa-restore.rules: 90-alsa-restore.rules.in
|
90-alsa-restore.rules: 90-alsa-restore.rules.in
|
||||||
$(edit)
|
$(edit)
|
||||||
|
|
||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
alsa-store.service.in \
|
alsa-state.service.in \
|
||||||
alsa-restore.service.in \
|
|
||||||
90-alsa-restore.rules.in
|
90-alsa-restore.rules.in
|
||||||
|
|
||||||
CLEANFILES = \
|
CLEANFILES = \
|
||||||
alsa-store.service \
|
alsa-state.service \
|
||||||
alsa-restore.service \
|
|
||||||
90-alsa-restore.rules
|
90-alsa-restore.rules
|
||||||
|
|
||||||
%.7: %.xml
|
%.7: %.xml
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Restore Sound Card State
|
|
||||||
DefaultDependencies=no
|
|
||||||
After=sysinit.target
|
|
||||||
Before=shutdown.target
|
|
||||||
Conflicts=shutdown.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=-@sbindir@/alsactl restore
|
|
||||||
StandardOutput=syslog
|
|
11
alsactl/alsa-state.service.in
Normal file
11
alsactl/alsa-state.service.in
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Manage Sound Card State (restore and store)
|
||||||
|
DefaultDependencies=no
|
||||||
|
After=sysinit.target
|
||||||
|
Before=shutdown.target
|
||||||
|
Conflicts=shutdown.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=-@sbindir@/alsactl -s rdaemon
|
||||||
|
ExecStop=-@sbindir@/alsactl -s rkill save_and_quit
|
|
@ -1,9 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Store Sound Card State
|
|
||||||
DefaultDependencies=no
|
|
||||||
Before=shutdown.target
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=@sbindir@/alsactl store
|
|
||||||
StandardOutput=syslog
|
|
|
@ -159,6 +159,7 @@ int main(int argc, char *argv[])
|
||||||
int init_fallback = 1; /* new default behavior */
|
int init_fallback = 1; /* new default behavior */
|
||||||
int period = 5*60;
|
int period = 5*60;
|
||||||
int background = 0;
|
int background = 0;
|
||||||
|
int daemoncmd = 0;
|
||||||
struct arg *a;
|
struct arg *a;
|
||||||
struct option *o;
|
struct option *o;
|
||||||
int i, j, k, res;
|
int i, j, k, res;
|
||||||
|
@ -178,7 +179,7 @@ int main(int argc, char *argv[])
|
||||||
if ((a->sarg & 0xff) == 0)
|
if ((a->sarg & 0xff) == 0)
|
||||||
continue;
|
continue;
|
||||||
o = &long_option[j];
|
o = &long_option[j];
|
||||||
o->name = args->larg;
|
o->name = a->larg;
|
||||||
o->has_arg = (a->sarg & (ENVARG|FILEARG|INTARG)) != 0;
|
o->has_arg = (a->sarg & (ENVARG|FILEARG|INTARG)) != 0;
|
||||||
o->flag = NULL;
|
o->flag = NULL;
|
||||||
o->val = a->sarg & 0xff;
|
o->val = a->sarg & 0xff;
|
||||||
|
@ -296,12 +297,15 @@ int main(int argc, char *argv[])
|
||||||
daemon(0, 0);
|
daemon(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd = argv[optind];
|
||||||
|
daemoncmd = strcmp(cmd, "daemon") == 0 || strcmp(cmd, "rdaemon") == 0;
|
||||||
|
|
||||||
if (use_syslog) {
|
if (use_syslog) {
|
||||||
openlog("alsactl", LOG_CONS|LOG_PID, LOG_DAEMON);
|
openlog("alsactl", LOG_CONS|LOG_PID, LOG_DAEMON);
|
||||||
syslog(LOG_INFO, "alsactl " SND_UTIL_VERSION_STR " daemon started");
|
if (daemoncmd)
|
||||||
|
syslog(LOG_INFO, "alsactl " SND_UTIL_VERSION_STR " daemon started");
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = argv[optind];
|
|
||||||
if (!strcmp(cmd, "init")) {
|
if (!strcmp(cmd, "init")) {
|
||||||
res = init(initfile, cardname);
|
res = init(initfile, cardname);
|
||||||
snd_config_update_free_global();
|
snd_config_update_free_global();
|
||||||
|
@ -328,7 +332,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
snd_config_update_free_global();
|
snd_config_update_free_global();
|
||||||
if (use_syslog) {
|
if (use_syslog) {
|
||||||
syslog(LOG_INFO, "alsactl daemon stopped");
|
if (daemoncmd)
|
||||||
|
syslog(LOG_INFO, "alsactl daemon stopped");
|
||||||
closelog();
|
closelog();
|
||||||
}
|
}
|
||||||
return res < 0 ? -res : 0;
|
return res < 0 ? -res : 0;
|
||||||
|
|
|
@ -322,6 +322,12 @@ AC_ARG_WITH([asound-state-dir],
|
||||||
[ASOUND_STATE_DIR="/var/lib/alsa"])
|
[ASOUND_STATE_DIR="/var/lib/alsa"])
|
||||||
AC_SUBST(ASOUND_STATE_DIR)
|
AC_SUBST(ASOUND_STATE_DIR)
|
||||||
|
|
||||||
|
AC_ARG_WITH([alsactl-pidfile-dir],
|
||||||
|
AS_HELP_STRING([--with-alsactl-pidfile-dir=DIR], [Directory to place alsactl.pid file in]),
|
||||||
|
[ALSACTL_PIDFILE_DIR="$withval"],
|
||||||
|
[ALSACTL_PIDFILE_DIR="/var/run"])
|
||||||
|
AC_SUBST(ALSACTL_PIDFILE_DIR)
|
||||||
|
|
||||||
AC_OUTPUT(Makefile alsactl/Makefile alsactl/init/Makefile \
|
AC_OUTPUT(Makefile alsactl/Makefile alsactl/init/Makefile \
|
||||||
alsamixer/Makefile amidi/Makefile amixer/Makefile \
|
alsamixer/Makefile amidi/Makefile amixer/Makefile \
|
||||||
m4/Makefile po/Makefile.in \
|
m4/Makefile po/Makefile.in \
|
||||||
|
|
Loading…
Reference in a new issue