From db98837af5aef7687b12ca7a8ab336a7ed2b80ed Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 16:22:48 +0200 Subject: l 2 radio: add and use utils --- lass/2configs/radio.nix | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'lass/2configs/radio.nix') diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 8cc2a2be7..518ab8fa5 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -1,4 +1,7 @@ { config, pkgs, ... }: + +with config.krebs.lib; + let name = "radio"; mainUser = config.users.extraUsers.mainUser; @@ -7,6 +10,20 @@ let admin-password = import ; source-password = import ; + add_random = pkgs.writeDashBin "add_random" '' + mpc add "$(mpc ls | shuf -n1)" + ''; + + skip_track = pkgs.writeDashBin "skip_track" '' + ${add_random}/bin/add_random + echo skipping: "$(${print_current}/bin/print_current)" + ${pkgs.mpc_cli}/bin/mpc -q next + ''; + + print_current = pkgs.writeDashBin "print_current" '' + ${pkgs.mpc_cli}/bin/mpc current -f %file% + ''; + in { users.users = { "${name}" = rec { @@ -28,6 +45,9 @@ in { }; krebs.per-user.${name}.packages = with pkgs; [ + add_random + skip_track + print_current ncmpcpp mpc_cli tmux @@ -100,10 +120,6 @@ in { autoAdd = pkgs.writeDash "autoAdd" '' LIMIT=$1 #in secconds - addRandom () { - mpc add "$(mpc ls | shuf -n1)" - } - timeLeft () { playlistDuration=$(mpc --format '%time%' playlist | awk -F ':' 'BEGIN{t=0} {t+=$1*60+$2} END{print t}') currentTime=$(mpc status | awk '/^\[playing\]/ { sub(/\/.+/,"",$3); split($3,a,/:/); print a[1]*60+a[2] }') @@ -111,7 +127,7 @@ in { } if test $(timeLeft) -le $LIMIT; then - addRandom + ${add_random}/bin/add_random fi ''; in { -- cgit v1.2.3 From 9a8cfe0c2183242d53207e597e9bbb3a7ba91b0b Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 16:24:38 +0200 Subject: l 2 radio: add Reaktor config --- lass/2configs/radio.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lass/2configs/radio.nix') diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 518ab8fa5..99a8c0859 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -146,4 +146,23 @@ in { ExecStart = "${autoAdd} 100"; }; }; + + krebs.Reaktor = { + enable = true; + nickname = "the_playlist|r"; + channels = [ "#the_playlist" ]; + extraEnviron = { + REAKTOR_HOST = "irc.freenode.org"; + }; + plugins = with pkgs.ReaktorPlugins; [ + (buildSimpleReaktorPlugin "skip" { + script = "${skip_track}/bin/skip_track"; + pattern = "^skip$"; + }) + (buildSimpleReaktorPlugin "current" { + script = "${print_current}/bin/print_current"; + pattern = "^current$"; + }) + ]; + }; } -- cgit v1.2.3 From e7f114ae090d6d2d0b9f11f03f58797feaef016a Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 16:25:06 +0200 Subject: l 2 radio: add config for lassul.us/the_playlist --- lass/2configs/radio.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lass/2configs/radio.nix') diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 99a8c0859..2d1596e3d 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -165,4 +165,29 @@ in { }) ]; }; + krebs.nginx.servers."lassul.us".locations = let + html = pkgs.writeText "index.html" '' + + + + + lassulus playlist + + +
+ +
+
+ +
+ + + + ''; + in [ + (nameValuePair "/the_playlist" '' + default_type "text/html"; + alias ${html}; + '') + ]; } -- cgit v1.2.3 From 39be633cf42aaaa4f8a6a992fd3af4e139ab8917 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 May 2016 20:57:08 +0200 Subject: l 2 radio print_current: show youtube link --- lass/2configs/radio.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lass/2configs/radio.nix') diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 2d1596e3d..17be327b9 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -21,7 +21,9 @@ let ''; print_current = pkgs.writeDashBin "print_current" '' - ${pkgs.mpc_cli}/bin/mpc current -f %file% + echo "$(${pkgs.mpc_cli}/bin/mpc current -f %file%) \ + $(${pkgs.mpc_cli}/bin/mpc current -f %file% \ + | ${pkgs.gnused}/bin/sed 's@.*\(.\{11\}\)\.ogg@http://www.youtube.com/watch?v=\1@')" ''; in { -- cgit v1.2.3 [cgit] Unable to lock slot /tmp/cgit/28100000.lock: No such file or directory (2)