Skip to content

Commit

Permalink
feat: add audio-setup/teardown scripts to home manager
Browse files Browse the repository at this point in the history
  • Loading branch information
flexiondotorg committed Jul 19, 2024
1 parent ae0a819 commit 5a00b0a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
25 changes: 25 additions & 0 deletions home-manager/_mixins/scripts/audio-setup/audio-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set +o pipefail # Disable pipefail

HOST=$(hostnamectl hostname)

# Enable sidetone
mic-loopback on
mic-loopback set 120

# Optimise PipeWire Quantum for OBS Studio; prevent audio crackling
case "${HOST}" in
vader) pw-metadata --name settings 0 clock.force-quantum 64;;
phasma) pw-metadata --name settings 0 clock.force-quantum 64;;
*) pw-metadata --name settings 0 clock.force-quantum 1024;;
esac

# Pause all audio players
playerctl -p cider pause || true
playerctl -p Lodge_iPad pause || true

rhythmbox-client --no-start --set-volume 0
rhythmbox-client --no-start --pause
rhythmbox-client --no-start --shuffle
rhythmbox-client --no-start --repeat
18 changes: 18 additions & 0 deletions home-manager/_mixins/scripts/audio-setup/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ pkgs, ... }:
let
name = builtins.baseNameOf (builtins.toString ./.);
shellApplication = pkgs.writeShellApplication {
inherit name;
runtimeInputs = with pkgs; [
coreutils-full
pipewire
playerctl
procps
rhythmbox
];
text = builtins.readFile ./${name}.sh;
};
in
{
home.packages = with pkgs; [ shellApplication ];
}
13 changes: 13 additions & 0 deletions home-manager/_mixins/scripts/audio-teardown/audio-teardown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

rhythmbox-client --no-start --pause
rhythmbox-client --no-start --no-repeat
rhythmbox-client --no-start --no-shuffle
rhythmbox-client --no-start --set-volume 0

# Restore PipeWire Quantum
pw-metadata --name settings 0 clock.force-quantum 0

# Disable sidetone
mic-loopback set 100
mic-loopback off
16 changes: 16 additions & 0 deletions home-manager/_mixins/scripts/audio-teardown/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ pkgs, ... }:
let
name = builtins.baseNameOf (builtins.toString ./.);
shellApplication = pkgs.writeShellApplication {
inherit name;
runtimeInputs = with pkgs; [
coreutils-full
pipewire
rhythmbox
];
text = builtins.readFile ./${name}.sh;
};
in
{
home.packages = with pkgs; [ shellApplication ];
}

0 comments on commit 5a00b0a

Please sign in to comment.