This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / 3modules / fetchWallpaper.nix
2.0 kB 80 lines
1{ config, lib, pkgs, ... }: 2 3let 4 cfg = config.lass.fetchWallpaper; 5 6 fetchWallpaperScript = pkgs.writers.writeDash "fetchWallpaper" '' 7 set -euf 8 9 mkdir -p ${cfg.stateDir} 10 chmod o+rx ${cfg.stateDir} 11 cd ${cfg.stateDir} 12 (curl -s -o wallpaper.tmp -z wallpaper.tmp ${lib.escapeShellArg cfg.url} && cp wallpaper.tmp wallpaper) || : 13 feh --no-fehbg --bg-scale wallpaper 14 ''; 15 16in { 17 options.lass.fetchWallpaper = { 18 enable = lib.mkEnableOption "fetch wallpaper"; 19 url = lib.mkOption { 20 type = lib.types.str; 21 }; 22 timerConfig = lib.mkOption { 23 type = lib.types.unspecified; 24 default = { 25 OnCalendar = "*:00,10,20,30,40,50"; 26 }; 27 }; 28 stateDir = lib.mkOption { 29 type = lib.types.str; 30 default = "/var/lib/wallpaper"; 31 }; 32 display = lib.mkOption { 33 type = lib.types.str; 34 default = ":${toString config.services.xserver.display}"; 35 }; 36 unitConfig = lib.mkOption { 37 type = lib.types.attrsOf lib.types.str; 38 description = "Extra unit configuration for fetchWallpaper to define conditions and assertions for the unit"; 39 example = lib.literalExample '' 40 # do not start when running on umts 41 { ConditionPathExists = "!/var/run/ppp0.pid"; } 42 ''; 43 default = {}; 44 }; 45 }; 46 47 config = lib.mkIf cfg.enable { 48 systemd.timers.fetchWallpaper = { 49 description = "fetch wallpaper timer"; 50 wantedBy = [ "timers.target" ]; 51 52 timerConfig = cfg.timerConfig; 53 }; 54 systemd.services.fetchWallpaper = { 55 description = "fetch wallpaper"; 56 after = [ "network.target" ]; 57 58 path = with pkgs; [ 59 curl 60 feh 61 ]; 62 63 environment = { 64 URL = cfg.url; 65 DISPLAY = cfg.display; 66 }; 67 restartIfChanged = true; 68 69 serviceConfig = { 70 Type = "simple"; 71 ExecStart = fetchWallpaperScript; 72 User = "fetchWallpaper"; 73 StateDirectory = true; 74 StateDirectoryMode = "0755"; 75 }; 76 77 unitConfig = cfg.unitConfig; 78 }; 79 }; 80}