refactor: merge 'audio-automation' module into 'audio' module

This commit is contained in:
2026-03-11 23:53:50 +01:00
parent b417e67e16
commit 210d8f3b1f
4 changed files with 50 additions and 30 deletions

View File

@@ -25,7 +25,6 @@ in
}) })
../../modules/desktops/niri ../../modules/desktops/niri
../../modules/audio ../../modules/audio
../../modules/audio-automation
../../modules/backups ../../modules/backups
../../modules/bluetooth ../../modules/bluetooth
../../modules/keyboard ../../modules/keyboard
@@ -57,6 +56,7 @@ in
docker.user = config.host.username; docker.user = config.host.username;
nfc.user = config.host.username; nfc.user = config.host.username;
desktop.ly.enable = true; desktop.ly.enable = true;
audio.automation.enable = true;
nix.settings.secret-key-files = [ config.sops.secrets.nix_signing_key_astyanax.path ]; nix.settings.secret-key-files = [ config.sops.secrets.nix_signing_key_astyanax.path ];

View File

@@ -1,17 +0,0 @@
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.libnotify ];
services.udev.extraRules = ''
SUBSYSTEM=="power_supply", ATTR{online}=="0", ACTION=="change", TAG+="systemd", ENV{SYSTEMD_USER_WANTS}+="mute-audio.service"
'';
systemd.user.services.mute-audio = {
description = "mute audio when switching to battery power";
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.bash}/bin/bash -c '${pkgs.pulseaudio}/bin/pactl set-sink-mute $(${pkgs.pulseaudio}/bin/pactl get-default-sink) true && ${pkgs.libnotify}/bin/notify-send \"audio Muted\" \"switched to battery power\"'";
};
};
}

View File

@@ -0,0 +1,29 @@
{
lib,
config,
pkgs,
...
}:
let
cfg = config.audio.automation;
in
{
options.audio.automation.enable = lib.mkEnableOption "audio automation (mute on battery)";
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.libnotify ];
services.udev.extraRules = ''
SUBSYSTEM=="power_supply", ATTR{online}=="0", ACTION=="change", TAG+="systemd", ENV{SYSTEMD_USER_WANTS}+="mute-audio.service"
'';
systemd.user.services.mute-audio = {
description = "mute audio when switching to battery power";
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.bash}/bin/bash -c '${pkgs.pulseaudio}/bin/pactl set-sink-mute $(${pkgs.pulseaudio}/bin/pactl get-default-sink) true && ${pkgs.libnotify}/bin/notify-send \"audio Muted\" \"switched to battery power\"'";
};
};
};
}

View File

@@ -1,18 +1,26 @@
{ ... }:
{ {
nixpkgs.allowedUnfree = [ imports = [
"spotify" ./audio-automation.nix
"spotify-unwrapped"
]; ];
security.rtkit.enable = true; config = {
services = { nixpkgs.allowedUnfree = [
pulseaudio.enable = false; "spotify"
pipewire = { "spotify-unwrapped"
enable = true; ];
alsa.enable = true;
alsa.support32Bit = true; security.rtkit.enable = true;
pulse.enable = true; services = {
pulseaudio.enable = false;
pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
pulseaudio.extraConfig = "load-module module-switch-on-connect";
}; };
pulseaudio.extraConfig = "load-module module-switch-on-connect";
}; };
} }