xmonad-extras 0.13.3 → 0.13.4
raw patch · 3 files changed
+54/−5 lines, 3 files
Files
- CHANGELOG.md +6/−0
- XMonad/Util/Brightness.hs +46/−3
- xmonad-extras.cabal +2/−2
CHANGELOG.md view
@@ -1,3 +1,9 @@+# 0.13.4++* Enable brightness plugin by default+* Add `setBrightness` function to the Brightness module+* Documentation improvements for the brightness plugin+ # 0.13.3 * Add brightness control plugin
XMonad/Util/Brightness.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE CPP#-} ----------------------------------------------------------------------------- -- | -- Module : XMonad.Util.Brightness@@ -25,8 +26,37 @@ -- To achieve this, you can: -- -- * Create a group with your user and root and give permissions to this--- group to write to the file;+-- group to write to the file. I usually follow these steps:+-- +-- * Create a group named xmonad --+-- > $ sudo groupadd xmonad+--+-- * Add user root and your user name to the group xmonad.+--+-- > $ sudo usermod -a -G xmonad root+-- > $ sudo usermod -a -G xmonad sibi+--+-- * The files under __\/sys__ are virtual. It's a RAM based filesystem through which you can access kernel data structures. The permission you give there won't persist after reboot. One of the way for persisting is creating a <https://unix.stackexchange.com/a/409780/29539 systemd script>:+--+-- > $ cat /etc/systemd/system/brightness.service+-- > [Unit]+-- > Description=Set brightness writable to everybody+-- > Before=nodered.service+-- > +-- > [Service]+-- > Type=oneshot+-- > User=root+-- > ExecStart=/bin/bash -c "chgrp -R -H xmonad /sys/class/backlight/intel_backlight && chmod g+w /sys/class/backlight/intel_backlight/brightness"+-- > +-- > [Install]+-- > WantedBy=multi-user.target+-- >+-- > $ sudo systemctl enable brightness.service+-- > $ sudo systemctl start brightness.service+-- > $ sudo systemctl status brightness.service+--+-- -- * Allow anyone to write the file through 646 permissions: __-rw-r--rw-__; -- -----------------------------------------------------------------------------@@ -34,12 +64,15 @@ ( increase , decrease , change+ , setBrightness ) where import XMonad+#if (MIN_VERSION_base(4,10,0)) import Data.Traversable (traverse)+#endif+import Prelude import System.IO (hPutStrLn, stderr)-import Data.Bitraversable (bitraverse) import Control.Monad (join) import Data.Bifunctor (first) import Control.Exception (try)@@ -47,7 +80,10 @@ import Data.ByteString.Char8 (unpack) import qualified Data.ByteString as BS +maxfile :: FilePath maxfile = "/sys/class/backlight/intel_backlight/max_brightness"++currentfile :: FilePath currentfile = "/sys/class/backlight/intel_backlight/brightness" -- | Update brightness by +100@@ -58,6 +94,12 @@ decrease :: X () decrease = liftIO $ change (+ (-100)) *> (pure ()) +-- | Change brightness to a particular level+--+-- @since 0.13.4+setBrightness :: Int -> X ()+setBrightness level = liftIO $ change (\_ -> level) *> pure ()+ -- | Perform all needed IO to update screen brightness change :: (Int -> Int) -> IO (Either () ()) change f = do@@ -82,7 +124,8 @@ _ -> Left "Could not parse string to int" printError :: Either String e -> IO (Either () e)-printError = bitraverse (hPutStrLn stderr) (pure . id)+printError es = either (\str -> hPutStrLn stderr str *> (return . Left $ ())) (\_ -> return . Left $ ()) es+ getFromFile :: FilePath -> (BS.ByteString -> Either String a) -> IO (Either String a) getFromFile filename fcast = fmap (fcast =<<) (try' $ BS.readFile filename)
xmonad-extras.cabal view
@@ -1,5 +1,5 @@ name: xmonad-extras-version: 0.13.3+version: 0.13.4 homepage: https://github.com/xmonad/xmonad-extras synopsis: Third party extensions for xmonad with wacky dependencies description: Various modules for xmonad that cannot be added to xmonad-contrib@@ -34,7 +34,7 @@ flag with_brightness description: Build module for brightness control.- default: False+ default: True flag testing description: Testing mode