Personal-use NixOS configuration

Create function for artist and cover art downloading

+34
+34
hosts/encryption/homes/encode42.nix
··· 5 5 ... 6 6 }: 7 7 8 + let 9 + mkConvertFunction = outputName: '' 10 + set downloadUrl $argv[1] 11 + set fileName download.tmp 12 + 13 + xh --download $downloadUrl --output $fileName 14 + 15 + set isOpaque (magick identify -format '%[opaque]' $fileName) 16 + set aspectRatio (magick $fileName -format "%[fx:w/h]" info:) 17 + 18 + set -l arguments; 19 + 20 + if test $isOpaque = "False" 21 + echo "Will replace transparency with solid color!" 22 + 23 + set -a arguments "-transparent white" 24 + end 25 + 26 + if test $aspectRatio != "1" 27 + echo "Will adjust the image's cropping!" 28 + 29 + set -a arguments "-gravity center -crop 1:1" 30 + end 31 + 32 + magick $fileName $arguments -quality 100% -verbose ${outputName} 33 + 34 + rm -f $fileName 35 + ''; 36 + in 8 37 { 9 38 imports = [ 10 39 (flakeRoot + /homes/encode42/common) ··· 25 54 26 55 (flakeRoot + /homes/shared/desktop/prismlauncher.nix) 27 56 ]; 57 + 58 + programs.fish.functions = { 59 + download_cover = mkConvertFunction "cover.jpg"; 60 + download_artist = mkConvertFunction "artist.jpg"; 61 + }; 28 62 29 63 home.packages = with pkgs; [ 30 64 ffmpeg