diff options
author | lassulus <lass@aidsballs.de> | 2016-05-25 16:22:48 +0200 |
---|---|---|
committer | lassulus <lass@aidsballs.de> | 2016-05-25 16:22:48 +0200 |
commit | db98837af5aef7687b12ca7a8ab336a7ed2b80ed (patch) | |
tree | 705303b3386342e67001471fd532f75672d678d2 /lass/2configs/radio.nix | |
parent | 7f889eba6b086a95fc48afb56d9b09880122c74a (diff) |
l 2 radio: add and use utils
Diffstat (limited to 'lass/2configs/radio.nix')
-rw-r--r-- | lass/2configs/radio.nix | 26 |
1 files changed, 21 insertions, 5 deletions
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 <secrets/icecast-admin-pw>; source-password = import <secrets/icecast-source-pw>; + 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 { |