summaryrefslogtreecommitdiffstats
path: root/lass/2configs
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2020-04-15 17:21:54 +0200
committerlassulus <lassulus@lassul.us>2020-04-15 17:21:54 +0200
commit07f18d851a974ee594c92e3332f167ef3b1d259f (patch)
tree279e4e61a76b37a07e8440668a858cbea5a600a8 /lass/2configs
parent993a8de856df192a172c25b5e9ededc3ece3e80d (diff)
l radio: more complex track logic
Diffstat (limited to 'lass/2configs')
-rw-r--r--lass/2configs/radio.nix33
1 files changed, 28 insertions, 5 deletions
diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix
index e8ce66d3e..c4c4b0abb 100644
--- a/lass/2configs/radio.nix
+++ b/lass/2configs/radio.nix
@@ -15,7 +15,7 @@ let
${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.findutils}/bin/find "${music_dir}/the_playlist" | grep '\.ogg$' | shuf -n1 | sed 's,${music_dir}/,,')"
'';
- skip_track = pkgs.writeDashBin "skip_track" ''
+ skip_track = pkgs.writeBashBin "skip_track" ''
set -eu
${add_random}/bin/add_random
@@ -23,17 +23,32 @@ let
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 "$music_dir"/"$current_track" || echo 0)
- if [ "$skip_count" -gt 2 ]; then
- mv "$music_dir"/"$current_track" "$music_dir"/.graveyard/
- echo killing: "$track_infos"
- else
+ if [[ "$current_track" =~ ^the_playlist/music/.* ]] && [ "$skip_count" -le 2 ]; then
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"
+ else
+ mkdir -p "$music_dir"/.graveyard/
+ mv "$music_dir"/"$current_track" "$music_dir"/.graveyard/
+ echo killing: "$track_infos"
fi
${pkgs.mpc_cli}/bin/mpc -q next
'';
+ good_track = pkgs.writeBashBin "good_track" ''
+ set -eu
+
+ music_dir=${escapeShellArg music_dir}
+ current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%)
+ track_infos=$(${print_current}/bin/print_current)
+ if [[ "$current_track" =~ ^the_playlist/music/.* ]]; then
+ ${pkgs.attr}/bin/setfattr -n user.skip_count -v 0 "$music_dir"/"$current_track"
+ else
+ mv "$music_dir"/"$current_track" "$music_dir"/the_playlist/music/
+ fi
+ echo good: "$track_infos"
+ '';
+
print_current = pkgs.writeDashBin "print_current" ''
echo "$(${pkgs.mpc_cli}/bin/mpc current -f %file%) \
$(${pkgs.mpc_cli}/bin/mpc current -f %file% \
@@ -63,6 +78,7 @@ in {
krebs.per-user.${name}.packages = with pkgs; [
add_random
+ good_track
skip_track
print_current
ncmpcpp
@@ -224,6 +240,13 @@ in {
arguments = [2];
commands = {
skip.filename = "${skip_track}/bin/skip_track";
+ next.filename = "${skip_track}/bin/skip_track";
+ bad.filename = "${skip_track}/bin/skip_track";
+
+ good.filename = "${good_track}/bin/good_track";
+ nice.filename = "${good_track}/bin/good_track";
+ like.filename = "${good_track}/bin/good_track";
+
current.filename = "${print_current}/bin/print_current";
suggest.filename = pkgs.writeDash "suggest" ''
echo "$@" >> playlist_suggest