guest@dotshare [~/groups/wms/xmonad] $ ls XMonad/ | cat

XMonad (scrot) (+1 likes)

ilpianista Dec 31, 2014 (wms/xmonad)

xmonad.hs(raw, dl)

SCROT

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
--
-- xmonad config file.
--

import XMonad
--import XMonad.Actions.GridSelect
import XMonad.Actions.CycleWS
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Layout.NoBorders
import XMonad.Layout.PerWorkspace
import XMonad.Layout.SimplestFloat
import XMonad.Prompt.Shell
import XMonad.Prompt
import XMonad.Util.Run(spawnPipe)
--import System.Exit
import System.IO

import qualified XMonad.StackSet as W
import qualified Data.Map        as M

-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal :: [Char]
myTerminal = "konsole"

-- Whether focus follows the mouse pointer.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = False

-- Whether clicking on a window to focus also passes the click to the window
myClickJustFocuses :: Bool
myClickJustFocuses = False

-- Width of the window border in pixels.
--
myBorderWidth :: Dimension
myBorderWidth = 1

-- modMask lets you specify which modkey you want to use. The default
-- is mod1Mask ("left alt").  You may also consider using mod3Mask
-- ("right alt"), which does not conflict with emacs keybindings. The
-- "windows key" is usually mod4Mask.
--
myModMask :: KeyMask
myModMask = mod4Mask

-- The default number of workspaces (virtual screens) and their names.
-- By default we use numeric strings, but any string may be used as a
-- workspace name. The number of workspaces is determined by the length
-- of this list.
--
myWorkspaces = ["*","web","media","chat"] ++ map show [5..9] ++ ["dev"]

-- Border colors for unfocused and focused windows, respectively.
--
myNormalBorderColor :: [Char]
myNormalBorderColor  = "#151515"
myFocusedBorderColor :: [Char]
myFocusedBorderColor = "#303030"

--powerMenu :: [(String, X ())]
--powerMenu = [ ("lock" , spawn "qdbus org.kde.ksmserver /ScreenSaver Lock")
--            , ("suspend" , spawn "qdbus org.kde.Solid.PowerManagement /org/freedesktop/PowerManagement Suspend")
--            , ("reboot" , spawn "qdbus org.kde.ksmserver /KSMServer logout 0 1 0")
--            , ("shutdown" , spawn "qdbus org.kde.ksmserver /KSMServer logout 0 2 0")
--            ]

