Xmonad/Config archive/TeXitoi's xmonad.hs

From HaskellWiki
Jump to navigation Jump to search
import XMonad hiding (Tall)
import XMonad.Actions.PhysicalScreens
import XMonad.Config.Desktop
import XMonad.Hooks.FadeInactive
import XMonad.Hooks.SetWMName
import XMonad.Layout.NoBorders
import XMonad.Layout.HintedTile
import System.Taffybar.Hooks.PagerHints (pagerHints)
import qualified Data.Map as M
import qualified XMonad.StackSet as W

main = xmonad $ pagerHints $ desktopConfig {
    modMask = mod4Mask,
    terminal = "gnome-terminal",
    keys = \c -> myKeys c `M.union` keys desktopConfig c,
    startupHook = startupHook desktopConfig >> setWMName "LG3D",
    logHook = logHook desktopConfig >> fadeInactiveLogHook 0xcccccccc,
    layoutHook = desktopLayoutModifiers . smartBorders $ tiled ||| Full,
    manageHook = myManageHook <+> manageHook desktopConfig,
    workspaces = map show [1..8],
    focusedBorderColor = "#729fcf",
    normalBorderColor = "#aaaaaa",
    borderWidth = 1
}

tiled = HintedTile 1 0.03 0.5 TopLeft Tall

myKeys conf@(XConfig {modMask = modm}) = M.fromList $
    [((modm, xK_semicolon), sendMessage (IncMasterN (-1))),
     ((mod1Mask, xK_Tab), windows W.focusDown),
     ((mod1Mask .|. shiftMask, xK_Tab), windows W.focusUp),
     ((modm .|. shiftMask, xK_l), spawn "gnome-screensaver-command -l")]
    ++
    [((modm .|. mask, key), f sc)
     | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
     , (f, mask) <- [(viewScreen, 0), (sendToScreen, shiftMask)]]
    ++
    [((modm .|. mask, key), f sc)
     | (key, sc) <- zip [xK_a, xK_u, xK_i] [0..]
     , (f, mask) <- [(viewScreen, 0), (sendToScreen, shiftMask)]]
    ++
    [((m .|. modm, k), windows $ f i)
     | (i, k) <- zip (workspaces conf) num
     , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]

num = numBepo
--num = numAzerty
numBepo = [0x22,0xab,0xbb,0x28,0x29,0x40,0x2b,0x2d,0x2f,0x2a]
numAzerty = [0x26,0xe9,0x22,0x27,0x28,0x2d,0xe8,0x5f,0xe7,0xe0]

myManageHook = composeAll $
  [className =? "Xfce4-notifyd" --> doIgnore,
   className =? "Xfrun4" --> doFloat,
   className =? "Xfce4-appfinder" --> doFloat,
   className =? "mplayer2" --> doFloat]
  ++
  [className =? c --> doShift w | (w, cs) <- wcs, c <- cs]
    where wcs = [("2", ["Midori", "Firefox", "Iceweasel", "Claws-mail"]),
                 ("4", ["Gajim"]),
                 ("5", ["Gmpc"])]

taffybar.hs

import System.Taffybar

import System.Taffybar.Systray
import System.Taffybar.TaffyPager
import System.Taffybar.SimpleClock

import System.Taffybar.Widgets.PollingBar
import System.Taffybar.Widgets.PollingGraph
import System.Taffybar.Widgets.PollingLabel

import System.Information.Memory
import System.Information.CPU

memCallback = do
  mi <- parseMeminfo
  return [memoryUsedRatio mi]

cpuCallback = do
  (userLoad, systemLoad, totalLoad) <- cpuLoad
  return [totalLoad, systemLoad]

main = do
  let memCfg = defaultGraphConfig { graphDataColors = [ (0.8, 0.2, 0.2, 1) ] }
      cpuCfg = defaultGraphConfig { graphDataColors = [ (0.45, 0.62, 0.81, 1), (1, 0, 1, 0.5) ] }
      clock = textClockNew Nothing "%Y-%m-%d %H:%M" 1
      pager = taffyPagerNew defaultPagerConfig
      mem = pollingGraphNew memCfg 1 memCallback
      cpu = pollingGraphNew cpuCfg 1 cpuCallback
      tray = systrayNew
  defaultTaffybar defaultTaffybarConfig { startWidgets = [ pager ]
                                        , endWidgets = [ clock, mem, cpu, tray ]
                                        }

taffybar.rs

 style "taffybar-default" {
   color["black"] = "#000000"
   color["white"] = "#ffffff"
   color["green"] = "#00ff00"
   color["red"]   = "#ff0000"
 
   bg[NORMAL]   = @black
   fg[NORMAL]   = @white
   text[NORMAL] = @white
   fg[PRELIGHT] = @green
   bg[PRELIGHT] = @black
 }
 
 style "taffybar-active-window" = "taffybar-default" {
   fg[NORMAL] = @white
 }
 
 style "taffybar-notification-button" = "taffybar-default" {
   text[NORMAL] = @red
   fg[NORMAL]   = @red
 }
 
 widget "Taffybar*" style "taffybar-default"
 widget "Taffybar*WindowSwitcher*label" style "taffybar-active-window"
 widget "*NotificationCloseButton" style "taffybar-notification-button"

.xsession

 export PATH=~/.cargo/bin:~/.local/bin:$PATH
 ~/.local/bin/bepo
 ~/.fehbg
 dunst &
 gnome-screensaver &
 xfce4-power-manager
 nm-applet &
 pasystray &
 xcompmgr &
 taffybar &
 exec xmonad