feat(audio): move to pipewire

This commit is contained in:
2025-07-27 21:30:51 +08:00
parent 3cb73506f1
commit 7d08e1f5ef
11 changed files with 70 additions and 105 deletions

View File

@@ -13,15 +13,14 @@
timeout = 0; timeout = 0;
}; };
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = true;
systemd.services.nix-daemon = { systemd.services.nix-daemon = {
environment.TMPDIR = "/var/cache/nix"; environment.TMPDIR = "/var/cache/nix";
serviceConfig.CacheDirectory = "nix"; serviceConfig.CacheDirectory = "nix";
}; };
environment.variables.NIX_REMOTE = "daemon"; environment.variables.NIX_REMOTE = "daemon";
my.audio.enable = false;
sops.secrets.imxyy-nix-server-hashed-password = { sops.secrets.imxyy-nix-server-hashed-password = {
sopsFile = secrets.imxyy-nix-server-hashed-password; sopsFile = secrets.imxyy-nix-server-hashed-password;
format = "binary"; format = "binary";

View File

@@ -29,8 +29,7 @@
wineWowPackages.waylandFull wineWowPackages.waylandFull
pavucontrol pwvucontrol
pamixer
]; ];
programs.zsh = { programs.zsh = {
sessionVariables = { sessionVariables = {
@@ -135,7 +134,6 @@
".config/Kingsoft" ".config/Kingsoft"
".config/dconf" ".config/dconf"
".config/gh" ".config/gh"
".config/pulse"
".config/pip" ".config/pip"
".config/libreoffice" ".config/libreoffice"
".config/sunshine" ".config/sunshine"

View File

@@ -35,36 +35,6 @@
}; };
environment.variables.NIX_REMOTE = "daemon"; environment.variables.NIX_REMOTE = "daemon";
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = false;
alsa.support32Bit = false;
pulse.enable = false;
audio.enable = false;
};
services.pulseaudio = {
enable = true;
support32Bit = true;
package = pkgs.pulseaudioFull;
extraConfig = ''
load-module module-switch-on-connect
unload-module module-suspend-on-idle
'';
};
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
settings = {
General = {
Enable = "Source,Sink,Media,Socket";
Disable = "HeadSet";
MultiProfile = "multiple";
};
};
};
users.extraUsers.${username}.extraGroups = [ "audio" ];
fonts = { fonts = {
enableDefaultPackages = false; enableDefaultPackages = false;
fontDir.enable = true; fontDir.enable = true;

View File

@@ -30,8 +30,7 @@
wineWowPackages.waylandFull wineWowPackages.waylandFull
pavucontrol pwvucontrol
pamixer
]; ];
programs.zsh = { programs.zsh = {
shellAliases = { shellAliases = {
@@ -173,7 +172,6 @@
".config/Kingsoft" ".config/Kingsoft"
".config/dconf" ".config/dconf"
".config/gh" ".config/gh"
".config/pulse"
".config/pip" ".config/pip"
".config/libreoffice" ".config/libreoffice"
".config/sunshine" ".config/sunshine"

View File

@@ -73,36 +73,6 @@ in
}; };
environment.variables.NIX_REMOTE = "daemon"; environment.variables.NIX_REMOTE = "daemon";
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = false;
alsa.support32Bit = false;
pulse.enable = false;
audio.enable = false;
};
services.pulseaudio = {
enable = true;
support32Bit = true;
package = pkgs.pulseaudioFull;
extraConfig = ''
load-module module-switch-on-connect
unload-module module-suspend-on-idle
'';
};
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
settings = {
General = {
Enable = "Source,Sink,Media,Socket";
Disable = "HeadSet";
MultiProfile = "multiple";
};
};
};
users.extraUsers.${username}.extraGroups = [ "audio" ];
fonts = { fonts = {
enableDefaultPackages = false; enableDefaultPackages = false;
fontDir.enable = true; fontDir.enable = true;

24
modules/audio.nix Normal file
View File

@@ -0,0 +1,24 @@
{
config,
lib,
username,
...
}:
lib.my.makeSwitch {
inherit config;
default = true;
optionName = "default audio settings";
optionPath = [ "audio" ];
config' = {
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
audio.enable = true;
};
users.extraUsers.${username}.extraGroups = [ "audio" ];
my.persist.homeDirs = [ ".local/state/wireplumber" ];
};
}

20
modules/bluetooth.nix Normal file
View File

@@ -0,0 +1,20 @@
{ config, lib, ... }:
lib.my.makeSwitch {
inherit config;
default = true;
optionName = "default bluetooth settings";
optionPath = [ "bluetooth" ];
config' = {
hardware.bluetooth = {
enable = true;
powerOnBoot = true;
settings = {
General = {
Enable = "Source,Sink,Media,Socket";
Disable = "HeadSet";
MultiProfile = "multiple";
};
};
};
};
}

