2016-06-21 13:43:45 +00:00
|
|
|
{ pkgs, ... }:
|
|
|
|
pkgs.writeHaskell "xmonad-lass" {
|
|
|
|
executables.xmonad = {
|
|
|
|
extra-depends = [
|
|
|
|
"containers"
|
|
|
|
"unix"
|
|
|
|
"X11"
|
|
|
|
"xmonad"
|
|
|
|
"xmonad-contrib"
|
|
|
|
"xmonad-stockholm"
|
|
|
|
];
|
2016-10-11 15:47:11 +00:00
|
|
|
text = /* haskell */ ''
|
2015-11-13 00:07:54 +00:00
|
|
|
{-# LANGUAGE DeriveDataTypeable #-} -- for XS
|
|
|
|
{-# LANGUAGE FlexibleContexts #-} -- for xmonad'
|
|
|
|
{-# LANGUAGE LambdaCase #-}
|
|
|
|
{-# LANGUAGE ScopedTypeVariables #-}
|
|
|
|
|
|
|
|
|
|
|
|
module Main where
|
2016-04-25 13:25:47 +00:00
|
|
|
import XMonad
|
2015-11-13 00:07:54 +00:00
|
|
|
|
2016-04-25 13:25:47 +00:00
|
|
|
import qualified XMonad.StackSet as W
|
2015-11-13 00:07:54 +00:00
|
|
|
import Control.Exception
|
2016-04-25 13:25:47 +00:00
|
|
|
import Data.List (isInfixOf)
|
2017-02-15 23:05:38 +00:00
|
|
|
import System.Environment (getArgs, withArgs)
|
2015-11-13 00:07:54 +00:00
|
|
|
import System.IO (hPutStrLn, stderr)
|
2016-10-11 15:47:11 +00:00
|
|
|
import System.Posix.Process (executeFile)
|
2016-04-25 13:25:47 +00:00
|
|
|
import Text.Read (readEither)
|
|
|
|
import XMonad.Actions.CopyWindow (copy, kill1)
|
2015-11-13 00:07:54 +00:00
|
|
|
import XMonad.Actions.CycleWS (toggleWS)
|
2016-04-25 13:25:47 +00:00
|
|
|
import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace, removeEmptyWorkspace)
|
|
|
|
import XMonad.Actions.DynamicWorkspaces (withWorkspace)
|
|
|
|
import XMonad.Actions.GridSelect (GSConfig(..), gridselectWorkspace, navNSearch)
|
|
|
|
import XMonad.Hooks.FloatNext (floatNext)
|
|
|
|
import XMonad.Hooks.FloatNext (floatNextHook)
|
|
|
|
import XMonad.Hooks.ManageDocks (avoidStruts, ToggleStruts(ToggleStruts))
|
|
|
|
import XMonad.Hooks.Place (placeHook, smart)
|
|
|
|
import XMonad.Hooks.UrgencyHook (focusUrgent)
|
2015-11-13 00:07:54 +00:00
|
|
|
import XMonad.Hooks.UrgencyHook (SpawnUrgencyHook(..), withUrgencyHook)
|
|
|
|
import XMonad.Layout.FixedColumn (FixedColumn(..))
|
2016-04-25 14:31:08 +00:00
|
|
|
import XMonad.Layout.Minimize (minimize, minimizeWindow, MinimizeMsg(RestoreNextMinimizedWin))
|
2016-04-25 15:24:54 +00:00
|
|
|
import XMonad.Layout.NoBorders (smartBorders)
|
2016-04-25 13:25:47 +00:00
|
|
|
import XMonad.Prompt (autoComplete, searchPredicate, XPConfig)
|
|
|
|
import XMonad.Prompt.Window (windowPromptGoto, windowPromptBringCopy)
|
2015-11-13 00:07:54 +00:00
|
|
|
import XMonad.Util.EZConfig (additionalKeysP)
|
2016-09-05 16:11:38 +00:00
|
|
|
import XMonad.Layout.SimpleFloat (simpleFloat)
|
2015-11-13 00:07:54 +00:00
|
|
|
|
2016-10-11 15:47:11 +00:00
|
|
|
import XMonad.Stockholm.Shutdown
|
2015-12-12 18:40:44 +00:00
|
|
|
|
2016-10-11 15:47:11 +00:00
|
|
|
urxvtcPath :: FilePath
|
|
|
|
urxvtcPath = "${pkgs.rxvt_unicode}/bin/urxvtc"
|
2015-11-13 00:07:54 +00:00
|
|
|
|
|
|
|
myFont :: String
|
|
|
|
myFont = "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*"
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = getArgs >>= \case
|
|
|
|
["--shutdown"] -> sendShutdownEvent
|
|
|
|
_ -> mainNoArgs
|
|
|
|
|
|
|
|
mainNoArgs :: IO ()
|
|
|
|
mainNoArgs = do
|
|
|
|
xmonad'
|
|
|
|
$ withUrgencyHook (SpawnUrgencyHook "echo emit Urgency ")
|
2016-02-17 14:01:35 +00:00
|
|
|
$ def
|
2016-10-11 15:47:11 +00:00
|
|
|
{ terminal = urxvtcPath
|
2015-11-13 00:07:54 +00:00
|
|
|
, modMask = mod4Mask
|
|
|
|
, layoutHook = smartBorders $ myLayoutHook
|
|
|
|
, manageHook = placeHook (smart (1,0)) <+> floatNextHook
|
|
|
|
, normalBorderColor = "#1c1c1c"
|
|
|
|
, focusedBorderColor = "#f000b0"
|
|
|
|
, handleEventHook = handleShutdownEvent
|
2017-02-15 23:05:38 +00:00
|
|
|
, workspaces = [ "dashboard" ]
|
2015-11-13 00:07:54 +00:00
|
|
|
} `additionalKeysP` myKeyMap
|
|
|
|
|
|
|
|
myLayoutHook = defLayout
|
|
|
|
where
|
2016-09-05 16:11:38 +00:00
|
|
|
defLayout = minimize $ ((avoidStruts $ Tall 1 (3/100) (1/2) ||| Full ||| Mirror (Tall 1 (3/100) (1/2))) ||| FixedColumn 2 80 80 1) ||| simpleFloat
|
2015-11-13 00:07:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
xmonad' :: (LayoutClass l Window, Read (l Window)) => XConfig l -> IO ()
|
|
|
|
xmonad' conf = do
|
2017-02-15 23:05:38 +00:00
|
|
|
let path = "/tmp/xmonad.state"
|
2015-11-13 00:07:54 +00:00
|
|
|
try (readFile path) >>= \case
|
|
|
|
Right content -> do
|
2016-10-11 15:47:11 +00:00
|
|
|
hPutStrLn stderr ("resuming from " ++ path)
|
2015-11-13 00:07:54 +00:00
|
|
|
withArgs ("--resume" : lines content) (xmonad conf)
|
|
|
|
Left e -> do
|
|
|
|
hPutStrLn stderr (displaySomeException e)
|
|
|
|
xmonad conf
|
|
|
|
|
|
|
|
displaySomeException :: SomeException -> String
|
|
|
|
displaySomeException = displayException
|
|
|
|
|
|
|
|
|
2016-04-25 13:25:47 +00:00
|
|
|
myKeyMap :: [([Char], X ())]
|
2015-11-13 00:07:54 +00:00
|
|
|
myKeyMap =
|
2017-03-07 18:41:25 +00:00
|
|
|
[ ("M4-<F11>", spawn "${pkgs.i3lock}/bin/i3lock -i $HOME/wallpaper/wallpaper -f")
|
2016-10-28 12:42:13 +00:00
|
|
|
, ("M4-C-p", spawn "${pkgs.scrot}/bin/scrot ~/public_html/scrot.png")
|
2016-06-30 15:24:50 +00:00
|
|
|
, ("M4-p", spawn "${pkgs.pass}/bin/passmenu --type")
|
2017-01-15 14:51:36 +00:00
|
|
|
, ("<XF86AudioRaiseVolume>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ +4%")
|
|
|
|
, ("<XF86AudioLowerVolume>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ -4%")
|
2017-01-16 16:29:41 +00:00
|
|
|
, ("<XF86MonBrightnessDown>", spawn "${pkgs.xorg.xbacklight}/bin/xbacklight -time 0 -dec 1%")
|
|
|
|
, ("<XF86MonBrightnessUp>", spawn "${pkgs.xorg.xbacklight}/bin/xbacklight -time 0 -inc 1")
|
2016-04-25 13:25:47 +00:00
|
|
|
, ("<XF86Launch1>", gridselectWorkspace gridConfig W.view)
|
2016-11-10 21:34:59 +00:00
|
|
|
, ("M4-C-k", spawn "${pkgs.xorg.xkill}/bin/xkill")
|
2015-11-13 00:07:54 +00:00
|
|
|
|
|
|
|
, ("M4-a", focusUrgent)
|
2016-04-25 13:25:47 +00:00
|
|
|
, ("M4-S-r", renameWorkspace def)
|
|
|
|
, ("M4-S-a", addWorkspacePrompt def)
|
2015-11-13 00:07:54 +00:00
|
|
|
, ("M4-S-<Backspace>", removeEmptyWorkspace)
|
|
|
|
, ("M4-S-c", kill1)
|
|
|
|
, ("M4-<Esc>", toggleWS)
|
2016-10-11 15:47:11 +00:00
|
|
|
, ("M4-S-<Enter>", spawn urxvtcPath)
|
|
|
|
, ("M4-x", floatNext True >> spawn urxvtcPath)
|
2015-11-13 00:07:54 +00:00
|
|
|
, ("M4-f", floatNext True)
|
|
|
|
, ("M4-b", sendMessage ToggleStruts)
|
|
|
|
|
2016-04-25 13:25:47 +00:00
|
|
|
, ("M4-v", withWorkspace autoXPConfig (windows . W.view))
|
|
|
|
, ("M4-S-v", withWorkspace autoXPConfig (windows . W.shift))
|
|
|
|
, ("M4-C-v", withWorkspace autoXPConfig (windows . copy))
|
2015-11-13 00:07:54 +00:00
|
|
|
|
2016-04-25 14:31:08 +00:00
|
|
|
, ("M4-m", withFocused minimizeWindow)
|
|
|
|
, ("M4-S-m", sendMessage RestoreNextMinimizedWin)
|
|
|
|
|
2016-04-25 13:25:47 +00:00
|
|
|
, ("M4-q", windowPromptGoto infixAutoXPConfig)
|
|
|
|
, ("M4-C-q", windowPromptBringCopy infixAutoXPConfig)
|
2015-11-13 00:07:54 +00:00
|
|
|
|
|
|
|
, ("M4-S-q", return ())
|
2017-01-10 15:18:00 +00:00
|
|
|
|
|
|
|
, ("M4-w", floatNext True >> spawn "${pkgs.copyq}/bin/copyq show")
|
2015-11-13 00:07:54 +00:00
|
|
|
]
|
|
|
|
|
2016-10-11 15:47:11 +00:00
|
|
|
forkFile :: FilePath -> [String] -> Maybe [(String, String)] -> X ()
|
|
|
|
forkFile path args env =
|
|
|
|
xfork (executeFile path False args env) >> return ()
|
|
|
|
|
2016-04-25 13:25:47 +00:00
|
|
|
autoXPConfig :: XPConfig
|
|
|
|
autoXPConfig = def
|
2015-11-13 00:07:54 +00:00
|
|
|
{ autoComplete = Just 5000
|
|
|
|
}
|
|
|
|
|
2016-04-25 13:25:47 +00:00
|
|
|
infixAutoXPConfig :: XPConfig
|
|
|
|
infixAutoXPConfig = autoXPConfig
|
|
|
|
{ searchPredicate = isInfixOf
|
2015-11-13 00:07:54 +00:00
|
|
|
}
|
|
|
|
|
2016-04-25 13:25:47 +00:00
|
|
|
gridConfig :: GSConfig WorkspaceId
|
|
|
|
gridConfig = def
|
2016-04-27 10:53:59 +00:00
|
|
|
{ gs_cellwidth = 100
|
|
|
|
, gs_cellheight = 30
|
2016-04-25 13:25:47 +00:00
|
|
|
, gs_cellpadding = 2
|
2015-11-13 00:07:54 +00:00
|
|
|
, gs_navigate = navNSearch
|
2016-04-25 13:25:47 +00:00
|
|
|
, gs_font = myFont
|
2015-11-13 00:07:54 +00:00
|
|
|
}
|
2016-06-21 13:43:45 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|