51 lines
1.1 KiB
Nix
51 lines
1.1 KiB
Nix
{ pkgs, ... }: let
|
|
amixer = "${pkgs.alsa-utils}/bin/amixer";
|
|
script = pkgs.writeScriptBin "scarlett-air" ''
|
|
#!${pkgs.stdenv.shell}
|
|
which=0
|
|
controlName=""
|
|
newValue=$${1:-2}
|
|
|
|
find_control() {
|
|
for i in /dev/snd/controlC*; do
|
|
r=$(${amixer} controls -c $which | grep "name='Line In 2 Air Capture Enum'")
|
|
|
|
if [[ -z $r ]]; then
|
|
((which++))
|
|
continue
|
|
else
|
|
break
|
|
fi
|
|
|
|
echo "found: $r"
|
|
|
|
controlName=$r
|
|
done
|
|
}
|
|
|
|
for n in {1..30}; do
|
|
find_control
|
|
if [[ -z $controlName ]]; then
|
|
echo "control not found this loop, waiting..."
|
|
sleep 1s
|
|
continue
|
|
fi
|
|
|
|
${amixer} cset -c $which "$controlName" "$newValue" && exit 0
|
|
done
|
|
'';
|
|
in {
|
|
home.packages = [
|
|
script
|
|
];
|
|
|
|
# systemd.user.services.scarlett-air = {
|
|
# enable = true;
|
|
# wantedBy = [ "graphical-session.target" ];
|
|
# description = "Enables yellow Air on the DAC";
|
|
# serviceConfig = {
|
|
# Type = "oneshot";
|
|
# ExecStart = "${script}/bin/scarlett-air";
|
|
# };
|
|
# };
|
|
}
|