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