summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Laptop.hs
diff options
context:
space:
mode:
authorJoey Hess2018-02-01 12:19:09 -0400
committerJoey Hess2018-02-01 12:19:09 -0400
commit141cf24148a1258a94f95ba1a6b2265070675d30 (patch)
treebb05015fa75a61b1ed3dece3d32e87cb40d00c95 /src/Propellor/Property/Laptop.hs
parent121c20726cebf3657b0b5d22d220cbdc7aa1aac4 (diff)
Laptop: New module, starting with powertopAutoTuneOnBoot.
This commit was sponsored by Brock Spratlen on Patreon.
Diffstat (limited to 'src/Propellor/Property/Laptop.hs')
-rw-r--r--src/Propellor/Property/Laptop.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Propellor/Property/Laptop.hs b/src/Propellor/Property/Laptop.hs
new file mode 100644
index 00000000..a36bda18
--- /dev/null
+++ b/src/Propellor/Property/Laptop.hs
@@ -0,0 +1,28 @@
+module Propellor.Property.Laptop where
+
+import Propellor.Base
+import qualified Propellor.Property.File as File
+import qualified Propellor.Property.Apt as Apt
+import qualified Propellor.Property.Systemd as Systemd
+
+-- | Makes powertop auto-tune the system for optimal power consumption on
+-- boot.
+powertopAutoTuneOnBoot :: RevertableProperty DebianLike DebianLike
+powertopAutoTuneOnBoot = setup <!> undo
+ `describe` "powertop auto-tune on boot"
+ where
+ setup = Systemd.enabled "powertop"
+ `requires` Apt.installed ["powertop"]
+ `requires` File.hasContent servicefile
+ [ "[Unit]"
+ , "Description=Powertop tunings"
+ , "[Service]"
+ , "ExecStart=/usr/sbin/powertop --auto-tune"
+ , "RemainAfterExit=true"
+ , "[Install]"
+ , "WantedBy=multi-user.target"
+ ]
+ undo = tightenTargets $ File.notPresent servicefile
+ `requires` check (doesFileExist servicefile)
+ (Systemd.disabled "powertop")
+ servicefile = "/etc/systemd/system/powertop.service"