summaryrefslogtreecommitdiffstats
path: root/lass
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2020-04-05 11:46:38 +0200
committerlassulus <lassulus@lassul.us>2020-04-05 11:46:38 +0200
commitc7bc2cb7c28c2542e549c76195eb9a9d9cbb8e96 (patch)
treea1fa14ac363b56943dcbc99e09858e61d40b2c26 /lass
parent5c6e007dbeb691cdadafa6615c5b23b40b6b77af (diff)
l radio: kill skipped tracks
Diffstat (limited to 'lass')
-rw-r--r--lass/2configs/radio.nix16
1 files changed, 14 insertions, 2 deletions
diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix
index b24d7af3e..639caa178 100644
--- a/lass/2configs/radio.nix
+++ b/lass/2configs/radio.nix
@@ -9,13 +9,25 @@ let
admin-password = import <secrets/icecast-admin-pw>;
source-password = import <secrets/icecast-source-pw>;
+ music_dir = "/home/radio/music";
+
add_random = pkgs.writeDashBin "add_random" ''
${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.mpc_cli}/bin/mpc ls the_playlist/music | grep '\.ogg$' | shuf -n1)"
'';
skip_track = pkgs.writeDashBin "skip_track" ''
${add_random}/bin/add_random
- echo skipping: "$(${print_current}/bin/print_current)"
+ current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%)
+ track_infos=$(${print_current}/bin/print_current)
+ skip_count=$(${pkgs.attr}/bin/getfattr -n user.skip_count --only-values "$current_track" || echo 0)
+ if [ "$skip_count" -gt 2 ]; then
+ mv "$music_dir"/"$current_track" "$music_dir"/.graveyard/
+ echo killing: "$track_infos"
+ else
+ skip_count=$((skip_count+1))
+ ${pkgs.attr}/bin/setfattr -n user.skip_count -v "$skip_count" "$music_dir"/"$current_track"
+ echo skipping: "$track_infos" skip_count: "$skip_count"
+ fi
${pkgs.mpc_cli}/bin/mpc -q next
'';
@@ -57,7 +69,7 @@ in {
services.mpd = {
enable = true;
group = "radio";
- musicDirectory = "/home/radio/music";
+ musicDirectory = "${music_dir}";
extraConfig = ''
log_level "default"
auto_update "yes"