summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Laptop.hs
blob: 40b3adb9a182043112ffe166eb445b5ec4ed7a22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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"

-- | Enables weekly TRIM for SSDs, using systemd's fstrim.timer,
trimSSD :: Property Linux
trimSSD = Systemd.enabled "fstrim.timer"