------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
--
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $

    -- launch a terminal
    [ ((modm,               xK_Return), spawn $ XMonad.terminal conf)

    -- launch dmenu
    , ((modm,               xK_r     ), shellPrompt myXPConfig)

    -- close focused window
    , ((modm .|. shiftMask, xK_c     ), kill)

    , ((controlMask .|. mod1Mask, xK_Escape), spawn "xkill")

     -- Rotate through the available layout algorithms
    , ((modm,               xK_space ), sendMessage NextLayout)

    --  Reset the layouts on the current workspace to default
    , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)

    -- Resize viewed windows to the correct size
    , ((modm,               xK_n     ), refresh)

    -- Move focus to the next window when they are overlapping
    , ((modm,               xK_Tab   ), windows W.focusUp >> windows W.shiftMaster)

    -- Move focus to the next window
    , ((mod1Mask,           xK_Tab   ), windows W.focusDown)

    -- Move focus to the next window
    , ((modm,               xK_j     ), windows W.focusDown)

    -- Move focus to the previous window
    , ((modm,               xK_k     ), windows W.focusUp  )

    -- Move focus to the master window
    , ((modm,               xK_m     ), windows W.focusMaster  )

    -- Swap the focused window and the master window
    , ((modm .|. shiftMask, xK_Return), windows W.swapMaster)

    -- Swap the focused window with the next window
    , ((modm .|. shiftMask, xK_j     ), windows W.swapDown  )

    -- Swap the focused window with the previous window
    , ((modm .|. shiftMask, xK_k     ), windows W.swapUp    )

    -- Shrink the master area
    , ((modm,               xK_h     ), sendMessage Shrink)

    -- Expand the master area
    , ((modm,               xK_l     ), sendMessage Expand)

    -- Push window back into tiling
    , ((modm,               xK_t     ), withFocused $ windows . W.sink)

    -- Increment the number of windows in the master area
    , ((modm              , xK_comma ), sendMessage (IncMasterN 1))

    -- Deincrement the number of windows in the master area
    , ((modm              , xK_period), sendMessage (IncMasterN (-1)))

    --, ((controlMask .|. mod1Mask, xK_l), runSelectedAction defaultGSConfig powerMenu)
    , ((controlMask .|. mod1Mask, xK_l), spawn "qdbus org.kde.ksmserver /ScreenSaver Lock")
    --, ((controlMask .|. mod1Mask, xK_l), spawn "slock")

    -- Toggle the status bar gap
    -- Use this binding with avoidStruts from Hooks.ManageDocks.
    -- See also the statusBar function from Hooks.DynamicLog.
    --
    -- , ((modm              , xK_b     ), sendMessage ToggleStruts)

    -- Quit xmonad
    --, ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))

    -- Restart xmonad
    , ((modm              , xK_q     ), spawn "xmonad --recompile; xmonad --restart")

    -- Run xmessage with a summary of the default keybindings (useful for beginners)
    --, ((modMask .|. shiftMask, xK_slash ), spawn ("echo \"" ++ help ++ "\" | xmessage -file -"))
    ]
    ++

    --
    -- mod-[1..0], Switch to workspace N
    -- mod-shift-[1..0], Move client to workspace N
    --
    [((m .|. modm, k), windows $ f i)
        | (i, k) <- zip (XMonad.workspaces conf) ([xK_1 .. xK_9] ++ [xK_0])
        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
    ++

    -- mod-{w,e}, Switch to previous/next Xinerama screen
    -- mod-shift-{w,e}, Move client to previous/next Xinerama screen
    --
    [((m .|. modm, key), sc >>= screenWorkspace >>= flip whenJust (windows . f))
        | (key, sc) <- zip [xK_w, xK_e] [(screenBy (-1)),(screenBy 1)]
        , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]

    -- Audio bindings
    ++
    [ ((0, 0x1008ff13), spawn "pactl set-sink-volume 0 +5%") -- XF86AudioRaiseVolume
    , ((0, 0x1008ff11), spawn "pactl set-sink-volume 0 -5%") -- XF86AudioLowerVolume
    , ((0, 0x1008ff12), spawn "pactl set-sink-mute 0 toggle") -- XF86AudioMute
    , ((0, 0x1008ffb2), spawn "pactl set-source-mute 1 toggle") -- XF86AudioMicMute
    ]

    -- Media bindings
    ++
    [ ((0, 0x1008ff14), spawn "playerctl play-pause") -- XF86AudioPlay
    , ((0, 0x1008ff16), spawn "playerctl previous") -- XF86AudioPrev
    , ((0, 0x1008ff17), spawn "playerctl next") -- XF86AudioNext
    , ((0, 0x1008ff15), spawn "playerctl stop") -- XF86AudioStop
    ]

    -- Brightness bindings
    ++
    [ ((0, 0x1008ff03), spawn "xbacklight -dec 20") -- XF86MonBrightnessDown
    , ((0, 0x1008ff02), spawn "xbacklight -inc 20") -- XF86MonBrightnessUp
    ]

    -- Extra bindings
    ++
    [ ((0, 0x1008ff41), spawn "firefox") -- XF86Launch1
    , ((0, 0x1008ff2d), spawn "qdbus org.kde.ksmserver /ScreenSaver Lock") -- XF86ScreenSaver
    , ((0, xK_Print  ), spawn "spectacle") -- XF86Print
    --, ((0, 0x1008ff93), spawn "") -- XF86Battery
    ]

myXPConfig :: XPConfig
myXPConfig = defaultXPConfig
    { font                = "xft:Source Code Pro:size=9"
    , bgColor             = "#151515"
    , fgColor             = "#90a959"
    , fgHLight            = "#d0d0d0"
    , bgHLight            = "#151515"
    , borderColor         = "#151515"
    , promptBorderWidth   = 0
    , position            = Top
    , height              = 18
    , showCompletionOnTab = True
    }

------------------------------------------------------------------------
-- Mouse bindings: default actions bound to mouse events
--
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $

    -- mod-button1, Set the window to floating mode and move by dragging
    [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
                                       >> windows W.shiftMaster))

    -- mod-button2, Raise the window to the top of the stack
    , ((modm, button2), (\w -> focus w >> windows W.shiftMaster))

    -- mod-button3, Set the window to floating mode and resize by dragging
    , ((modm, button3), (\w -> focus w >> mouseResizeWindow w
                                       >> windows W.shiftMaster))

    -- you may also bind events to the mouse scroll wheel (button4 and button5)
    ]