View File

@@ -23,8 +23,3 @@ audio_output {
type "pipewire" type "pipewire"
name "pipewire" name "pipewire"
} }
audio_output {
type "pulse"
name "pulseaudio"
}

View File

@@ -151,17 +151,19 @@
"XF86AudioRaiseVolume" = { "XF86AudioRaiseVolume" = {
allow-when-locked = true; allow-when-locked = true;
action.spawn = [ action.spawn = [
"pamixer" "wpctl"
"-i" "set-volume"
"2" "@DEFAULT_SINK@"
"2%+"
]; ];
}; };
"XF86AudioLowerVolume" = { "XF86AudioLowerVolume" = {
allow-when-locked = true; allow-when-locked = true;
action.spawn = [ action.spawn = [
"pamixer" "wpctl"
"-d" "set-volume"
"2" "@DEFAULT_SINK@"
"2%-"
]; ];
}; };
"XF86AudioMute" = { "XF86AudioMute" = {

View File

@@ -19,8 +19,8 @@ _: {
modules-right = [ modules-right = [
"custom/notification" "custom/notification"
"tray" "tray"
"pulseaudio" "wireplumber"
"pulseaudio#microphone" "wireplumber#source"
]; ];
"niri/workspaces" = { "niri/workspaces" = {
@@ -73,7 +73,6 @@ _: {
stopped = ""; stopped = "";
}; };
tooltip = false; tooltip = false;
toottip-format = "{status_icon} Musicfox {artist} - {album} - {title}";
on-scroll-up = "playerctl -p musicfox volume 0.05+"; on-scroll-up = "playerctl -p musicfox volume 0.05+";
on-scroll-down = "playerctl -p musicfox volume 0.05-"; on-scroll-down = "playerctl -p musicfox volume 0.05-";
}; };
@@ -81,14 +80,12 @@ _: {
format = " {:%H:%M %m.%d}"; format = " {:%H:%M %m.%d}";
tooltip = false; tooltip = false;
}; };
pulseaudio = { wireplumber = {
format = "{icon} {volume}%"; format = "{icon} {volume}%";
tooltip = false; tooltip = false;
format-muted = "󰟎 Muted"; format-muted = "󰟎 Muted";
on-click = "pamixer -t"; on-click = "wpctl set-mute @DEFAULT_SINK@ toggle";
on-click-middle = "pavucontrol & disown"; on-click-middle = "pwvucontrol";
on-scroll-up = "pamixer -i 5";
on-scroll-down = "pamixer -d 5";
scroll-step = 5; scroll-step = 5;
format-icons = { format-icons = {
headphone = "󰋋"; headphone = "󰋋";
@@ -104,14 +101,13 @@ _: {
]; ];
}; };
}; };
"pulseaudio#microphone" = { "wireplumber#source" = {
format = "{format_source}"; node-type = "Audio/Source";
format = "󰍬 {volume}%";
tooltip = false; tooltip = false;
format-source = "󰍬 {volume}%"; format-muted = "󰍬 Muted";
format-source-muted = "󰍭 Muted"; on-click = "wpctl set-mute @DEFAULT_SOURCE@ toggle";
on-click = "pamixer --default-source -t"; on-click-middle = "pwvucontrol";
on-scroll-up = "pamixer --default-source -i 5";
on-scroll-down = "pamixer --default-source -d 5";
scroll-step = 5; scroll-step = 5;
}; };
} }

View File

@@ -100,7 +100,7 @@ tooltip * {
#window, #window,
#clock, #clock,
#battery, #battery,
#pulseaudio, #wireplumber,
#network, #network,
#workspaces, #workspaces,
#taskbar, #taskbar,
@@ -219,13 +219,13 @@ window#waybar.empty #window {
border-right: 0; border-right: 0;
} }
#pulseaudio { #wireplumber {
color: #89b4fa; color: #89b4fa;
border-right: 0px; border-right: 0px;
border-radius: 10px 0px 0px 10px; border-radius: 10px 0px 0px 10px;
} }
#pulseaudio.microphone { #wireplumber.source {
color: #cba6f7; color: #cba6f7;
margin-right: 5px; margin-right: 5px;
border-left: 0px; border-left: 0px;
@@ -238,10 +238,3 @@ window#waybar.empty #window {
margin-right: 10px; margin-right: 10px;
border-left: 0px; border-left: 0px;
} }
#custom-weather {
border-radius: 0px 10px 10px 0px;
border-left: 0;
border-right: 0;
margin-left: 0px;
}