Skip to content

Commit 5555b0c

Browse files
author
Yann Hoffmann
committed
Implement adaptive xmobarrc config
1 parent 3725306 commit 5555b0c

File tree

5 files changed

+65
-36
lines changed

5 files changed

+65
-36
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Caveat emptor as always.
1717

1818
XMonad uses the build script at "$HOME/.xmonad/build" when recompiling
1919
(`xmonad --recompile`)
20+
Moving it to $HOME/.xmonad/xmonad86_64..
21+
For more information https://sitr.us/2018/05/13/build-xmonad-with-stack.html
2022

2123

2224
## How to install

src/Modules/Keys.hs

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ emacsKeys = [
6767
, ("C-M1-d" , spawn "zeal" )
6868
, ("C-M1-e" , spawn "emacs" )
6969
, ("C-M1-f" , spawn "firefox" )
70-
, ("C-M1-g" , spawn "gimp" )
70+
, ("C-M1-g" , spawn "pinta" )
7171
, ("C-M1-i" , spawn "idea-ce" )
7272
, ("C-M1-k" , spawn "kdenlive" )
7373

@@ -101,7 +101,7 @@ emacsKeys = [
101101
, ("C-M-o", scratchpadAction exclusiveSps "octave" ) -- octave
102102
, ("C-M-p", scratchpadAction exclusiveSps "python" ) -- python
103103

104-
, ("C-M-r", scratchpadAction exclusiveSps "R" ) -- R
104+
, ("C-M-r", scratchpadAction exclusiveSps "radioswissjazz.AppImage" ) -- R
105105
, ("C-M-s", scratchpadAction exclusiveSps "rambox" ) -- social media
106106
, ("C-M-t", scratchpadAction exclusiveSps "timetrack" ) -- time tracking
107107

@@ -262,8 +262,8 @@ fKeys = [xK_F1 .. xK_F9]
262262

263263
strWorkspaces, strFKeys, clickables :: [String]
264264
strFKeys = ["F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9"]
265-
strWorkspaces = ["1:idea", "2:*", "3:*", "4:*", "5:*",
266-
"6:*", "7:*", "8:*", "9:dump"]
265+
strWorkspaces = ["1", "2", "3", "4", "5",
266+
"6", "7", "8", "9"]
267267

268268
clickables = action strWorkspaces
269269
where action l = [ "<action=xdotool key super+" ++ n ++ ">" ++ ws ++ "</action>" |

src/xmonad.hs

+16-30
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import XMonad.Actions.KeyRemap
3030

3131
-- my Imports
3232
--import Modules.MyTreeSelect (treeselectAction, sshTreeselectAction, myTreeNavigation)
33-
import Modules.Keys (emacsKeys, mouseKeys, clickables, confKeys, exclusiveSps)
33+
import Modules.Keys (emacsKeys, mouseKeys, clickables, confKeys, exclusiveSps, strWorkspaces)
3434
import Modules.Others (dtXPConfig, dtXPConfig', tsDefaultConfig, pp, m)
3535
import Modules.Layouts (myManageHook, myLayoutHook)
3636
import XMonad.Hooks.RefocusLast
@@ -47,32 +47,12 @@ myBorderWidth = 3
4747
------------------------------------------------------------------------
4848
-- MAIN
4949
------------------------------------------------------------------------
50-
--main :: IO ()
51-
--main = xmonad def
52-
-- { handleEventHook = refocusLastWhen myPred <+> handleEventHook def
53-
-- , logHook = refocusLastLogHook <+> logHook def
54-
---- , layoutHook = refocusLastLayoutHook $ layoutHook def
55-
-- , keys = refocusLastKeys <+> keys def
56-
-- } where
57-
-- myPred = refocusingIsActive <||> isFloat
58-
-- refocusLastKeys cnf
59-
-- = M.fromList
60-
-- $ ((modMask cnf , xK_a), toggleFocus)
61-
-- : ((modMask cnf .|. shiftMask, xK_a), swapWithLast)
62-
-- : ((modMask cnf , xK_b), toggleRefocusing)
63-
-- : [ ( (modMask cnf .|. shiftMask, n)
64-
-- , windows =<< shiftRLWhen myPred wksp
65-
-- )
66-
-- | (n, wksp) <- zip [xK_1..xK_9] (workspaces cnf)
67-
-- ]
68-
6950
main :: IO ()
7051
--main = xmonad =<< xmobar def { modMask = mod4Mask }
71-
52+
--
7253
main = do
7354
nScreens <- countScreens
74-
-- let nScreens = 2
75-
handles <- mapM (spawnPipe . xmobarCommand) [0..nScreens-1]
55+
handles <- mapM (\(x, y) -> spawnPipe (xmobarCommand x y)) [(s, nScreens) | s <- [0..nScreens-1]]
7656

7757
xmonad $ ewmh def {
7858
manageHook = myManageHook -- how windows are opened
@@ -92,7 +72,7 @@ main = do
9272

9373
, focusFollowsMouse = False
9474
, clickJustFocuses = False
95-
, workspaces = withScreens nScreens clickables
75+
, workspaces = withScreens nScreens strWorkspaces
9676
, modMask = mod4Mask
9777
, keys = confKeys -- Workspaces
9878

@@ -107,17 +87,23 @@ main = do
10787
where myPred = refocusingIsActive <||> isFloat
10888

10989
-- TODO Refactor
110-
xmobarCommand (S screen) = unwords ["xmobar", "-x", show screen, myConfig screen]
90+
xmobarCommand (S screen) nScreens = unwords ["xmobar", "-x", show screen, myConfig screen nScreens]
11191
where
112-
myConfig 2 = "$HOME/.config/xmobar/xmobarrc_mid.hs"
113-
myConfig 0 = "$HOME/.config/xmobar/xmobarrc_left.hs"
114-
myConfig 1 = "$HOME/.config/xmobar/xmobarrc_right.hs"
92+
myConfig screen nScreens
93+
| nScreens == 1 = "$HOME/.config/xmobar/laptop/mono.hs"
94+
| nScreens == 2 && screen == 1 = "$HOME/.config/xmobar/laptop/docked_right.hs"
95+
| nScreens == 2 && screen == 0 = "$HOME/.config/xmobar/laptop/docked_laptop.hs"
96+
| nScreens == 3 && screen == 1 = "$HOME/.config/xmobar/laptop/left.hs"
97+
| nScreens == 3 && screen == 1 = "$HOME/.config/xmobar/desktop/center.hs"
98+
| nScreens == 3 && screen == 2 = "$HOME/.config/xmobar/desktop/right.hs"
99+
| otherwise = "$HOME/.config/xmobar/xmobarrc_laptop.hs"
100+
++ " --additional-logger=StdinReader"
115101

116102
addNETSupported :: Atom -> X ()
117103
addNETSupported x = withDisplay $ \dpy -> do
118104
r <- asks theRoot
119105
a_NET_SUPPORTED <- getAtom "_NET_SUPPORTED"
120-
a <- getAtom "ATOM"
106+
a <- getAtom "ATOMOSINT"
121107
liftIO $ do
122108
sup <- join . maybeToList <$> getWindowProperty32 dpy a_NET_SUPPORTED r
123109
when (fromIntegral x `notElem` sup) $
@@ -135,4 +121,4 @@ myStartupHook :: X ()
135121
myStartupHook = do
136122
spawnOnce "$HOME/system/etc/autostart.sh"
137123
setWMName "xmonad"
138-
-- setWMName "LG3D" --for the JVM
124+
setWMName "LG3D" --for the JVM

stack.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ packages:
3636
# These entries can reference officially published versions as well as
3737
# forks / in-progress versions pinned to a git hash. For example:
3838
#
39-
# extra-deps:
39+
extra-deps:
40+
- cairo-0.13.8.2@sha256:ef1709c3c4d2c6d68a9a51d9f220dccc0745f6468d2d0868c15a7ecdf8f325a1,4078
41+
- colour-2.3.6@sha256:ebdcbf15023958838a527e381ab3c3b1e99ed12d1b25efeb7feaa4ad8c37664a,2378
42+
- pango-0.13.8.2@sha256:d4057ebddade4cde3e25d7755b5e030e7a7e56fe7365afd37916a7bba46d3fd9,3917
43+
- glib-0.13.8.2@sha256:f44b829e741b3c3244d523f60b058701dfc067ff64c2ba61d43be4cccfc2663d,3156
44+
- gtk2hs-buildtools-0.13.8.3@sha256:207229eee7abff12aba2740b32131522086275e46f2e72a0f5bbc3cb781e9d4d,5304
4045
# - acme-missiles-0.3
4146
# - git: https://github.com/commercialhaskell/stack.git
4247
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
@@ -66,3 +71,4 @@ packages:
6671
#
6772
# Allow a newer minor version of GHC than the snapshot specifies
6873
# compiler-check: newer-minor
74+

stack.yaml.lock

+36-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,42 @@
33
# For more information, please see the documentation at:
44
# https://docs.haskellstack.org/en/stable/lock_files
55

6-
packages: []
6+
packages:
7+
- completed:
8+
hackage: cairo-0.13.8.2@sha256:ef1709c3c4d2c6d68a9a51d9f220dccc0745f6468d2d0868c15a7ecdf8f325a1,4078
9+
pantry-tree:
10+
size: 2830
11+
sha256: d6a9b3a15bc2e7b53fda331279cfdbc299fbf0c4be2ee8c1b6b79b924b6fdeb4
12+
original:
13+
hackage: cairo-0.13.8.2@sha256:ef1709c3c4d2c6d68a9a51d9f220dccc0745f6468d2d0868c15a7ecdf8f325a1,4078
14+
- completed:
15+
hackage: colour-2.3.6@sha256:ebdcbf15023958838a527e381ab3c3b1e99ed12d1b25efeb7feaa4ad8c37664a,2378
16+
pantry-tree:
17+
size: 1183
18+
sha256: 03f8e22f364deb86098dbfbe0bf83c896437b2355f139abdac0402658fb6ac7e
19+
original:
20+
hackage: colour-2.3.6@sha256:ebdcbf15023958838a527e381ab3c3b1e99ed12d1b25efeb7feaa4ad8c37664a,2378
21+
- completed:
22+
hackage: pango-0.13.8.2@sha256:d4057ebddade4cde3e25d7755b5e030e7a7e56fe7365afd37916a7bba46d3fd9,3917
23+
pantry-tree:
24+
size: 1506
25+
sha256: 10c335853e1d43e0b7426b33e8ddbdb90b3e318ebec4d58f0726a2f4cfb2e1c9
26+
original:
27+
hackage: pango-0.13.8.2@sha256:d4057ebddade4cde3e25d7755b5e030e7a7e56fe7365afd37916a7bba46d3fd9,3917
28+
- completed:
29+
hackage: glib-0.13.8.2@sha256:f44b829e741b3c3244d523f60b058701dfc067ff64c2ba61d43be4cccfc2663d,3156
30+
pantry-tree:
31+
size: 1625
32+
sha256: 2442a22152231a94e2f1ecfe7ddc0f4e5fb2d5ae116b371508a448bd3312ef06
33+
original:
34+
hackage: glib-0.13.8.2@sha256:f44b829e741b3c3244d523f60b058701dfc067ff64c2ba61d43be4cccfc2663d,3156
35+
- completed:
36+
hackage: gtk2hs-buildtools-0.13.8.3@sha256:207229eee7abff12aba2740b32131522086275e46f2e72a0f5bbc3cb781e9d4d,5304
37+
pantry-tree:
38+
size: 3588
39+
sha256: 1f93c6dbf2573503c48019fdf9f4662dcac494beaecccaea1873ec901eb2152f
40+
original:
41+
hackage: gtk2hs-buildtools-0.13.8.3@sha256:207229eee7abff12aba2740b32131522086275e46f2e72a0f5bbc3cb781e9d4d,5304
742
snapshots:
843
- completed:
944
size: 533252

0 commit comments

Comments
 (0)