nix/modules/stuff/mpd.nix
2024-10-16 11:40:24 +02:00

43 lines
1.1 KiB
Nix

{ 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
# todo: dmenu for this if i3
(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
'')
];
};
};
}