On Saturday, 17 April 2021 at 00:05:41 UTC, Alain De Vos wrote:
After some fiddling i finally got it.
A d-lang program which sets my volume to zero.
```
import std.stdio;
import core.sys.posix.ioctl;
import core.stdc.config;
import core.stdc.stdio;
void main() {
writeln("Set vol to min");
char *mixerdev=cast(char *)"/dev/mixer";
char *mode=cast(char *)"rw";
int mixfd=(fopen(mixerdev,mode)).fileno;
writeln(mixfd);
c_ulong x=3221507328;
int left=0;
ioctl(mixfd,x, &left);
}
```
The function .fileno returns the "underlying handle" of the FILE "object".

Here you could avoid C stdio and just use posix functions like `core.sys.posix.fcntl
 : open` that returns a file descriptor directly.

Reply via email to