aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>2000-05-20 23:25:08 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>2000-05-20 23:25:08 +0000
commit7a1203480c13ddff93fc4b02e91e81585e1168af (patch)
tree87c43e239d12e9b8623130bdd2078870f07bb1ea
parent28c645cf6a9ec7ece1f37cddc001656c25344c64 (diff)
downloadsrc-7a1203480c13ddff93fc4b02e91e81585e1168af.tar.gz
src-7a1203480c13ddff93fc4b02e91e81585e1168af.zip
I've always wanted to be able to dump out the current values of
the mixer in a format suitable for saving and handing off to mixer(1) at some future date to restore the settings. Add a -s flag to do this.
Notes
Notes: svn path=/head/; revision=60741
-rw-r--r--usr.sbin/mixer/mixer.88
-rw-r--r--usr.sbin/mixer/mixer.c20
2 files changed, 23 insertions, 5 deletions
diff --git a/usr.sbin/mixer/mixer.8 b/usr.sbin/mixer/mixer.8
index 55d2898dc5dd..d429528b0904 100644
--- a/usr.sbin/mixer/mixer.8
+++ b/usr.sbin/mixer/mixer.8
@@ -36,6 +36,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl f Ar device
+.Op Fl s
.Oo
.Oo Ns
.Ar dev Op Ar lvol Ns Op Ar :rvol
@@ -79,6 +80,13 @@ and
.Ar rvol
arguments may be from 0 - 100.
.Pp
+If the
+.Fl s
+flag is used, the current mixer values will be displayed in a format suitable
+for use as the command-line arguments to a future invocation of
+.Nm
+(as above).
+.Pp
To change the recording device you use one of:
.Bl -tag -width =rec -offset indent
.It ^rec
diff --git a/usr.sbin/mixer/mixer.c b/usr.sbin/mixer/mixer.c
index feb3193ba83a..21b35804f486 100644
--- a/usr.sbin/mixer/mixer.c
+++ b/usr.sbin/mixer/mixer.c
@@ -35,7 +35,7 @@ usage(int devmask, int recmask)
{
int i, n;
- printf("usage: mixer [[dev [voll[:volr]] | recsrc | {^|+|-|=}rec recdev] ... ]\n");
+ printf("usage: mixer [-s] [[dev [voll[:volr]] | recsrc | {^|+|-|=}rec recdev] ... ]\n");
printf(" devices: ");
for (i = 0, n = 0; i < SOUND_MIXER_NRDEVICES; i++)
if ((1 << i) & devmask) {
@@ -89,7 +89,7 @@ main(int argc, char *argv[])
{
int foo, bar, baz, dev;
int devmask = 0, recmask = 0, recsrc = 0, orecsrc;
- int dusage = 0, drecsrc = 0;
+ int dusage = 0, drecsrc = 0, shortflag = 0;
int l, r;
char *name;
@@ -101,6 +101,10 @@ main(int argc, char *argv[])
else if (!strcmp(argv[0], "mixer3"))
name = strdup("/dev/mixer2");
+ if (argc > 1 && strcmp(argv[1], "-s") == 0) {
+ shortflag = 1;
+ argc -= 1; argv += 1;
+ }
if (argc > 2 && strcmp(argv[1], "-f") == 0) {
name = strdup(argv[2]);
argc -= 2; argv += 2;
@@ -125,7 +129,10 @@ main(int argc, char *argv[])
warn("MIXER_READ");
continue;
}
- printf("Mixer %-8s is currently set to %3d:%d\n", names[foo], bar & 0x7f, (bar >> 8) & 0x7f);
+ if (shortflag)
+ printf("%s %d:%d ", names[foo], bar & 0x7f, (bar >> 8) & 0x7f);
+ else
+ printf("Mixer %-8s is currently set to %3d:%d\n", names[foo], bar & 0x7f, (bar >> 8) & 0x7f);
}
return(0);
}
@@ -181,8 +188,11 @@ main(int argc, char *argv[])
argc--; argv++;
continue;
}
- printf("Mixer %-8s is currently set to %3d:%d\n",
- names[dev], bar & 0x7f, (bar >> 8) & 0x7f);
+ if (shortflag)
+ printf("%s %d:%d ", names[dev], bar & 0x7f, (bar >> 8) & 0x7f);
+ else
+ printf("Mixer %-8s is currently set to %3d:%d\n",
+ names[dev], bar & 0x7f, (bar >> 8) & 0x7f);
argc--; argv++;
break;