summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2016-02-11 11:04:19 +0100
committermakefu <github@syntax-fehler.de>2016-02-11 11:04:19 +0100
commita649befbfafaff80d1d1a10896bfc4343021797b (patch)
treea88e088bfc9e2d9744a0114dfd5d71ea8f4796d2
parent4c23e33dea4d9901b64bf287983c43862f4990f2 (diff)
k 3 fetchWallpaper: scrap predicate, use unitConfig
-rw-r--r--krebs/3modules/fetchWallpaper.nix23
-rw-r--r--makefu/2configs/fetchWallpaper.nix15
2 files changed, 15 insertions, 23 deletions
diff --git a/krebs/3modules/fetchWallpaper.nix b/krebs/3modules/fetchWallpaper.nix
index f320c7505..225f00803 100644
--- a/krebs/3modules/fetchWallpaper.nix
+++ b/krebs/3modules/fetchWallpaper.nix
@@ -12,10 +12,6 @@ let
api = {
enable = mkEnableOption "fetch wallpaper";
- predicate = mkOption {
- type = with types; nullOr path;
- default = null;
- };
url = mkOption {
type = types.str;
};
@@ -33,16 +29,20 @@ let
type = types.str;
default = ":11";
};
+ unitConfig = mkOption {
+ type = types.attrsOf types.str;
+ description = "Extra unit configuration for fetchWallpaper to define conditions and assertions for the unit";
+ example = literalExample ''
+ # do not start when running on umts
+ { ConditionPathExists = "!/var/run/ppp0.pid"; }
+ '';
+ default = {};
+ };
};
fetchWallpaperScript = pkgs.writeScript "fetchWallpaper" ''
#! ${pkgs.bash}/bin/bash
- ${optionalString (cfg.predicate != null) ''
- if ! ${cfg.predicate}; then
- echo "predicate failed - will not fetch from remote"
- exit 0
- fi
- ''}
+
mkdir -p ${shell.escape cfg.stateDir}
curl -s -o ${shell.escape cfg.stateDir}/wallpaper -z ${shell.escape cfg.stateDir}/wallpaper ${shell.escape cfg.url}
feh --no-fehbg --bg-scale ${shell.escape cfg.stateDir}/wallpaper
@@ -76,7 +76,6 @@ let
URL = cfg.url;
DISPLAY = cfg.display;
};
-
restartIfChanged = true;
serviceConfig = {
@@ -84,6 +83,8 @@ let
ExecStart = fetchWallpaperScript;
User = "fetchWallpaper";
};
+
+ unitConfig = cfg.unitConfig;
};
};
in out
diff --git a/makefu/2configs/fetchWallpaper.nix b/makefu/2configs/fetchWallpaper.nix
index b071a128d..786df6d40 100644
--- a/makefu/2configs/fetchWallpaper.nix
+++ b/makefu/2configs/fetchWallpaper.nix
@@ -1,24 +1,15 @@
{ config, pkgs, ... }:
-let
- # check if laptop runs on umts
- weaksauce-internet = with pkgs;writeScript "weaksauce-internet" ''
- #! /bin/sh
- if ${iproute}/bin/ip addr show dev ppp0 2>/dev/null \
- | ${gnugrep}/bin/grep -q inet;then
- exit 1
- fi
- '';
-
-in {
+{
krebs.fetchWallpaper = {
enable = true;
display = ":0";
- predicate = weaksauce-internet;
+ unitConfig.ConditionPathExists = "!/var/run/ppp0.pid";
timerConfig = {
OnCalendar = "*:0/30";
};
url = "http://echelon/wallpaper.png";
};
+
}