aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LICENSE2
-rw-r--r--README10
-rw-r--r--alsause.118
-rw-r--r--alsause.c30
4 files changed, 44 insertions, 16 deletions
diff --git a/LICENSE b/LICENSE
index fccd785..46cd895 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
ISC License
-© 2024 Mattias Andrée <maandree@kth.se>
+© 2024, 2025 Mattias Andrée <m@maandree.se>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/README b/README
index 41f9516..b19d65b 100644
--- a/README
+++ b/README
@@ -1,18 +1,18 @@
NAME
alsause - Set default ALSA PCM device
-SYNPOSIS
+SYNOPSIS
alsause [(-r | name | card:device) [command [argument] ...]]
DESCRIPTION
The alsause utility lists all ALSA PCM devices or sets, either for the
user or for a program it starts, the default ALSA PCM device.
- No options or operands are specified, alsause will list all ALSA PCM
+ If no options or operands are specified, alsause will list all ALSA PCM
devices, otherwise it will set the default ALSA PCM device.
If command is specified, alsause will run that command with the default
- ALSA PCM device set only for that process and it's child processes.
+ ALSA PCM device set only for that process and its child processes.
OPTIONS
The alsause utility conforms to the Base Definitions volume of
@@ -24,7 +24,7 @@ OPTIONS
to the system-wide default ALSA PCM device.
OPERANDS
- The following operands shall be supported:
+ The following operands are supported:
card:device
The card number and device number to use as the default ALSA PCM
@@ -55,4 +55,4 @@ EXIT STATUS
127 The utility specified by command could not be found.
SEE ALSO
- None.
+ galsause(1)
diff --git a/alsause.1 b/alsause.1
index d433d58..72e17ab 100644
--- a/alsause.1
+++ b/alsause.1
@@ -1,7 +1,7 @@
.TH ALSAUSE 1 ALSAUSE
.SH NAME
alsause - Set default ALSA PCM device
-.SH SYNPOSIS
+.SH SYNOPSIS
.B alsause
.RB [( \-r
|
@@ -17,7 +17,7 @@ utility lists all ALSA PCM devices or
sets, either for the user or for a program
it starts, the default ALSA PCM device.
.PP
-No options or operands are specified,
+If no options or operands are specified,
.B alsause
will list all ALSA PCM devices, otherwise
it will set the default ALSA PCM device.
@@ -28,7 +28,7 @@ is specified,
.B alsause
will run that command with the default
ALSA PCM device set only for that process
-and it's child processes.
+and its child processes.
.SH OPTIONS
The
.B alsause
@@ -41,7 +41,7 @@ The following option is supported:
Remove the user-specified default ALSA PCM device,
falling back to the system-wide default ALSA PCM device.
.SH OPERANDS
-The following operands shall be supported:
+The following operands are supported:
.TP
.IR card : device
The card number and device number to use as the default
@@ -69,7 +69,7 @@ None.
The following environment variable affects the execution of
.TP
.I HOME
-Used to override the path to the user's home directroy.
+Used to override the path to the user's home directory.
.TP
.I PATH
Determine the location of the
@@ -84,7 +84,7 @@ utility.
.SH ASYNCHRONOUS EVENTS
Default.
.SH STDOUT
-If no option or operand is specified, each ALSA PCM device is the form:
+If no option or operand is specified, each ALSA PCM device is of the form:
.RS
\fB\(dq%u:%u\et%s - %s\en\(dq,\fP <\fIcard number\fP>\fB,\fP <\fIdevice number\fP>\fB,\fP <\fIcard name\fP>\fB,\fP <\fIdevice name\fP>
@@ -94,9 +94,9 @@ Otherwise, the
.B alsause
utility does not write to standard output.
.SH STDERR
-The standard error shall be used only for diagnostic messages.
+The standard error is only used for diagnostic messages.
.SH OUTPUT FILES
-If the the default ALSA PCM device is set, the
+If the default ALSA PCM device is set, the
.B alsause
utility may create, modify, replace, or unlink the file
.I .asoundrc
@@ -134,4 +134,4 @@ The utility specified by
.I command
could not be found.
.SH SEE ALSO
-None.
+.BR galsause (1)
diff --git a/alsause.c b/alsause.c
index e157e71..5cb923d 100644
--- a/alsause.c
+++ b/alsause.c
@@ -1,5 +1,15 @@
/* See LICENSE file for copyright and license details. */
#include <sys/mount.h>
+#ifndef OPEN_TREE_CLONE
+# define MISSING_OPEN_TREE
+#endif
+#ifndef MOVE_MOUNT_F_EMPTY_PATH
+# define MISSING_MOVE_MOUNT
+#endif
+#if defined(MISSING_OPEN_TREE) || defined(MISSING_MOVE_MOUNT)
+# include <linux/mount.h>
+# include <sys/syscall.h>
+#endif
#include <sched.h>
#include <alsa/asoundlib.h>
#include <libsimple.h>
@@ -8,6 +18,24 @@
NUSAGE(125, "[(-r | name | card:device) [command [argument] ...]]");
+#ifdef MISSING_OPEN_TREE
+static int
+open_tree(int dirfd, const char *path, int flags)
+{
+ return syscall(SYS_open_tree, dirfd, path, flags);
+}
+#endif
+
+
+#ifdef MISSING_MOVE_MOUNT
+static int
+move_mount(int dirfd1, const char *path1, int dirfd2, const char *path2, int flags)
+{
+ return syscall(SYS_move_mount, dirfd1, path1, dirfd2, path2, flags);
+}
+#endif
+
+
static char *
get_config_path(void)
{
@@ -277,7 +305,7 @@ main(int argc, char *argv[])
treefd = open_tree(AT_FDCWD, temppath, OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
if (treefd < 0) {
- weprintf("open_tree AT_FDCWD %s OPEN_TREE_CLONE:", temppath);
+ weprintf("open_tree AT_FDCWD %s OPEN_TREE_CLONE|OPEN_TREE_CLOEXEC:", temppath);
unlink(temppath);
exit(libsimple_default_failure_exit);
}