diff --git a/home-manager/modules/nushell/default.nix b/home-manager/modules/nushell/default.nix index 6fffe93..76de5ca 100644 --- a/home-manager/modules/nushell/default.nix +++ b/home-manager/modules/nushell/default.nix @@ -33,9 +33,15 @@ in register ${pkgs.nushellPlugins.query}/bin/nu_plugin_query register ${nushell_plugin_formats}/bin/nu_plugin_formats + + use kink.nu ''; }; + xdg.configFile."nushell/scripts/kink.nu" = { + source = ./scripts/kink.nu; + }; + home.packages = with pkgs; [ carapace ]; diff --git a/home-manager/modules/nushell/scripts/kink.nu b/home-manager/modules/nushell/scripts/kink.nu new file mode 100644 index 0000000..8ff4e08 --- /dev/null +++ b/home-manager/modules/nushell/scripts/kink.nu @@ -0,0 +1,19 @@ +export def main [channel?: string] { + let playlist = (if ($channel == null) { + http get https://playerservices.streamtheworld.com/pls/KINKAAC.pls | from ini + } else if ($channel == "80s") { + http get https://playerservices.streamtheworld.com/pls/KINK_DNAAAC.pls | from ini + } else if ($channel == "distortion") { + http get https://playerservices.streamtheworld.com/pls/KINK_DISTORTIONAAC.pls | from ini + } else { + echo "Unknown channel" + exit + }) + let playlist = ($playlist.playlist | transpose | where {|x| ($x.column0 | str starts-with "File") } | get column1) + mpc clear + let streamIndex = (random integer ..($playlist | length)) + echo $"Playing stream ($streamIndex)" + let stream = ($playlist | get $streamIndex) + mpc add $stream + mpc play +} \ No newline at end of file