Haron_Prime

.xmonad.hs

Mar 20th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 19.61 KB | None | 0 0
  1. import XMonad hiding ( (|||) )
  2. import Control.Monad
  3. import Data.Ratio ((%))
  4. import Foreign.C (CChar)
  5. import System.Exit
  6. import System.IO
  7. import qualified XMonad.StackSet as W
  8. import qualified Data.Map        as M
  9. import qualified Data.ByteString as B
  10.  
  11. -- Actions
  12. import XMonad.Actions.CycleWS
  13. import XMonad.Actions.FloatSnap
  14. import XMonad.Actions.FloatKeys
  15. import XMonad.Actions.OnScreen
  16. import XMonad.Actions.Promote
  17. import XMonad.Actions.SpawnOn
  18. import XMonad.Actions.SwapWorkspaces
  19. import XMonad.Actions.UpdateFocus
  20.  
  21. -- Hooks
  22. import XMonad.Hooks.DynamicLog
  23. import XMonad.Hooks.EwmhDesktops
  24. import XMonad.Hooks.InsertPosition
  25. import XMonad.Hooks.ManageDocks
  26. import XMonad.Hooks.ManageHelpers
  27. import XMonad.Hooks.Place
  28. import XMonad.Hooks.SetWMName
  29. import XMonad.Hooks.WorkspaceByPos
  30. import XMonad.Hooks.UrgencyHook hiding (Never)
  31.  
  32. -- Layouts
  33. import XMonad.Layout.Accordion
  34. import XMonad.Layout.CenteredMaster
  35. import XMonad.Layout.Grid
  36. import XMonad.Layout.IM
  37. import XMonad.Layout.LayoutCombinators
  38. import XMonad.Layout.NoBorders
  39. import XMonad.Layout.PerWorkspace
  40. import XMonad.Layout.Spacing
  41. import XMonad.Layout.TwoPane
  42. import XMonad.Layout.Tabbed
  43. import qualified XMonad.Layout.ToggleLayouts as Tog
  44.  
  45. -- Prompts
  46. import XMonad.Prompt
  47. import XMonad.Prompt.Man
  48. import XMonad.Prompt.RunOrRaise
  49. import XMonad.Prompt.Shell
  50.  
  51. -- Utils
  52. import XMonad.Util.NamedScratchpad
  53. import XMonad.Util.Run(spawnPipe)
  54. import XMonad.Util.EZConfig(additionalKeysP, additionalKeys)
  55.  
  56. myBrowser            = "/home/haron/.local/bin/firefox"
  57. myTerminal           = "urxvtc"
  58. myShell              = "zsh"
  59. myFocusFollowsMouse  :: Bool
  60. myFocusFollowsMouse  = True
  61. myBorderWidth        = 1
  62. myModMask            = mod4Mask
  63. myWorkspaces         :: [String]
  64. myWorkspaces         = [ "W", "M", "E", "F", "S", "V", "P", "J", "T" , "VM" , "IM", "XII"]
  65. myNormalBorderColor  = "#151515"
  66. myFocusedBorderColor = "#9df"
  67. myFont               = "xft:SonyEricssonLogo:size=10:antialias=true:hinting=true"
  68.  
  69. -- Key bindings.
  70. myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
  71.     [
  72.       ((0,                      0x1008ff13),     spawn "/usr/bin/pulseaudio-ctl up")
  73.     , ((0,                      0x1008ff11),     spawn "/usr/bin/pulseaudio-ctl down")
  74.     , ((0,                      0x1008ff12),     spawn "/usr/bin/pulseaudio-ctl mute")
  75.     , ((0,                      0x1008ff14),     spawn "mpc toggle")
  76.     , ((0,                      0x1008ff15),     spawn "mpc stop")
  77.     , ((0,                      0x1008ff16),     spawn "mpc prev")
  78.     , ((0,                      0x1008ff17),     spawn "mpc next")
  79.     , ((0,                      0x1008ff30),     spawn "transgui")
  80.     , ((0,                      0x1008ff18),     spawn "firefox")
  81.     , ((modm,                   0x1008ff18),     spawn "firefoxR")
  82.     , ((mod1Mask,               0x1008ff18),     spawn "foxb.sh")
  83.     , ((0       .|. shiftMask,  0x1008ff18),     spawn "foxn.sh")
  84.     , ((0,                      0x1008ff19),     spawn "thunderbird")
  85.     , ((0,                      0x1008ff5d),     spawn "pcmanfm")
  86.     , ((mod1Mask,               0x1008ff5d),     spawn "gksu pcmanfm")
  87.     , ((0,                      0x1008ff1d),     spawn "galculator")
  88.     , ((0,                      0x1008ff2f),     spawn "slock")
  89.     , ((0,                      0x1008ff81),     spawn "urxvtc -name ncmpcpp -e /usr/bin/ncmpcpp")
  90.     , ((0,                      0x1008ff1b),     spawn "urxvtc -name htop -e /usr/bin/htop")
  91.     , ((0,                      0x1008ff73),     spawn "compreboot")
  92.     , ((0,                          0xff69),     spawn "compdown")
  93.     , ((0,                          0xffc9),     spawn "urxvtc -name terminal")
  94.     , ((0,                          0xff61),     spawn "scrot -e 'mv $f ~/Pictures/Screenshots/ 2>/dev/null'")                                        --Print
  95.     , ((mod1Mask,                   0xff61),     spawn "scrot -s -e 'mv $f ~/Pictures/Screenshots/ 2>/dev/null'")                                     --Alt+Print
  96.     , ((mod1Mask,                     0x62),     spawn "baobab")                                                                                      --Alt+B
  97.     , ((mod1Mask,                     0x63),     spawn "chromium")                                                                                    --Alt+C
  98.     -- , ((mod1Mask,                     0x64),     spawn "doublecmd")                                                                                   --Alt+D
  99.     , ((mod1Mask,                     0x65),     spawn "pulseaudio-equalizer-gtk")                                                                    --Alt+E
  100.     , ((mod1Mask,                     0x66),     spawn "pavucontrol")                                                                                 --Alt+F
  101.     , ((mod1Mask,                     0x67),     spawn "gimp")                                                                                        --Alt+G
  102.     , ((mod1Mask .|. shiftMask,       0x67),     spawn "python3 /home/haron/lib/gis-weather/gis-weather.py")                                          --Alt+Shift+G
  103.     , ((mod1Mask,                     0x68),     spawn "hexchat")                                                                                     --Alt+H
  104.     , ((mod1Mask,                     0x69),     spawn "iron")                                                                                        --Alt+I
  105.     , ((mod1Mask,                     0x6c),     spawn "cat /home/haron/Documents/last.pass | cut -c 1-24 | xclip -selection clipboard")              --Alt+L
  106.     , ((mod1Mask,                     0x6d),     spawn "urxvtc -name mc -e mc")                                                              --Alt+M
  107.     -- , ((mod1Mask,                     0x6e),     spawn "xnvim")                                                                                       --Alt+N
  108.     , ((mod1Mask,                     0x6f),     spawn "soffice")                                                                                     --Alt+O
  109.     , ((mod1Mask,                     0x70),     spawn "env WINEPREFIX='/home/haron/.wine' wine '/home/haron/lib/Pro100-5.20-GIV/PRO100.exe'")        --Alt+P
  110.     , ((mod1Mask,                     0x73),     spawn "subl3")                                                                                       --Alt+S
  111.     , ((mod1Mask .|. shiftMask,       0x73),     spawn "gksu subl3")                                                                                  --Alt+Shift+S
  112.     , ((mod1Mask,                     0x74),     spawn "telegram")                                                                                    --Alt+T
  113.     , ((mod1Mask .|. shiftMask,       0x74),     spawn "tor-browser")                                                                                 --Alt+Shift+T
  114.     , ((mod1Mask,                     0x76),     spawn "urxvtc -name vim -e vim")                                                                                        --Alt+V
  115.     , ((mod1Mask,                     0x77),     spawn "gksu pacmanxg")                                                                               --Alt+W
  116.     , ((modm,                         0x71),     spawn "xmonad --recompile && xmonad --restart")                                                      --Win+Q
  117.     , ((modm     .|. shiftMask,       0x70),     spawn "dmenu_run -i -p 'Run:' -sb '#333' -nf '#999' -sf '#9df' -fn 'Terminus Re33:size=12'")         --Win+Shift+P
  118.     , ((modm,                         0x70),     spawn "gmrun")                                                                                       --Wim+P
  119.     , ((modm     .|. shiftMask,  xK_Return),     spawn $ XMonad.terminal conf)                                                                        --Win+Shift+C
  120.  
  121.     , ((mod1Mask,                   0xffbe),     manPrompt myXPConfig)                                                                                --Alt+F1
  122.     , ((mod1Mask,                   0xffbf),     shellPrompt myXPConfig)                                                                              --Alt+F2
  123.     , ((mod1Mask,                   0xffc0),     runOrRaisePrompt myXPConfig)                                                                         --Alt+F3
  124.     , ((modm,                       xK_Tab),     windows W.focusDown)                                                                                 --Alt+Tab
  125.     , ((mod1Mask,                   xK_Tab),     windows W.focusMaster)                                                                               --Win+Tab
  126.     , ((modm     .|. shiftMask,       0x63),     kill)                                                                                                --Win+Shift+C
  127.     , ((modm,                     xK_space),     sendMessage NextLayout)
  128.     , ((modm     .|. shiftMask,   xK_space),     setLayout $ XMonad.layoutHook conf)
  129.     , ((modm,                         0x6e),     refresh)                                                                                             --Win+N
  130.     , ((modm,                    xK_Escape),     toggleWS' ["NSP"])                                                                                   --Win+Escape
  131.    , ((modm,                         0x6a),     windows W.focusDown)                                                                                 --Win+J
  132.    , ((modm,                         0x6b),     windows W.focusUp)                                                                                   --Win+K
  133.    , ((modm,                         0x6d),     windows W.focusMaster)                                                                               --Win+M
  134.    , ((modm,                    xK_Return),     windows W.swapMaster)                                                                                --Win+Enter
  135.    , ((modm     .|. shiftMask,       0x6a),     windows W.swapDown)                                                                                  --Win+Shift+J
  136.    , ((modm     .|. shiftMask,       0x6b),     windows W.swapUp)                                                                                    --Win+Shift+K
  137.    , ((modm,                         0x68),     sendMessage Shrink)                                                                                  --Win+H
  138.    , ((modm,                         0x6c),     sendMessage Expand)                                                                                  --Win+L
  139.    , ((modm,                         0x74),     withFocused $ windows . W.sink)                                                                      --Win+T
  140.    , ((modm,                     xK_comma),     sendMessage (IncMasterN 1))
  141.    , ((modm,                    xK_period),     sendMessage (IncMasterN (-1)))
  142.    , ((modm,                         0x62),     sendMessage ToggleStruts)                                                                            --Win+B
  143.    , ((modm     .|. shiftMask,       0x71),     io (exitWith ExitSuccess))                                                                           --Win+Shift+Q
  144.    ]
  145.    ++
  146.  
  147.    [((m .|. modm, k), windows $ f i)
  148.        | (i, k) <- zip (XMonad.workspaces conf) [xK_1, xK_2, xK_3, xK_4, xK_5, xK_6, xK_7, xK_8, xK_9, xK_0, xK_minus, xK_equal]
  149.        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  150.    ++
  151.  
  152.    [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
  153.        | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
  154.        , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  155.  
  156. -- Mouse bindings: default actions bound to mouse events
  157. myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
  158.  
  159.    [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
  160.                                       >> windows W.shiftMaster))
  161.  
  162.    , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
  163.  
  164.    , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
  165.                                       >> windows W.shiftMaster))
  166.    ]
  167.  
  168. -- Layouts:
  169. myLayout =  avoidStruts
  170.            $ Tog.toggleLayouts (noBorders Full)
  171.            $ smartBorders
  172.            $ onWorkspace "W"  (Full  ||| tiled ||| Mirror tiled)
  173.            $ onWorkspace "M"  (tiled ||| centerMaster Grid)
  174.            $ onWorkspace "E"  (tiled ||| Mirror tiled ||| GridRatio 1)
  175.            $ onWorkspace "F"  (tiled ||| (TwoPane 0.01 0.5) ||| (Mirror $ TwoPane 0.01 0.5))
  176.            $ onWorkspace "S"  (tiled ||| Mirror tiled)
  177.            $ onWorkspace "V"  (Full  ||| Grid)
  178.            $ onWorkspace "P"  (Full  ||| (centerMaster Grid))
  179.            $ onWorkspace "J"  (Full  ||| Grid)
  180.            $ onWorkspace "T"  (Full  ||| Accordion ||| (Mirror $ Accordion))
  181.            $ onWorkspace "VM" (Full  ||| Grid)
  182.            $ onWorkspace "IM" (smartSpacing 2 $ withIM 0.17 (ClassName "psi") (GridRatio 1))
  183.            $ onWorkspace "XII"(Grid  ||| tiled ||| Mirror tiled)
  184.            $ tiled ||| Mirror tiled  ||| Full
  185.  where
  186.    tiled   = Tall nmaster delta ratio
  187.    nmaster = 1
  188.    ratio   = 0.5
  189.    delta   = 0.01
  190.  
  191. -- IMLayout
  192. myIMLayout = withIM (1%7) psi Grid
  193.    where
  194.      psi   = And (ClassName "psi") (Role "main")
  195.  
  196. -- Tabs:
  197. -- myTabConfig = defaultTheme {
  198. --           activeColor         = "#151515"
  199. --         , inactiveColor       = "#151515"
  200. --         , activeBorderColor   = "#151515"
  201. --         , inactiveBorderColor = "#151515"
  202. --         , activeTextColor     = "#9df"
  203. --         , inactiveTextColor   = "#555"
  204. --         , fontName            = "xft:Terminus Re33:size=12:antialias=true:hinting=true"
  205. --         , decoHeight          = 18
  206. --     }
  207.  
  208. -- XP
  209. myXPConfig = defaultXPConfig {
  210.          font              = "xft:Terminus Re33:size=12:antialias=true:hinting=true"
  211.        , bgColor           = "#151515"
  212.        , fgColor           = "#999"
  213.        , bgHLight          = "#151515"
  214.        , fgHLight          = "#9df"
  215.        , promptBorderWidth = 0
  216.        , position          = Top
  217.        , height            = 18
  218.        , alwaysHighlight   = True
  219.        , historySize       = 100
  220.    }
  221.  
  222. -- Window rules:
  223. myManageHook = composeAll . concat $
  224.    [
  225.      [className =? c             --> doF (W.shift "W")            | c <- myWeb]
  226.    , [className =? c             --> doF (W.shift "M")            | c <- myMail]
  227.    , [className =? c             --> doF (W.shift "E")            | c <- myEdit]
  228.    , [className =? c             --> doF (W.shift "F")            | c <- myFile]
  229.    , [className =? c             --> doF (W.shift "S")            | c <- mySystem]
  230.    , [className =? c             --> doF (W.shift "V")            | c <- myVideo]
  231.    , [className =? c             --> doF (W.shift "P")            | c <- myPic]
  232.    , [className =? c             --> doF (W.shift "J")            | c <- myWork]
  233.    , [className =? c             --> doF (W.shift "T")            | c <- myTorrent]
  234.    , [className =? c             --> doF (W.shift "VM")           | c <- myVM]
  235.    , [className =? c             --> doF (W.shift "IM")           | c <- myIM]
  236.  
  237.    , [className =? c             --> doCenterFloat                | c <- myFloatC]
  238.    , [appName   =? a             --> doCenterFloat                | a <- myFloatA]
  239.    , [title     =? t             --> doCenterFloat                | t <- myFloatT]
  240.  
  241.    , [title     =? "LibreOffice" --> doF (W.shift "E")]
  242.  
  243.    , [currentWs =? "M"           --> insertPosition Below Newer]
  244.  
  245.    , [currentWs =? "T"           --> insertPosition Below Newer]
  246.  
  247.    , [currentWs =? "E"           --> insertPosition Below Newer]
  248.  
  249.    , [currentWs =? "XII"         --> insertPosition Below Newer]
  250.  
  251.    , [resource  =? "stalonetray" --> doIgnore]
  252.  
  253.    , [isDialog                   --> doCenterFloat]
  254.  
  255.    , [isFullscreen               --> doFullFloat]
  256.  
  257.     -- , [stringProperty "WM_WINDOW_ROLE" =? "page-info"   --> doCenterFloat]
  258.  
  259.     , [stringProperty "WM_WINDOW_ROLE" =? "About"       --> doCenterFloat]
  260.  
  261.    , [transience']
  262.  
  263.     , [manageDocks]
  264.  
  265.     ]
  266.     where
  267.     myWeb     = ["Firefox","Chromium","Opera","Iron","Tor Browser"]
  268.     myMail    = ["Thunderbird"]
  269.     myEdit    = ["Subl3","Et","Wps","Wpp","Acroread","FoxitReader"]
  270.     myFile    = ["Pcmanfm"]
  271.     mySystem  = ["pacmanxg","Baobab","systemdx","GParted","Sysinfo","PkgBrowser","Systemadm","Tk","Zenmap","Xfce4-power-manager-settings"]
  272.     myVideo   = ["mpv","Vlc","Sopcast-player.py","Cheese","PornTime","Deadbeef"]
  273.     myPic     = ["Pinta","Gimp","Gimp-2.8","Inkscape"]
  274.     myWork    = ["Wine"]
  275.     myTorrent = ["Tixati","Transgui","Transmission-gtk","Transmission-remote-gtk"]
  276.     myVM      = ["VirtualBox"]
  277.     myIM      = ["Hexchat","psi","Psi","Viber","Telegram"]
  278.     -- CenterFloat
  279.     myFloatC  = ["Galculator","Shutter","Zenity","Nvidia-settings","Pulseaudio-equalizer.py","Gnome-alsamixer","Gsmartcontrol","Gis-weather.py"]
  280.     myFloatA  = ["lxappearance","xarchiver","gmrun"]
  281.     myFloatT  = ["Software Update"]
  282.  
  283. -- Event handling
  284. myEventHook = fullscreenEventHook <+> docksEventHook
  285.  
  286. -- Status bars and logging.
  287. myLogHook = dynamicLogString $ xmobarPP {
  288.           ppCurrent         = xmobarColor "#9df" ""
  289.         , ppTitle           = xmobarColor "#999" "". shorten 100
  290.         }
  291.  
  292. -- Startup hook
  293. myStartupHook = return () <+> adjustEventInput <+> setWMName "LG3D"
  294.  
  295. myScratchpads = [ NS "ncmpcpp" "urxvtc -name ncmpcpp -e ncmpcpp" (appName =? "ncmpcpp") (customFloating $ W.RationalRect 0.15 0.2 0.7 0.6)
  296.                 , NS "htop" "urxvtc -name htop -e htop" (appName =? "htop") (customFloating $ W.RationalRect 0.05 0.05 0.9 0.9)
  297.                 , NS "mc" "urxvtc -name mc -e mc" (appName =? "mc") (customFloating $ W.RationalRect 0.05 0.05 0.9 0.9)
  298.                 , NS "gpick" "gpick" (appName =? "gpick") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6)
  299.                 , NS "terminal" "urxvtc -name terminal" (appName =? "terminal") (customFloating $ W.RationalRect 0.1 0.15 0.8 0.7)
  300.                 , NS "equaliser" "urxvtc -name equaliser -e alsamixer -D equal" (appName =? "equaliser") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6)
  301.                 , NS "pavucontrol" "pavucontrol" (appName =? "pavucontrol") (customFloating $ W.RationalRect 0.2 0.2 0.6 0.6)
  302.                 , NS "feh" "feh" (className =? "feh") (customFloating $ W.RationalRect 0.05 0.05 0.9 0.9)
  303.                 , NS "Mirage" "mirage" (className =? "Mirage") (customFloating $ W.RationalRect 0.05 0.05 0.9 0.9)
  304.                 , NS "page-info" "page-info " (stringProperty "WM_WINDOW_ROLE" =? "page-info") (customFloating $ W.RationalRect 0.15 0.15 0.7 0.7)
  305.                 , NS "Organizer" "Organizer" (stringProperty "WM_WINDOW_ROLE" =? "Organizer") (customFloating $ W.RationalRect 0.1 0.1 0.8 0.8)
  306.                 ]
  307.  
  308. main = do
  309.     xmonad =<< xmobar defaults
  310. encodeCChar :: B.ByteString -> [CChar]
  311. encodeCChar = map fromIntegral . B.unpack
  312.  
  313. defaults = ewmh $ withUrgencyHookC  NoUrgencyHook urgencyConfig { suppressWhen = Focused } defaultConfig {
  314.         terminal           = myTerminal,
  315.         focusFollowsMouse  = myFocusFollowsMouse,
  316.         borderWidth        = myBorderWidth,
  317.         modMask            = myModMask,
  318.         workspaces         = myWorkspaces,
  319.         normalBorderColor  = myNormalBorderColor,
  320.         focusedBorderColor = myFocusedBorderColor,
  321.         keys               = myKeys,
  322.         mouseBindings      = myMouseBindings,
  323.         layoutHook         = avoidStruts myLayout,
  324.         manageHook         = manageHook defaultConfig <+> manageDocks <+> myManageHook <+> namedScratchpadManageHook myScratchpads <+> placeHook (smart (0.5,0.5)) <+> workspaceByPos ,
  325.         handleEventHook    = myEventHook,
  326.         logHook            = myLogHook >>= xmonadPropLog,
  327.         startupHook        = myStartupHook
  328.     }
Add Comment
Please, Sign In to add comment