blob: 1e8985af9bb0e9d0bceea9679424c7b1d0a8bf1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.os.core.audio;
toggleMuteNotify = pkgs.writeShellScriptBin "toggle-mute-notify" ''
IS_MUTED=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep -c "MUTED")
if [ "$IS_MUTED" -eq 1 ]; then
${pkgs.libnotify}/bin/notify-send -a "MuteIndicator" -t 0 -u critical "Microphone Muted" "Mic is currently OFF"
else
${pkgs.mako}/bin/makoctl dismiss -a "MuteIndicator"
fi
'';
in
{
options.os.core.audio = {
enable = lib.mkEnableOption "audio support";
disable-devices.enable = lib.mkEnableOption "disables some random devices cluttering up";
};
config = lib.mkMerge [
(lib.mkIf cfg.enable {
services = {
pipewire = {
enable = true;
audio.enable = true;
pulse.enable = true;
alsa.enable = true;
alsa.support32Bit = true;
jack.enable = true;
wireplumber.enable = true;
};
playerctld.enable = true;
spotifyd.enable = true;
};
security.rtkit.enable = true;
environment.systemPackages = with pkgs; [
toggleMuteNotify
pulsemixer
crosspipe
alsa-utils
];
})
(lib.mkIf cfg.disable-devices.enable {
services.pipewire.wireplumber.extraConfig = {
"99-disable-useless-devices"."monitor.alsa.rules" = [
{
matches = [
{ "device.name" = "~alsa_card.pci-0000_03_00.1*"; }
{ "device.description" = "~USB Audio*"; }
];
actions.update-props = {
"device.disabled" = true;
};
}
];
};
})
];
}
|