------------------------------------------------------------------------
-- Layouts:

-- You can specify and transform your layouts by modifying these values.
-- If you change layout bindings be sure to use 'mod-shift-space' after
-- restarting (with 'mod-q') to reset your layout state to the new
-- defaults, as xmonad preserves your old layout settings by default.
--
-- The available layouts.  Note that each layout is separated by |||,
-- which denotes layout choice.
--
myLayout = avoidStruts $

    -- borders automatically disappear for fullscreen windows
    smartBorders $

    -- custom layouts per workspaces
    onWorkspace "web" Full $
    onWorkspace "media" Full $

    tiled ||| Mirror tiled ||| Full ||| simplestFloat
    where
       -- default tiling algorithm partitions the screen into two panes
      tiled   = Tall nmaster delta ratio

      -- The default number of windows in the master pane
      nmaster = 1

      -- Default proportion of screen occupied by master pane
      ratio   = 1/2

      -- Percent of screen to increment by when resizing panes
      delta   = 3/100

------------------------------------------------------------------------
-- Window rules:

-- Execute arbitrary actions and WindowSet manipulations when managing
-- a new window. You can use this to, for example, always float a
-- particular program, or have a client always appear on a particular
-- workspace.
--
myManageHook = composeAll
    [ className =? "QupZilla"          --> doShift "web"
    , className =? "Firefox"           --> doShift "web"
    , resource  =? "kontact"           --> doShift "web"
    , className =? "Vlc"               --> doFloat <+> doShift "media"
    , className =? "Amarok"            --> doShift "media"
    , className =? "cantata"           --> doShift "media"
    , className =? "konversation"      --> doShift "chat"
    , className =? "ktpcontactlist"    --> doShift "chat"
    , className =? "ktp-text-ui"       --> doShift "chat"
    , className =? "Skype"             --> doShift "chat"
    , className =? "Eclipse"           --> doShift "dev"
    , className =? "QtCreator"         --> doShift "dev"
    , className =? "Designer"          --> doShift "dev"
    , className =? "Xmessage"          --> doFloat
    , className =? "stalonetray"       --> doIgnore
    , title =? "SailfishOS Emulator [Running] - Oracle VM VirtualBox" --> doFloat
    , isFullscreen                     --> doFullFloat
    ]

------------------------------------------------------------------------
-- Event handling

-- * EwmhDesktops users should change this to ewmhDesktopsEventHook
--
-- Defines a custom handler function for X Events. The function should
-- return (All True) if the default handler is to be run afterwards. To
-- combine event hooks use mappend or mconcat from Data.Monoid.
--
myEventHook = mempty

------------------------------------------------------------------------
-- Status bars and logging

-- Perform an arbitrary action on each internal state change or X event.
-- See the 'XMonad.Hooks.DynamicLog' extension for examples.
--
--myLogHook = dynamicLogWithPP $ xmobarPP

------------------------------------------------------------------------
-- Startup hook

-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
myStartupHook :: X()
myStartupHook = setWMName "LG3D" -- pre java 7 workaround for some apps

------------------------------------------------------------------------
-- Now run xmonad with all the defaults we set up.

-- Run xmonad with the settings you specify.
--
main :: IO()
main = do
    xmproc <- spawnPipe "xmobar"
    xmonad $ defaults
        { logHook = dynamicLogWithPP $ xmobarPP
            { ppOutput  = hPutStrLn xmproc
            , ppCurrent = xmobarColor "#d0d0d0" "#151515"
            , ppUrgent  = xmobarColor "#202020" "#ac4142"
            , ppVisible = xmobarColor "#90a959" "#151515"
            , ppSep     = " ~ "
            , ppOrder   = \(ws:_:t:_) -> [ws,t]
            , ppTitle   = xmobarColor "#d0d0d0" "" . shorten 140
            }
        }

