2024-04-05 01:38:57 +02:00
|
|
|
{ pkgs, config, ... }:
|
2023-06-11 15:51:26 +02:00
|
|
|
|
2024-04-03 11:51:01 +02:00
|
|
|
let
|
|
|
|
inherit (pkgs) mpc-cli;
|
2024-04-05 01:38:57 +02:00
|
|
|
inherit (config.xdg.userDirs) music;
|
2024-04-03 11:51:01 +02:00
|
|
|
|
2024-04-05 01:38:57 +02:00
|
|
|
musicDirectory = music;
|
2024-04-03 11:51:01 +02:00
|
|
|
changeScript = "ncmpcpp/on-song-change.sh";
|
|
|
|
fallbackImage = ../assets/wallpaper.png;
|
|
|
|
in
|
2023-06-22 16:42:23 +02:00
|
|
|
{
|
2024-04-03 11:51:01 +02:00
|
|
|
home.packages = [ mpc-cli ];
|
2023-05-18 21:58:30 +02:00
|
|
|
|
2023-06-16 13:23:35 +02:00
|
|
|
services.mpd = {
|
|
|
|
enable = true;
|
2024-04-03 11:51:01 +02:00
|
|
|
inherit musicDirectory;
|
|
|
|
|
2024-04-03 01:33:03 +02:00
|
|
|
extraConfig = /* config */ ''
|
2023-06-16 15:55:50 +02:00
|
|
|
auto_update "yes"
|
|
|
|
'';
|
2024-04-03 01:33:03 +02:00
|
|
|
};
|
2023-06-01 21:02:10 +02:00
|
|
|
|
2024-04-03 11:51:01 +02:00
|
|
|
xdg.configFile.${changeScript} = {
|
|
|
|
executable = true;
|
|
|
|
text = /* bash */ ''
|
|
|
|
#!/usr/bin/env bash
|
2023-06-16 15:55:50 +02:00
|
|
|
|
2024-04-03 11:51:01 +02:00
|
|
|
find_cover () {
|
|
|
|
ext="$(mpc --format %file% current | sed 's/^.*\.//')"
|
2023-06-16 15:55:50 +02:00
|
|
|
|
2024-04-03 11:51:01 +02:00
|
|
|
if [ "$ext" == "flac" ]; then
|
|
|
|
metaflac --export-picture-to=/tmp/cover.jpg \
|
|
|
|
"$(mpc --format "${musicDirectory}"/%file% current)" && cover_path="/tmp/cover.jpg" && return
|
|
|
|
else
|
2024-04-05 01:40:09 +02:00
|
|
|
ffmpeg -y -i "$(mpc --format "${musicDirectory}"/%file% | head -n 1)" \
|
2024-04-03 11:51:01 +02:00
|
|
|
/tmp/cover.jpg && cover_path="/tmp/cover.jpg" && return
|
|
|
|
fi
|
2023-06-16 15:55:50 +02:00
|
|
|
|
2024-04-03 11:51:01 +02:00
|
|
|
file="${musicDirectory}/$(mpc --format %file% current)"
|
|
|
|
album="''${file%/*}"
|
|
|
|
cover_path=$(find "$album" -maxdepth 1 | grep -m 1 ".*\.\(jpg\|png\|gif\|bmp\)")
|
|
|
|
}
|
2023-06-16 15:55:50 +02:00
|
|
|
|
2024-04-05 01:40:09 +02:00
|
|
|
find_cover 2>/dev/null
|
|
|
|
notify-send -i "''${cover_path:-${fallbackImage}}" "Now Playing" "$(mpc current)" 2>/dev/null
|
2024-04-03 11:51:01 +02:00
|
|
|
'';
|
2023-06-16 15:55:50 +02:00
|
|
|
};
|
2023-05-25 18:15:23 +02:00
|
|
|
|
2023-06-16 13:23:35 +02:00
|
|
|
programs.ncmpcpp = {
|
|
|
|
enable = true;
|
2023-05-25 18:15:23 +02:00
|
|
|
|
2023-06-16 13:23:35 +02:00
|
|
|
bindings = [
|
|
|
|
{ key = "mouse"; command = "dummy"; }
|
|
|
|
{ key = "h"; command = [ "previous_column" "jump_to_parent_directory" ]; }
|
|
|
|
{ key = "j"; command = "scroll_down"; }
|
|
|
|
{ key = "k"; command = "scroll_up"; }
|
|
|
|
{ key = "l"; command = [ "next_column" "enter_directory" "play_item" ]; }
|
|
|
|
{ key = "H"; command = [ "select_item" "scroll_down" ]; }
|
|
|
|
{ key = "J"; command = [ "move_sort_order_down" "move_selected_items_down" ]; }
|
|
|
|
{ key = "K"; command = [ "move_sort_order_up" "move_selected_items_up" ]; }
|
|
|
|
{ key = "L"; command = [ "select_item" "scroll_up" ]; }
|
|
|
|
{ key = "'"; command = "remove_selection"; }
|
|
|
|
{ key = "ctrl-u"; command = "page_up"; }
|
|
|
|
{ key = "ctrl-d"; command = "page_down"; }
|
|
|
|
{ key = "u"; command = "page_up"; }
|
|
|
|
{ key = "d"; command = "page_down"; }
|
|
|
|
{ key = "n"; command = "next_found_item"; }
|
|
|
|
{ key = "N"; command = "previous_found_item"; }
|
|
|
|
{ key = "t"; command = "next_screen"; }
|
|
|
|
{ key = "g"; command = "move_home"; }
|
|
|
|
{ key = "G"; command = "move_end"; }
|
|
|
|
{ key = "w"; command = "next"; }
|
|
|
|
{ key = "b"; command = "previous"; }
|
|
|
|
{ key = ";"; command = "seek_forward"; }
|
|
|
|
{ key = ","; command = "seek_backward"; }
|
|
|
|
{ key = "f"; command = "apply_filter"; }
|
|
|
|
{ key = "i"; command = "select_item"; }
|
|
|
|
{ key = "x"; command = [ "delete_playlist_items" "delete_browser_items" "delete_stored_playlist" ]; }
|
|
|
|
{ key = "U"; command = "update_database"; }
|
|
|
|
{ key = "m"; command = "add_random_items"; }
|
|
|
|
];
|
2023-05-19 08:54:35 +02:00
|
|
|
|
2023-06-16 13:23:35 +02:00
|
|
|
settings = {
|
|
|
|
ncmpcpp_directory = "~/.config/ncmpcpp";
|
|
|
|
user_interface = "alternative";
|
|
|
|
autocenter_mode = "yes";
|
|
|
|
allow_for_physical_item_deletion = "no";
|
|
|
|
mouse_support = "no";
|
2024-04-03 11:51:01 +02:00
|
|
|
execute_on_song_change = "~/.config/${changeScript}";
|
2023-06-16 13:23:35 +02:00
|
|
|
mpd_crossfade_time = 3;
|
|
|
|
};
|
|
|
|
};
|
2023-05-16 23:09:05 +02:00
|
|
|
}
|