packages feed

xmonad-vanessa (empty) → 0.1.0.0

raw patch · 8 files changed

+262/−0 lines, 8 filesdep +X11dep +basedep +containers

Dependencies added: X11, base, containers, process, tibetan-utils, xmonad, xmonad-contrib, xmonad-extras, xmonad-vanessa

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Vanessa McHale (c) 2016++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Vanessa McHale nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ app/Main.hs view
@@ -0,0 +1,3 @@+import XMonad.Config.Vanessa++main = vConfig
+ app/ParseKBLayout.hs view
@@ -0,0 +1,3 @@+import XMonad.Util.Keyboard (showKBLayout)++main = show <$> showKBLayout
+ src/XMonad/Config/Vanessa.hs view
@@ -0,0 +1,81 @@+-- | Configuration with defaults I like and brightness adjustable for my computer and appropriate +module XMonad.Config.Vanessa (vConfig) where++--XMonad modules+import XMonad+import XMonad.Hooks.DynamicLog+import XMonad.Hooks.ManageDocks+import XMonad.Layout.Spiral+import XMonad.Layout.Reflect+import XMonad.Util.Run+import XMonad.Util.Volume+import XMonad.Util.Brightness+import XMonad.Util.Keyboard+import XMonad.StackSet+--Monads etc.+import qualified Data.Map as M+import Data.Monoid+import Control.Monad hiding (guard)+import Control.Monad.IO.Class++-- | IO action of the whole thing+vConfig :: IO ()+vConfig = xmonad . config =<< spawnPipe "xmobar"+    where config = myConfig++-- | Custom configuration taking in one pipe to xmobar+myConfig xmproc = def { terminal   = "gnome-terminal"+                      , keys       = newKeys+                      , layoutHook = myLayout+                      , logHook    = (vLogHook xmproc)+                      , manageHook = myManageHook }++-- | Provides custom hooks to xmonad. This disables printing the window title/connects xmobar and xmonad.+vLogHook xmproc = dynamicLogWithPP xmobarPP { ppOutput = hPutStrLn xmproc+                                            , ppTitle = const ""+                                            , ppLayout = const ""+                                            , ppHiddenNoWindows = id+                                            , ppHidden = (xmobarColor "darkorange" "black")+                                            , ppVisible = (xmobarColor "yellow" "black")+                                            }+ +-- | Doesn't work but I'm trying so hey. +myManageHook :: Query (Endo WindowSet)+myManageHook = composeAll [ resource =? "gimp"          --> doFloat+                          , resource =? "spotify"       --> doF (shift "5")+                          , resource =? "google-chrome" --> doF (shift "2")+                          ]++-- | Custom keymaps to adjust volume, brightness, and +myKeys :: XConfig t -> M.Map (KeyMask, KeySym) (X ())+myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList+             [ ((modm, xK_Up), raiseVolume 5)+             , ((modm, xK_Down), lowerVolume 5)+             , ((modm, xK_Left), brighten (-100))+             , ((modm, xK_Right), brighten 100)+             , ((modm, xK_F8), toggleMute)+             , ((modm, xK_p), spawn "yeganesh -x")+             , ((modm .|. shiftMask, xK_End), spawn "shutdown now")+             , ((modm, xK_F12), spawn "cd ~/.screenshots && scrot")+             , ((modm, xK_F1), setLang def)+             , ((modm, xK_F2), setLang tibetan)+             , ((modm, xK_F3), setLang accented)+             ]+             --alt + h and alt+l should go over by one?+             --idea: "browse" workspaces but multiple of them/autospawn in a new one?+             --overambition:vim-like window management+++-- | Function giving keybindings to undo+keysToRemove :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())+keysToRemove x@(XConfig {XMonad.modMask = modm}) = M.fromList+        [ ((modm , xK_p ), return ())+        ]++-- | Gives a better ratio for the master pane and lets us spiral windows+myLayout = avoidStruts $ normalPanes ||| reflectHoriz normalPanes ||| Full ||| spiral (16/9)+    where normalPanes = Tall 1 (3/100) (3/7)++-- | Make new key layout from a given keyboard layout+newKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())+newKeys x = myKeys x `M.union` (keys def x `M.difference` keysToRemove x)
+ src/XMonad/Util/Brightness.hs view
@@ -0,0 +1,17 @@+-- | Module to control screen brightness within the `X` Monad.+module XMonad.Util.Brightness (brighten) where++import XMonad++-- | Brighten screen+-- also consider splitting off once this has been generalized+brighten :: Int -> X ()+brighten n = liftIO $ do+    currentBacklight <- readFile "/sys/class/backlight/intel_backlight/brightness"+    length currentBacklight `seq` (writeFile "/sys/class/backlight/intel_backlight/brightness" (show . guard $ (read currentBacklight :: Int) + n))++-- | Don't let the brightness be obnoxious+guard :: Int -> Int+guard = (gu 2000) . (gl 0)+    where gu m n = if n > m then m else n+          gl m n = if n < m then m else n
+ src/XMonad/Util/Keyboard.hs view
@@ -0,0 +1,53 @@+-- | Allows to switch keyboard layouts +module XMonad.Util.Keyboard ( KbLayout (..)+                            , showKBLayout+                            , parseKB+                            , setLang+                            , tibetan+                            , accented+                            ) where++import XMonad+import XMonad.Hooks.DynamicLog+import System.Process hiding (spawn)++-- | Datatype for a keyboard layout.+data KbLayout = Simple String | Regional String String++instance Show KbLayout where+    show (Simple "us") = "US"+    show (Simple "layout") = "US"+    show (Regional "cn" "tib") = xmobarColor "yellow" "black" "Tibetan"+    show (Regional "us" "altgr-intl") = "US Extended"++-- | Set default keyboard layout to vanilla "us"+instance Default KbLayout where+    def = Simple "us"++-- | executable to yield current layout+showKBLayout :: IO ()+showKBLayout = putStrLn =<< (show <$> parseKB)++-- | Get current keyboard layout+parseKB :: IO KbLayout+parseKB = do+    out <- lines <$> readCreateProcess (shell "setxkbmap -query") ""+    let strip i = (dropWhile (==' ')) . (drop 1) . (dropWhile (/=':')) . (!!i)+    let line = flip strip out+    if length out == 3 then+        pure (Simple (line 2))+    else+        pure (Regional (line 2) (line 3))++-- | keyboard layout for typing Tibetan text+tibetan :: KbLayout+tibetan  = (Regional "cn" "tib")++-- | Alr-gr keyboard providing common accents on a US keyboard+accented :: KbLayout+accented = (Regional "us" "altgr-intl")++-- | Set keyboard layout+setLang :: KbLayout -> X ()+setLang (Simple lc) = spawn $ "setxkbmap " ++ lc+setLang (Regional lc r) = spawn $ "setxkbmap -layout " ++ lc ++ " -variant " ++ r
+ src/XMonad/Util/Volume.hs view
@@ -0,0 +1,20 @@+-- | Utils to use to control volume via amixer+module XMonad.Util.Volume where++import XMonad++-- | Generate action in the X monad to +vol :: String -> X ()+vol = spawn . ((++) "amixer -D pulse sset Master ")++-- | Mute/unmute within the `X` Monad.+toggleMute :: X ()+toggleMute = vol "toggle"++-- | Raise volume+raiseVolume :: (Integral a, Show a) => a -> X ()+raiseVolume n = vol $ (show n) ++ "%+"++-- | Lower volume+lowerVolume :: (Integral a, Show a) => a -> X ()+lowerVolume n = vol $ (show n) ++ "%-"
+ xmonad-vanessa.cabal view
@@ -0,0 +1,55 @@+name: xmonad-vanessa+version: 0.1.0.0+cabal-version: >=1.10+build-type: Simple+license: BSD3+license-file: LICENSE+copyright: 2016 Vanessa McHale+maintainer: tmchale@wisc.edu+homepage: https://github.com/vmchale/xmonad-vanessa#readme+synopsis: Custom xmonad, via stack+description:+    Please see README.md+category: Web+author: Vanessa McHale++source-repository head+    type: git+    location: https://github.com/vmchale/xmonad-vanessa++library+    exposed-modules:+        XMonad.Config.Vanessa+        XMonad.Util.Brightness+        XMonad.Util.Keyboard+        XMonad.Util.Volume+    build-depends:+        base >=4.7 && <5,+        xmonad ==0.12.*,+        xmonad-contrib ==0.12.*,+        xmonad-extras >=0.12.1 && <0.13,+        containers >=0.5.7.1 && <0.6,+        process >=1.4.2.0 && <1.5,+        X11 >=1.6.1.2 && <1.7,+        tibetan-utils >=0.1.0.3 && <0.2+    default-language: Haskell2010+    hs-source-dirs: src++executable xmonad+    main-is: Main.hs+    build-depends:+        base >=4.9.0.0 && <4.10,+        xmonad-vanessa >=0.1.0.0 && <0.2+    default-language: Haskell2010+    hs-source-dirs: app+    ghc-options: -threaded -rtsopts -with-rtsopts=-N -O3 -fllvm -optlo-O3++executable getkb+    main-is: ParseKBLayout.hs+    build-depends:+        base >=4.9.0.0 && <4.10,+        xmonad-vanessa >=0.1.0.0 && <0.2+    default-language: Haskell2010+    hs-source-dirs: app+    ghc-options: -threaded -rtsopts -with-rtsopts=-N+