added toggleaudiosink pkg
This commit is contained in:
parent
95e23247b0
commit
4b17075968
3 changed files with 140 additions and 106 deletions
|
|
@ -113,6 +113,9 @@
|
||||||
};
|
};
|
||||||
workstationOverlay = final: prev: {
|
workstationOverlay = final: prev: {
|
||||||
plasticity = nixpkgs.legacyPackages."x86_64-linux".callPackage ./packages/plasticity.nix { };
|
plasticity = nixpkgs.legacyPackages."x86_64-linux".callPackage ./packages/plasticity.nix { };
|
||||||
|
toggleaudiosink =
|
||||||
|
nixpkgs.legacyPackages."x86_64-linux".callPackage ./packages/toggleaudiosink.nix
|
||||||
|
{ };
|
||||||
};
|
};
|
||||||
serverOverlay = final: prev: {
|
serverOverlay = final: prev: {
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -43,113 +43,96 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
# Workstation specific configuration
|
# Workstation specific configuration
|
||||||
(lib.mkIf hostType.isWorkstation (
|
(lib.mkIf hostType.isWorkstation ({
|
||||||
let
|
environment.systemPackages = with pkgs; [
|
||||||
kwrite = pkgs.symlinkJoin {
|
### Dev Tools ###
|
||||||
name = "kwrite";
|
bat
|
||||||
paths = [ pkgs.kdePackages.kate ];
|
deploy-rs
|
||||||
postBuild = ''
|
fd
|
||||||
rm -rf $out/bin/kate \
|
fzf
|
||||||
$out/bin/.kate-wrapped \
|
nixfmt-rfc-style
|
||||||
$out/share/applications/org.kde.kate.desktop \
|
nix-init
|
||||||
$out/share/man \
|
nix-output-monitor
|
||||||
$out/share/icons/hicolor/*/apps/kate.png \
|
ripgrep
|
||||||
$out/share/icons/hicolor/scalable/apps/kate.svg \
|
### Internet Browsers & Communication ###
|
||||||
$out/share/appdata/org.kde.kate.appdata.xml
|
beeper
|
||||||
'';
|
brave
|
||||||
|
nextcloud-client
|
||||||
|
tor-browser
|
||||||
|
vesktop
|
||||||
|
### Office & Productivity ###
|
||||||
|
aspell
|
||||||
|
aspellDicts.de
|
||||||
|
aspellDicts.en
|
||||||
|
aspellDicts.en-computers
|
||||||
|
aspellDicts.pt_BR
|
||||||
|
libreoffice-qt
|
||||||
|
obsidian
|
||||||
|
(octaveFull.withPackages (octavePackages: with octavePackages; [ signal ]))
|
||||||
|
onlyoffice-desktopeditors
|
||||||
|
rnote
|
||||||
|
### Graphics & Design ###
|
||||||
|
gimp
|
||||||
|
inkscape
|
||||||
|
orca-slicer
|
||||||
|
plasticity
|
||||||
|
### Gaming & Entertainment ###
|
||||||
|
clonehero
|
||||||
|
heroic
|
||||||
|
mangohud
|
||||||
|
prismlauncher
|
||||||
|
protonup
|
||||||
|
### System Utilities ###
|
||||||
|
adwaita-icon-theme
|
||||||
|
junction
|
||||||
|
kara
|
||||||
|
kde-rounded-corners
|
||||||
|
libfido2
|
||||||
|
morewaita-icon-theme
|
||||||
|
nautilus
|
||||||
|
mission-center
|
||||||
|
p7zip
|
||||||
|
qbittorrent
|
||||||
|
quickemu
|
||||||
|
quickgui
|
||||||
|
rustdesk
|
||||||
|
steam-run
|
||||||
|
toggleaudiosink
|
||||||
|
unrar
|
||||||
|
### Media ###
|
||||||
|
mpv
|
||||||
|
obs-studio
|
||||||
|
qview
|
||||||
|
];
|
||||||
|
|
||||||
|
programs = {
|
||||||
|
adb.enable = true;
|
||||||
|
steam.enable = true;
|
||||||
|
dconf.enable = true;
|
||||||
|
nix-ld.enable = true;
|
||||||
|
kdeconnect.enable = true;
|
||||||
|
partition-manager.enable = true;
|
||||||
|
gamemode.enable = true;
|
||||||
|
appimage = {
|
||||||
|
enable = true;
|
||||||
|
binfmt = true;
|
||||||
};
|
};
|
||||||
in
|
nh = {
|
||||||
{
|
enable = true;
|
||||||
environment.systemPackages = with pkgs; [
|
flake = "/home/user/Projects/personal/nix-config";
|
||||||
### Dev Tools ###
|
};
|
||||||
bat
|
};
|
||||||
deploy-rs
|
|
||||||
fd
|
fonts = {
|
||||||
fzf
|
fontDir.enable = true;
|
||||||
nixfmt-rfc-style
|
packages = with pkgs; [
|
||||||
nix-init
|
corefonts
|
||||||
nix-output-monitor
|
inter
|
||||||
ripgrep
|
nerd-fonts.hack
|
||||||
### Internet Browsers & Communication ###
|
noto-fonts-cjk-sans
|
||||||
beeper
|
roboto
|
||||||
brave
|
|
||||||
nextcloud-client
|
|
||||||
tor-browser
|
|
||||||
vesktop
|
|
||||||
### Office & Productivity ###
|
|
||||||
aspell
|
|
||||||
aspellDicts.de
|
|
||||||
aspellDicts.en
|
|
||||||
aspellDicts.en-computers
|
|
||||||
aspellDicts.pt_BR
|
|
||||||
kwrite
|
|
||||||
libreoffice-qt
|
|
||||||
obsidian
|
|
||||||
(octaveFull.withPackages (octavePackages: with octavePackages; [ signal ]))
|
|
||||||
onlyoffice-desktopeditors
|
|
||||||
rnote
|
|
||||||
### Graphics & Design ###
|
|
||||||
gimp
|
|
||||||
inkscape
|
|
||||||
orca-slicer
|
|
||||||
plasticity
|
|
||||||
### Gaming & Entertainment ###
|
|
||||||
clonehero
|
|
||||||
heroic
|
|
||||||
mangohud
|
|
||||||
prismlauncher
|
|
||||||
protonup
|
|
||||||
### System Utilities ###
|
|
||||||
adwaita-icon-theme
|
|
||||||
junction
|
|
||||||
kara
|
|
||||||
kde-rounded-corners
|
|
||||||
libfido2
|
|
||||||
morewaita-icon-theme
|
|
||||||
nautilus
|
|
||||||
mission-center
|
|
||||||
p7zip
|
|
||||||
qbittorrent
|
|
||||||
quickemu
|
|
||||||
quickgui
|
|
||||||
rustdesk
|
|
||||||
steam-run
|
|
||||||
unrar
|
|
||||||
### Media ###
|
|
||||||
mpv
|
|
||||||
obs-studio
|
|
||||||
qview
|
|
||||||
];
|
];
|
||||||
|
};
|
||||||
programs = {
|
}))
|
||||||
adb.enable = true;
|
|
||||||
steam.enable = true;
|
|
||||||
dconf.enable = true;
|
|
||||||
nix-ld.enable = true;
|
|
||||||
kdeconnect.enable = true;
|
|
||||||
partition-manager.enable = true;
|
|
||||||
gamemode.enable = true;
|
|
||||||
appimage = {
|
|
||||||
enable = true;
|
|
||||||
binfmt = true;
|
|
||||||
};
|
|
||||||
nh = {
|
|
||||||
enable = true;
|
|
||||||
flake = "/home/user/Projects/personal/nix-config";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
fonts = {
|
|
||||||
fontDir.enable = true;
|
|
||||||
packages = with pkgs; [
|
|
||||||
corefonts
|
|
||||||
inter
|
|
||||||
nerd-fonts.hack
|
|
||||||
noto-fonts-cjk-sans
|
|
||||||
roboto
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
))
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
48
packages/toggleaudiosink.nix
Normal file
48
packages/toggleaudiosink.nix
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
{
|
||||||
|
pkgs ? import <nixpkgs> { },
|
||||||
|
}:
|
||||||
|
|
||||||
|
pkgs.writeShellScriptBin "toggleaudiosink" ''
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
sound_server="pipewire"
|
||||||
|
|
||||||
|
# Grab a count of how many audio sinks we have
|
||||||
|
sink_count=$(${pkgs.pulseaudio}/bin/pactl list sinks | grep -c "Sink #[[:digit:]]")
|
||||||
|
# Create an array of the actual sink IDs
|
||||||
|
sinks=()
|
||||||
|
mapfile -t sinks < <(${pkgs.pulseaudio}/bin/pactl list sinks | grep 'Sink #[[:digit:]]' | sed -n -e 's/.*Sink #\([[:digit:]]\)/\1/p')
|
||||||
|
# Get the ID of the active sink
|
||||||
|
active_sink_name=$(${pkgs.pulseaudio}/bin/pactl info | grep 'Default Sink:' | sed -n -e 's/.*Default Sink:[[:space:]]\+\(.*\)/\1/p')
|
||||||
|
active_sink=$(${pkgs.pulseaudio}/bin/pactl list sinks | grep -B 2 "$active_sink_name" | sed -n -e 's/Sink #\([[:digit:]]\)/\1/p' | head -n 1)
|
||||||
|
|
||||||
|
# Get the ID of the last sink in the array
|
||||||
|
final_sink=''${sinks[$((sink_count - 1))]}
|
||||||
|
|
||||||
|
# Find the index of the active sink
|
||||||
|
for index in "''${!sinks[@]}"; do
|
||||||
|
if [[ "''${sinks[$index]}" == "$active_sink" ]]; then
|
||||||
|
active_sink_index=$index
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Default to the first sink in the list
|
||||||
|
next_sink=''${sinks[0]}
|
||||||
|
next_sink_index=0
|
||||||
|
|
||||||
|
# If we're not at the end of the list, move up the list
|
||||||
|
if [[ $active_sink -ne $final_sink ]]; then
|
||||||
|
next_sink_index=$((active_sink_index + 1))
|
||||||
|
next_sink=''${sinks[$next_sink_index]}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Change the default sink
|
||||||
|
# Get the name of the next sink
|
||||||
|
next_sink_name=$(${pkgs.pulseaudio}/bin/pactl list sinks | grep -C 2 "Sink #$next_sink" | sed -n -e 's/.*Name:[[:space:]]\+\(.*\)/\1/p' | head -n 1)
|
||||||
|
${pkgs.pulseaudio}/bin/pactl set-default-sink "$next_sink_name"
|
||||||
|
|
||||||
|
# Move all inputs to the new sink
|
||||||
|
for app in $(${pkgs.pulseaudio}/bin/pactl list sink-inputs | sed -n -e 's/.*Sink Input #\([[:digit:]]\)/\1/p'); do
|
||||||
|
${pkgs.pulseaudio}/bin/pactl "move-sink-input $app $next_sink"
|
||||||
|
done
|
||||||
|
''
|
||||||
Loading…
Add table
Add a link
Reference in a new issue