summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoey Hess2015-11-24 09:53:53 -0400
committerJoey Hess2015-11-24 09:53:53 -0400
commit811ad9d4f5e907c7064d86db89a40e840b187f55 (patch)
tree51a279b3326b51dad79c1849ae62dca043a7d6b9 /src
parent7743ef8542b6490c3c42ac826a26aa0b24991f22 (diff)
found this handy conversion of my blog post to propellor property in spwhitton's repo
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/Property/SiteSpecific/JoeySites.hs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs
index d6a50309..f428d382 100644
--- a/src/Propellor/Property/SiteSpecific/JoeySites.hs
+++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs
@@ -929,3 +929,43 @@ userDirHtml = File.fileProperty "apache userdir is html" (map munge) conf
munge = replace "public_html" "html"
conf = "/etc/apache2/mods-available/userdir.conf"
+-- Alarm clock: see
+-- <http://joeyh.name/blog/entry/a_programmable_alarm_clock_using_systemd/>
+--
+-- oncalendar example value: "*-*-* 7:30"
+alarmClock :: String -> User -> String -> Property NoInfo
+alarmClock oncalendar (User user) command = combineProperties
+ "goodmorning timer installed"
+ [ "/etc/systemd/system/goodmorning.timer" `File.hasContent`
+ [ "[Unit]"
+ , "Description=good morning"
+ , ""
+ , "[Timer]"
+ , "Unit=goodmorning.service"
+ , "OnCalendar=" ++ oncalendar
+ , "WakeSystem=true"
+ , "Persistent=false"
+ , ""
+ , "[Install]"
+ , "WantedBy=multi-user.target"
+ ]
+ `onChange` (Systemd.daemonReloaded
+ `before` Systemd.restarted "goodmorning.timer")
+ , "/etc/systemd/system/goodmorning.service" `File.hasContent`
+ [ "[Unit]"
+ , "Description=good morning"
+ , "RefuseManualStart=true"
+ , "RefuseManualStop=true"
+ , "ConditionACPower=true"
+ , "StopWhenUnneeded=yes"
+ , ""
+ , "[Service]"
+ , "Type=oneshot"
+ , "ExecStart=/bin/systemd-inhibit --what=handle-lid-switch --why=goodmorning /bin/su " ++ user ++ " -c \"" ++ program ++ "\""
+ ]
+ `onChange` Systemd.daemonReloaded
+ , Systemd.enabled "goodmorning.timer"
+ , Systemd.started "goodmorning.timer"
+ , "/etc/systemd/logind.conf" `File.containsConfPair`
+ ("Login", "LidSwitchIgnoreInhibited", "no")
+ ]