{ pkgs, lib, ... }:
let
  inherit (lib) getExe;
  inherit (pkgs) mpv;
in
{
  programs = let
    # TODO: a notification based variant
    opts = lib.escapeShellArgs [
      # no gui
      "--no-video"
      # no stdout
      "--really-quiet"
      # prime tv audio
      "--audio-wait-open=1" # TODO: no work? ""
      "--audio-stream-silence=yes" # "Not all AOs support this"
    ];
    rcScript = ''
      salert() {
        local retval=$?
        local -a opts=(${opts})
        if test $retval -eq 0; then
          case $(( $RANDOM % 10 )) in
          0 | 1 | 2 | 3 | 4)
            ${getExe mpv} "''${opts[@]}" --volume-gain=10 ${../../files/sounds/NTR-BKIE-USA-0134.wav} ||:
          ;;
          5 | 6 | 7 | 8)
            ${getExe mpv} "''${opts[@]}" --volume-gain=12 ${../../files/sounds/NTR-BKIE-USA-0065.wav} ||:
          ;;
          9)
            ${getExe mpv} "''${opts[@]}" --volume-gain=3 ${../../files/sounds/TFH_MadameC_Sing.wav} ||:
          ;;
          esac
        else
          ${getExe mpv} "''${opts[@]}" --volume-gain=8 ${../../files/sounds/NTR-BKIE-USA-0137.wav} ||:
        fi

        return $retval
      }
    '';
  in {
    # TODO: fish
    bash.initExtra = rcScript;
    zsh.initExtra = rcScript;
  };
}
