-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRedShift.hs
35 lines (28 loc) · 1009 Bytes
/
RedShift.hs
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
33
34
35
module RedShift
( redShiftStart
, redShiftToggle
) where
import qualified XMonad.Util.ExtensibleState as State
import Imports
import Misc
data RedShift = RedShiftEnabled | RedShiftDisabled
deriving (Eq, Ord, Enum, Bounded, Read, Show, Typeable)
instance ExtensionClass RedShift where
initialValue = RedShiftEnabled
extensionType = PersistentExtension
redShiftStart :: XX ()
redShiftStart = redShiftUpdate =<< toXX State.get
redShiftToggle :: XX ()
redShiftToggle = do
x <- toXX State.get
let x' = nxt x
redShiftUpdate x'
toXX $ State.put x'
redShiftUpdate :: (MonadIO m, MonadReader Env m) => RedShift -> m ()
redShiftUpdate RedShiftEnabled =
-- TODO: Ideally this brightness would affect the laptop screen
-- settings to save power, *unless* an external monitor is plugged
-- in. For now preferring automatic brightness of external.
spawn "redshift" ["-l", "47:-120", "-t", "6500:3700", "-b", "1:0.4", "-r"]
redShiftUpdate RedShiftDisabled =
spawn "killall" ["redshift"]