From f38bf906919bd1eb4cab13c76859fb6c821ef7e3 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Sat, 2 Dec 2023 17:22:38 +0800 Subject: [PATCH] home, scripts: use fetchers --- .../graphical/nixos/scripts/bin/lofi | 109 ------------------ .../graphical/nixos/scripts/default.nix | 19 ++- 2 files changed, 14 insertions(+), 114 deletions(-) delete mode 100755 users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/bin/lofi diff --git a/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/bin/lofi b/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/bin/lofi deleted file mode 100755 index 7b00f85..0000000 --- a/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/bin/lofi +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/sh - -# i forgot where did i found this script, wasnt made by me - -command -v mpv &>/dev/null || { echo "Error: mpv is not installed." && exit 1; } - -# should work unless the link has been changed/ended/taken down... -declare -A urls=( - ["study"]="https://youtu.be/jfKfPfyJRdk" - ["chill"]="https://youtu.be/rUxyKA_-grg" - ["game"]="https://youtu.be/MVPTGNGiI-4" - ["fcc"]="https://coderadio-relay-ffm.freecodecamp.org/radio/8010/radio.mp3" -) - -declare -A messages=( - ["study"]="Playing lofi hip hop radio - beats to relax/study to" - ["chill"]="Playing lofi hip hop radio - beats to sleep/chill to" - ["game"]="Playing synthwave radio - beats to chill/game to" - ["fcc"]="Playing freeCodeCamp code Radio" -) - -usage() { - cat <= 22 && hour < 6)); then - set_station "chill" - elif ((hour >= 6 && hour < 12)); then - set_station "study" - elif ((hour >= 18 && hour < 22)); then - set_station "game" - else - set_station "fcc" - fi -} - -main() { - local url - local video=false - if [[ $# -eq 0 ]]; then - set_station_based_on_time_of_the_day - else - while [[ $# -gt 0 ]]; do - case $1 in - -s | --study | relax | study) - set_station "study" - shift - ;; - -c | --chill | sleep | chill) - set_station "chill" - shift - ;; - -g | --game | synthwave | game) - set_station "game" - shift - ;; - -f | --fcc | code | fcc) - set_station "fcc" - shift - ;; - -r | --random) - random_station_name=$(shuf -n 1 -e "${!urls[@]}") - set_station "$random_station_name" - shift - ;; - -v | --video) - video=true - shift - ;; - -h | --help) - usage - exit 0 - ;; - *) - echo "Unknown option: $1" >&2 - usage - exit 1 - ;; - esac - done - fi - - echo "${messages[$station_name]}..." - - if $video; then - mpv "$url" - else - mpv --no-video "$url" - fi -} - -main "$@" diff --git a/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/default.nix b/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/default.nix index edab979..6e65251 100644 --- a/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/default.nix +++ b/users/guanranwang/home-manager/profiles/device-type/graphical/nixos/scripts/default.nix @@ -1,8 +1,17 @@ -{...}: { +{pkgs, ...}: { home.sessionPath = ["$HOME/.local/bin"]; - home.file.".local/bin" = { - source = ./bin; - recursive = true; - executable = true; + home.file = { + ".local/bin" = { + source = ./bin; + recursive = true; + executable = true; + }; + ".local/bin/lofi" = { + source = pkgs.fetchurl { + url = "https://raw.githubusercontent.com/lime-desu/bin/main/lofi"; + hash = "sha256-hT+S/rqOHUYnnFcSDFfQht4l1DGasz1L3wDHKUWLraA="; + }; + executable = true; + }; }; }