nix/modules/stuff/mpd.nix

43 lines
1 KiB
Nix
Raw Normal View History

2024-08-06 13:41:05 +02:00
{ lib, pkgs, config, ...}: let
inherit (lib) mkIf mkEnableOption mkOption;
cfg = config.chuj.stuff.mpd;
user = config.chuj.system.user;
in {
options.chuj.stuff.mpd = {
enable = mkEnableOption "mpd";
};
config = mkIf cfg.enable {
home-manager.users.${user} = {
services.mpd = {
enable = true;
extraConfig = ''
audio_output {
type "pulse"
name "PulseAudio Output"
}
'';
};
home.packages = let
yad = "${pkgs.yad}/bin/yad";
dunstify = "${pkgs.dunst}/bin/dunstify";
mpc = "${pkgs.mpc-cli}/bin/mpc";
cut = "${pkgs.coreutils}/bin/cut";
in [
pkgs.mpc-cli
(pkgs.writeShellScriptBin "mpdfdial.sh" ''
path=$(${yad} --file --directory | ${cut} -d "/" -f5-)
${dunstify} "playing from \"$path\""
${mpc} update
${mpc} rescan
${mpc} add "$path"
${mpc} random on
${mpc} repeat on
${mpc} play
'')
];
};
};
}