Skip to content

Instantly share code, notes, and snippets.

@miguel-negrao
Created March 10, 2016 11:53
Show Gist options
  • Select an option

  • Save miguel-negrao/fd00f718b6a5958f50e9 to your computer and use it in GitHub Desktop.

Select an option

Save miguel-negrao/fd00f718b6a5958f50e9 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where
import Turtle hiding (x)
import Prelude hiding (FilePath)
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import Filesystem.Path.CurrentOS (encodeString)
main :: IO ()
main = do
let a = "/tmp/lcd_backlight_last_value" :: Turtle.FilePath
exists <- testfile a
if exists then do
v <- TIO.readFile $ encodeString a
proc "xbacklight" ["-set", v] empty
rm a
else do
output a (inproc "xbacklight" ["-get"] empty)
void $ proc "xbacklight" ["-set", "0"] empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment