diff options
| author | Joey Hess <joeyh@joeyh.name> | 2017-07-05 23:03:06 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2017-07-05 23:03:06 -0400 |
| commit | cd9e250a0122f84c60f9cc49bab81801d71284ec (patch) | |
| tree | d23cc5feb2d45dd034d66f0eef1a7ec9aa16279c | |
| parent | f07e85e89163517d0f69f6b19e425094ebd7d270 (diff) | |
Added Propellor.Property.FreeDesktop module.
This commit was sponsored by Trenton Cronholm on Patreon.
| -rw-r--r-- | debian/changelog | 6 | ||||
| -rw-r--r-- | joeyconfig.hs | 5 | ||||
| -rw-r--r-- | src/Propellor/Property/ConfFile.hs | 11 | ||||
| -rw-r--r-- | src/Propellor/Property/FreeDesktop.hs | 29 |
4 files changed, 50 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog index d36ad42c..8361403a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +propellor (4.3.1) UNRELEASED; urgency=medium + + * Added Propellor.Property.FreeDesktop module. + + -- Joey Hess <id@joeyh.name> Wed, 05 Jul 2017 22:57:42 -0400 + propellor (4.3.0) unstable; urgency=medium * DiskImage: Removed grubBooted; properties that used to need it as a diff --git a/joeyconfig.hs b/joeyconfig.hs index 8a00e87d..e61f7317 100644 --- a/joeyconfig.hs +++ b/joeyconfig.hs @@ -22,6 +22,7 @@ import qualified Propellor.Property.Postfix as Postfix import qualified Propellor.Property.Apache as Apache import qualified Propellor.Property.LetsEncrypt as LetsEncrypt import qualified Propellor.Property.LightDM as LightDM +import qualified Propellor.Property.FreeDesktop as FreeDesktop import qualified Propellor.Property.XFCE as XFCE import qualified Propellor.Property.Grub as Grub import qualified Propellor.Property.Obnam as Obnam @@ -123,7 +124,9 @@ demo = host "demo" $ props & XFCE.networkManager & XFCE.defaultPanelFor user File.OverwriteExisting & LightDM.autoLogin user - & Apt.installed ["firefox"] + & FreeDesktop.autostart "installer" "Installer" + "firefox http://127.0.0.1:8023/" + `requires` Apt.installed ["firefox"] where user = User "user" root = User "root" diff --git a/src/Propellor/Property/ConfFile.hs b/src/Propellor/Property/ConfFile.hs index b49c626e..ce092ec9 100644 --- a/src/Propellor/Property/ConfFile.hs +++ b/src/Propellor/Property/ConfFile.hs @@ -11,6 +11,7 @@ module Propellor.Property.ConfFile ( containsIniSetting, hasIniSection, lacksIniSection, + iniFileContains, ) where import Propellor.Base @@ -114,3 +115,13 @@ lacksIniSection f header = adjustIniSection (const []) -- remove all lines of section id -- add no lines if section is missing f + +-- | Specifies the whole content of a .ini file. +-- +-- Revertijg this causes the file not to exist. +iniFileContains :: FilePath -> [(IniSection, [(IniKey, String)])] -> RevertableProperty UnixLike UnixLike +iniFileContains f l = f `hasContent` content <!> notPresent f + where + content = concatMap sectioncontent l + sectioncontent (section, keyvalues) = iniHeader section : + map (\(key, value) -> key ++ "=" ++ value) keyvalues diff --git a/src/Propellor/Property/FreeDesktop.hs b/src/Propellor/Property/FreeDesktop.hs new file mode 100644 index 00000000..75dcbdfa --- /dev/null +++ b/src/Propellor/Property/FreeDesktop.hs @@ -0,0 +1,29 @@ +-- | Freedesktop.org configuration file properties. + +module Propellor.Property.FreeDesktop where + +import Propellor.Base +import Propellor.Property.ConfFile + +desktopFile :: String -> FilePath +desktopFile s = s ++ ".desktop" + +-- | Name used in a desktop file; user visible. +type Name = String + +-- | Command that a dekstop file runs. May include parameters. +type Exec = String + +-- | Specifies an autostart file. By default it will be located in the +-- system-wide autostart directory. +autostart :: FilePath -> Name -> Exec -> RevertableProperty UnixLike UnixLike +autostart f n e = ("/etc/xdg/autostart" </> f) `iniFileContains` + [ ("Desktop Entry", + [ ("Type", "Application") + , ("Version", "1.0") + , ("Name", n) + , ("Comment", "Autostart") + , ("Terminal", "False") + , ("Exec", e) + ] ) + ] |