-- A structure containing your configuration settings, overriding
-- fields in the default config. Any you don't override, will
-- use the defaults defined in xmonad/XMonad/Config.hs
--
defaults = defaultConfig
    { terminal           = myTerminal
    , focusFollowsMouse  = myFocusFollowsMouse
    , clickJustFocuses   = myClickJustFocuses
    , borderWidth        = myBorderWidth
    , modMask            = myModMask
    , workspaces         = myWorkspaces
    , normalBorderColor  = myNormalBorderColor
    , focusedBorderColor = myFocusedBorderColor
    , keys               = myKeys
    , mouseBindings      = myMouseBindings
    , layoutHook         = myLayout
    , manageHook         = myManageHook
    , handleEventHook    = myEventHook
    , startupHook        = myStartupHook
    }

CLICK TO VIEW

x

xmobarrc(raw, dl)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
Config {

   -- appearance
     font            = "xft:Source Code Pro:size=9,Ionicons:size=10"
   , additionalFonts = []
   , bgColor         = "#151515"
   , fgColor         = "#90a959"
   , alpha           = 255
   , position        = Top
   , border          = NoBorder
   , borderColor     = "#151515"
   , borderWidth     = 0
   , textOffset      = -1
   , iconOffset      = -1
   , iconRoot        = "."

   -- layout
   , sepChar =  "%"   -- delineator between plugin names and straight text
   , alignSep = "}{"  -- separator between left-right alignment
   , template = "%StdinReader%}{%wlp3s0wi% %default:Master% %battery% %multicpu% %date%"

   -- general behavior
   , lowerOnStart =     True    -- send to bottom of window stack on start
   , hideOnStart =      False   -- start with window unmapped (hidden)
   , allDesktops =      True    -- show on all desktops
   , overrideRedirect = True    -- set the Override Redirect flag (Xlib)
   , pickBroadest =     False   -- choose widest display (multi-monitor)
   , persistent =       True    -- enable/disable hiding (True = disabled)

   -- plugins
   --   Numbers can be automatically colored according to their value. xmobar
   --   decides color based on a three-tier/two-cutoff system, controlled by
   --   command options:
   --     --Low sets the low cutoff
   --     --High sets the high cutoff
   --
   --     --low sets the color below --Low cutoff
   --     --normal sets the color between --Low and --High cutoffs
   --     --High sets the color above --High cutoff
   --
   --   The --template option controls how the plugin is displayed. Text
   --   color can be set by enclosing in <fc></fc> tags. For more details
   --   see http://projects.haskell.org/xmobar/#system-monitor-plugins.
   , commands =

      [
        -- wireless network activity monitor
        Run Wireless "wlp3s0" [ "--template" , "<action=`kde5-nm-connection-editor`><fc=#6a9fb5> <essid></fc></action>"
                             ] 10

        -- volume monitor
      , Run Volume "default" "Master" [ "--template" , "<action=`pactl set-sink-mute 0 toggle`><status></action>"
                                      , "--"
                                      , "-c"         , "#aa759f"
                                      , "-o"         , ""
                                      , "-C"         , "#aa759f"
                                      , "-O"         , " <volume>"
                                      ] 10

        -- battery monitor
      , Run Battery [ "--template" , "<action=`konsole --hold -e acpi -V`><acstatus></action>"
                    , "--Low"      , "20"        -- units: %
                    , "--High"     , "80"        -- units: %
                    , "--low"      , "#ac4142"
                    , "--high"     , "#d28445"
                    , "--"
                    , "-o"         , "<fc=#d28445> <left>%</fc>"
                    , "-O"         , "<fc=#d28445> <left>%</fc>"
                    , "-i"         , "<fc=#d28445> <left>%</fc>"
                    ] 120

        -- system load monitor
      , Run MultiCpu          [ "--template" , "<action=`konsole -e htop`><fc=#f4bf75> <total>%</fc></action>"
                              ] 15

        -- time and date indicator
      , Run Date              "<action=`konsole --noclose -e cal -3`>%A, %R</action>" "date" 60

      , Run StdinReader
      ]
   }
 

x

Notes

  • using xmobar.
  • base16 colors.
  • Ionicons font for widgets icons.
  • Anonymous Pro as main font.
  • clickable widgets (they run apps).
  • dunst for notifications.