i3 - improved tiling WM


Support mixer_idx with OSS

Patch status: merged

Patch by Baptiste Daroussin

Long description:

make mixer_idx load the default mixer

To apply this patch, use:
curl http://cr.i3wm.org/patch/93/raw.patch | git am

b/man/i3status.man

15
@@ -312,9 +312,10 @@ details on the format string.
16
 Outputs the volume of the specified mixer on the specified device. Works only
17
 on Linux because it uses ALSA.
18
 A simplified configuration can be used on FreeBSD and OpenBSD due to
19
-the lack of ALSA,  the +device+, +mixer+ and +mixder_idx+ options can be
20
+the lack of ALSA,  the +device+ and +mixer+ options can be
21
 ignored on these systems. On these systems the OSS API is used instead to
22
-query +/dev/mixer+ directly.
23
+query +/dev/mixer+ directly if +mixer_dix+ is -1, otherwise
24
++/dev/mixer++mixer_idx+.
25
 
26
 *Example order*: +volume master+
27
 

b/src/print_volume.c

32
@@ -175,12 +175,22 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *
33
 	}
34
 #endif
35
 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
36
-        char mixerpath[] = "/dev/mixer";
37
+        char *mixerpath;
38
+        char defaultmixer[] = "/dev/mixer";
39
         int mixfd, vol, devmask = 0;
40
         pbval = 1;
41
 
42
+        if (mixer_idx > 0)
43
+                asprintf(&mixerpath, "/dev/mixer%d", mixer_idx);
44
+        else
45
+                mixerpath = defaultmixer;
46
+
47
         if ((mixfd = open(mixerpath, O_RDWR)) < 0)
48
                 return;
49
+
50
+        if (mixer_idx > 0)
51
+                free(mixerpath);
52
+
53
         if (ioctl(mixfd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1)
54
                 return;
55
         if (ioctl(mixfd, MIXER_READ(0),&vol) == -1)