diff options
-rw-r--r-- | .Xdefaults | 2 | ||||
-rw-r--r-- | .config/systemd/user/emacs.service | 12 | ||||
-rw-r--r-- | .emacs | 82 | ||||
-rw-r--r-- | .xmonad/xmonad.hs | 107 |
4 files changed, 169 insertions, 34 deletions
@@ -11,4 +11,4 @@ URxvt.keysym.M-Escape: perl:keyboard-select:activate | |||
11 | URxvt.keysym.M-s: perl:keyboard-select:search | 11 | URxvt.keysym.M-s: perl:keyboard-select:search |
12 | URxvt.url-select.launcher: /home/gkleen/.nix-profile/bin/cliparg | 12 | URxvt.url-select.launcher: /home/gkleen/.nix-profile/bin/cliparg |
13 | URxvt.url-select.underline: true | 13 | URxvt.url-select.underline: true |
14 | URxvt.perl-lib: /run/current-system/sw/lib/urxvt/perl/ \ No newline at end of file | 14 | URxvt.perl-lib: /home/gkleen/.nix-profile/lib/urxvt/perl/ |
diff --git a/.config/systemd/user/emacs.service b/.config/systemd/user/emacs.service new file mode 100644 index 0000000..a552611 --- /dev/null +++ b/.config/systemd/user/emacs.service | |||
@@ -0,0 +1,12 @@ | |||
1 | [Unit] | ||
2 | Description=Emacs: the extensible, self-documenting text editor | ||
3 | |||
4 | [Service] | ||
5 | Type=forking | ||
6 | ExecStart=/bin/sh -c "emacs --daemon" | ||
7 | ExecStop=/bin/sh -c 'emacsclient --eval "(kill-emacs)"' | ||
8 | Environment=PATH=%h/bin:/var/setuid-wrappers:%h/.nix-profile/bin:%h/.nix-profile/sbin:%h/.nix-profile/lib/kde4/libexec:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/nix/var/nix/profiles/default/lib/kde4/libexec:/run/current-system/sw/bin:/run/current-system/sw/sbin:/run/current-system/sw/lib/kde4/libexec | ||
9 | Restart=always | ||
10 | |||
11 | [Install] | ||
12 | WantedBy=default.target | ||
@@ -0,0 +1,82 @@ | |||
1 | (require 'package) | ||
2 | |||
3 | (add-to-list 'package-archives | ||
4 | '("marmaled" . "http://marmalade-repo.org/packages/") t) | ||
5 | (add-to-list 'package-archives | ||
6 | '("melpa" . "http://melpa.org/packages/")) | ||
7 | (when (< emacs-major-version 24) | ||
8 | ;; For important compatibility libraries like cl-lib | ||
9 | (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) | ||
10 | |||
11 | (package-initialize) | ||
12 | |||
13 | (defun ensure-package-installed (&rest packages) | ||
14 | "Assure every package is installed, ask for installation if it’s not. | ||
15 | |||
16 | Return a list of installed packages or nil for every skipped package." | ||
17 | (mapcar | ||
18 | (lambda (package) | ||
19 | ;; (package-installed-p 'evil) | ||
20 | (if (package-installed-p package) | ||
21 | nil | ||
22 | (if (y-or-n-p (format "Package %s is missing. Install it? " package)) | ||
23 | (package-install package) | ||
24 | package))) | ||
25 | packages)) | ||
26 | |||
27 | ;; make sure to have downloaded archive description. | ||
28 | ;; Or use package-archive-contents as suggested by Nicolas Dudebout | ||
29 | (or (file-exists-p package-user-dir) | ||
30 | (package-refresh-contents)) | ||
31 | |||
32 | (ensure-package-installed 'color-theme 'evil 'evil-dvorak 'undo-tree 'zenburn-theme 'magit 'haskell-mode 'keychain-environment 'nix-mode 'mic-paren) | ||
33 | |||
34 | (package-initialize) | ||
35 | |||
36 | (add-to-list 'load-path "~/.nix-profile/share/emacs/site-lisp/") | ||
37 | (add-to-list 'load-path "/run/current-system/sw/share/emacs/site-lisp/") | ||
38 | |||
39 | (menu-bar-mode -1) | ||
40 | (scroll-bar-mode -1) | ||
41 | |||
42 | (require 'evil) | ||
43 | (evil-mode 1) | ||
44 | |||
45 | (require 'color-theme) | ||
46 | (color-theme-initialize) | ||
47 | (if (daemonp) | ||
48 | (add-hook 'after-make-frame-functions | ||
49 | (lambda (frame) | ||
50 | (with-selected-frame frame | ||
51 | (color-theme-ld-dark)))) | ||
52 | (color-theme-ld-dark) | ||
53 | ) | ||
54 | |||
55 | (global-undo-tree-mode) | ||
56 | |||
57 | (set-default-font "DejaVu Sans Mono") | ||
58 | (tool-bar-mode -1) | ||
59 | |||
60 | (global-set-key (kbd "RET") 'newline-and-indent) | ||
61 | (global-set-key (kbd "M-g") 'magit-status) | ||
62 | |||
63 | (setq backup-directory-alist `(("." . "~/.saves"))) | ||
64 | (setq delete-old-versions t | ||
65 | kept-new-versions 6 | ||
66 | kept-old-versions 2 | ||
67 | version-control t) | ||
68 | |||
69 | (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) | ||
70 | (eval-after-load "haskell-mode" | ||
71 | '(progn | ||
72 | (define-key haskell-mode-map (kbd "C-,") 'haskell-move-nested-lift) | ||
73 | (define-key haskell-mode-map (kbd "C-.") 'haskell-move-nested-right))) | ||
74 | |||
75 | (custom-set-variables | ||
76 | '(haskell-font-lock-symbols t)) | ||
77 | (add-hook 'haskell-mode-hook | ||
78 | (custom-set-faces | ||
79 | '(font-lock-type-face ((t (:foreground "PaleGreen" :weight bold)))) | ||
80 | '(font-lock-function-face ((t (:foreground "LightSkyBlue" :weight bold)))) | ||
81 | ) | ||
82 | ) | ||
diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs index 4e04fee..353041d 100644 --- a/.xmonad/xmonad.hs +++ b/.xmonad/xmonad.hs | |||
@@ -14,7 +14,7 @@ import Control.Monad.State (get) | |||
14 | import XMonad.Layout.Spiral | 14 | import XMonad.Layout.Spiral |
15 | import Data.Ratio | 15 | import Data.Ratio |
16 | import Data.List | 16 | import Data.List |
17 | import Data.Maybe (fromMaybe, listToMaybe) | 17 | import Data.Maybe (fromMaybe, listToMaybe, catMaybes) |
18 | import XMonad.Layout.Tabbed | 18 | import XMonad.Layout.Tabbed |
19 | import XMonad.Prompt | 19 | import XMonad.Prompt |
20 | import XMonad.Util.Scratchpad | 20 | import XMonad.Util.Scratchpad |
@@ -25,6 +25,7 @@ import XMonad.Layout.PerWorkspace | |||
25 | import XMonad.Layout.SimplestFloat | 25 | import XMonad.Layout.SimplestFloat |
26 | import XMonad.Layout.Renamed | 26 | import XMonad.Layout.Renamed |
27 | import XMonad.Layout.Reflect | 27 | import XMonad.Layout.Reflect |
28 | import XMonad.Layout.OnHost | ||
28 | import System.Process | 29 | import System.Process |
29 | import System.Directory (removeFile) | 30 | import System.Directory (removeFile) |
30 | import System.Posix.Files | 31 | import System.Posix.Files |
@@ -39,6 +40,9 @@ import Control.Monad (when) | |||
39 | import Graphics.X11.ExtraTypes.XF86 | 40 | import Graphics.X11.ExtraTypes.XF86 |
40 | import XMonad.Util.Cursor | 41 | import XMonad.Util.Cursor |
41 | import XMonad.Actions.Warp | 42 | import XMonad.Actions.Warp |
43 | import XMonad.Util.SpawnOnce | ||
44 | import System.Directory | ||
45 | import System.FilePath | ||
42 | 46 | ||
43 | import XMonad.Layout.IM | 47 | import XMonad.Layout.IM |
44 | 48 | ||
@@ -47,44 +51,78 @@ import XMonad.Prompt.MySsh | |||
47 | 51 | ||
48 | import Network.HostName | 52 | import Network.HostName |
49 | 53 | ||
54 | import Control.Applicative ((<$>)) | ||
55 | |||
50 | type KeyMap = Map (ButtonMask, KeySym) (X ()) | 56 | type KeyMap = Map (ButtonMask, KeySym) (X ()) |
51 | 57 | ||
52 | data Host l1 l2 = Host | 58 | data Host = Host |
53 | { hName :: HostName | 59 | { hName :: HostName |
54 | , hManageHook :: ManageHook | 60 | , hManageHook :: ManageHook |
55 | , hWsp :: Integer -> WorkspaceId | 61 | , hWsp :: Integer -> WorkspaceId |
56 | , hLayoutMod :: l1 -> l2 | 62 | , hCoWsp :: String -> Maybe WorkspaceId |
57 | , hKeysMod :: XConfig Layout -> (KeyMap -> KeyMap) | 63 | , hKeysMod :: XConfig Layout -> (KeyMap -> KeyMap) |
64 | , hScreens :: [ScreenId] | ||
58 | } | 65 | } |
59 | 66 | ||
60 | defaultHost = Host { hName = "unkown" | 67 | defaultHost = Host { hName = "unkown" |
61 | , hManageHook = composeOne [manageScratchTerm] | 68 | , hManageHook = composeOne [manageScratchTerm] |
62 | , hWsp = show | 69 | , hWsp = show |
63 | , hLayoutMod = id | 70 | , hCoWsp = const Nothing |
64 | , hKeysMod = const id | 71 | , hKeysMod = const id |
72 | , hScreens = [0,1..] | ||
65 | } | 73 | } |
66 | 74 | ||
67 | --hostFromName :: (LayoutClass l1 a, LayoutClass l2 a) => HostName -> Host (l1 a) (l2 a) | 75 | hostFromName :: HostName -> Host |
68 | hostFromName h@("vali") = defaultHost { hName = h | 76 | hostFromName h@("vali") = defaultHost { hName = h |
69 | , hManageHook = hManageHook defaultHost | 77 | , hManageHook = composeOne $ catMaybes [ Just manageScratchTerm |
70 | , hWsp = \i -> case Map.lookup i workspaceNames of | 78 | , assign "web" $ className =? ".dwb-wrapped" |
71 | Just str -> show i ++ " " ++ str | 79 | , assign "web" $ className =? "Chromium" |
72 | Nothing -> show i | 80 | , assign "work" $ className =? "Emacs" |
73 | , hLayoutMod = id | 81 | ] |
74 | , hKeysMod = \conf -> Map.union $ Map.fromList $ join $ map (spawnBindings conf) [ (xK_d, ["dwb", "dwb $(xclip -o)"]) | 82 | , hWsp = hWsp |
75 | ] | 83 | , hCoWsp = hCoWsp |
84 | , hKeysMod = \conf -> Map.union $ Map.fromList $ join $ map (spawnBindings conf) [ (xK_d, ["chromium", "chromium $(xclip -o)"]) | ||
85 | , (xK_e, ["emacsclient -c"]) | ||
86 | ] | ||
87 | , hScreens = [1, 0] ++ [2,3..] | ||
76 | } | 88 | } |
77 | where | 89 | where |
78 | workspaceNames = Map.fromList [ (1, "web") | 90 | workspaceNames = Map.fromList [ (2, "web") |
91 | , (3, "work") | ||
79 | ] | 92 | ] |
93 | hWsp = wspFromMap workspaceNames | ||
94 | hCoWsp = coWspFromMap workspaceNames | ||
95 | assign wsp test = (\wsp -> test -?> doShift wsp) <$> hCoWsp wsp | ||
80 | hostFromName _ = defaultHost | 96 | hostFromName _ = defaultHost |
81 | 97 | ||
98 | wspFromMap workspaceNames = \i -> case Map.lookup i workspaceNames of | ||
99 | Just str -> show i ++ " " ++ str | ||
100 | Nothing -> show i | ||
101 | |||
102 | coWspFromMap workspaceNames = \str -> case filter ((== str) . snd) $ Map.toList workspaceNames of | ||
103 | [] -> Nothing | ||
104 | [(i, _)] -> Just $ wspFromMap workspaceNames i | ||
105 | _ -> Nothing | ||
106 | |||
82 | spawnModifiers = [0, controlMask, shiftMask .|. controlMask] | 107 | spawnModifiers = [0, controlMask, shiftMask .|. controlMask] |
83 | spawnBindings conf (k, cmds) = zipWith (\m cmd -> ((modm .|. mod1Mask .|. m, k), spawn cmd)) spawnModifiers cmds | 108 | spawnBindings conf (k, cmds) = zipWith (\m cmd -> ((modm .|. mod1Mask .|. m, k), spawn cmd)) spawnModifiers cmds |
84 | where | 109 | where |
85 | modm = XMonad.modMask conf | 110 | modm = XMonad.modMask conf |
86 | 111 | ||
87 | manageScratchTerm = resource =? "scratchpad" -?> doRectFloat $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8) | 112 | manageScratchTerm = (resource =? "scratchpad" <||> resource =? "keysetup") -?> doRectFloat $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8) |
113 | |||
114 | tabbedLayout t = renamed [Replace "Tabbed"] $ reflectHoriz $ t CustomShrink $ tabbedTheme | ||
115 | tabbedTheme = defaultTheme { activeColor = "black" | ||
116 | , inactiveColor = "black" | ||
117 | , urgentColor = "black" | ||
118 | , activeBorderColor = "white" | ||
119 | , inactiveBorderColor = "#202020" | ||
120 | , urgentBorderColor = "#bb0000" | ||
121 | , activeTextColor = "white" | ||
122 | , inactiveTextColor = "white" | ||
123 | , urgentTextColor = "white" | ||
124 | , decoHeight = 16 | ||
125 | } | ||
88 | 126 | ||
89 | main = do | 127 | main = do |
90 | xmobarProc <- spawnPipe "xmobar" | 128 | xmobarProc <- spawnPipe "xmobar" |
@@ -95,26 +133,26 @@ main = do | |||
95 | , layoutHook = smartBorders $ avoidStruts layout' | 133 | , layoutHook = smartBorders $ avoidStruts layout' |
96 | , logHook = dynamicLogWithPP xmobarPP' | 134 | , logHook = dynamicLogWithPP xmobarPP' |
97 | , modMask = mod4Mask | 135 | , modMask = mod4Mask |
98 | , keys = \conf -> hKeysMod host conf $ myKeys' conf | 136 | , keys = \conf -> hKeysMod host conf $ myKeys' conf host |
99 | , workspaces = take (length numKeys) $ map (hWsp host) [1..] | 137 | , workspaces = take (length numKeys) $ map wsp [1..] |
100 | , startupHook = assimilateKeychain >> (sequence autostart) >> (setDefaultCursor xC_left_ptr) >> banishScreen LowerRight >> return () | 138 | , startupHook = assimilateKeychain >> (sequence autostart) >> (setDefaultCursor xC_left_ptr) >> banishScreen LowerRight >> return () |
101 | , normalBorderColor = "#202020" | 139 | , normalBorderColor = "#202020" |
102 | , focusedBorderColor = "white" | 140 | , focusedBorderColor = "white" |
103 | } | 141 | } |
104 | layout' = hLayoutMod host $ defaultLayouts | 142 | wsp = hWsp host |
143 | -- We can´t define per-host layout modifiers because we lack dependent types | ||
144 | layout' = onHost "skadhi" ( onWorkspace (wsp 1) (noBorders Full ||| withIM (1%5) (Title "Buddy List") (tabbedLayout tabbedBottomAlways)) $ | ||
145 | onWorkspace (wsp 10) (noBorders Full) $ | ||
146 | onWorkspace (wsp 2) (noBorders Full ||| tabbedLayout tabbedBottomAlways) $ | ||
147 | onWorkspace (wsp 5) (tabbedLayout tabbedBottomAlways) $ | ||
148 | onWorkspace (wsp 8) (withIM (1%5) (Title "Friends") (tabbedLayout tabbedBottomAlways)) $ | ||
149 | defaultLayouts | ||
150 | ) $ | ||
151 | onHost "vali" ( onWorkspace (wsp 2) (noBorders Full ||| tabbedLayout tabbedBottomAlways) $ | ||
152 | defaultLayouts | ||
153 | ) $ | ||
154 | defaultLayouts | ||
105 | defaultLayouts = spiralWithDir East CW (1 % 2) ||| tabbedLayout tabbedBottom ||| noBorders Full ||| simplestFloat | 155 | defaultLayouts = spiralWithDir East CW (1 % 2) ||| tabbedLayout tabbedBottom ||| noBorders Full ||| simplestFloat |
106 | tabbedLayout t = renamed [Replace "Tabbed"] $ reflectHoriz $ t CustomShrink $ tabbedTheme | ||
107 | tabbedTheme = defaultTheme { activeColor = "black" | ||
108 | , inactiveColor = "black" | ||
109 | , urgentColor = "black" | ||
110 | , activeBorderColor = "white" | ||
111 | , inactiveBorderColor = "#202020" | ||
112 | , urgentBorderColor = "#bb0000" | ||
113 | , activeTextColor = "white" | ||
114 | , inactiveTextColor = "white" | ||
115 | , urgentTextColor = "white" | ||
116 | , decoHeight = 16 | ||
117 | } | ||
118 | xmobarPP' = xmobarPP { ppOutput = hPutStrLn xmobarProc | 156 | xmobarPP' = xmobarPP { ppOutput = hPutStrLn xmobarProc |
119 | , ppTitle = shorten 50 | 157 | , ppTitle = shorten 50 |
120 | , ppSort = (liftM2 (.)) getSortByIndex $ return scratchpadFilterOutWorkspace | 158 | , ppSort = (liftM2 (.)) getSortByIndex $ return scratchpadFilterOutWorkspace |
@@ -129,10 +167,13 @@ main = do | |||
129 | xmonad $ myConfig | 167 | xmonad $ myConfig |
130 | 168 | ||
131 | autostart = [ spawnKeychain | 169 | autostart = [ spawnKeychain |
132 | , safeSpawn "urxvtd" ["-q", "-f", "-o"] | 170 | , spawnOnce "urxvtd -o" |
133 | ] | 171 | ] |
134 | 172 | ||
135 | spawnKeychain = runInTerm "" "keychain ~/.ssh/id_ecdsa ~/.ssh/id_rsa" | 173 | spawnKeychain = do |
174 | home <- liftIO getHomeDirectory | ||
175 | let keys = map ((home </>) . ("/.ssh/id_" ++)) ["ed25519", "ecdsa", "rsa"] | ||
176 | safeSpawn "urxvt" $ ["-title", "keysetup", "-e", "keychain"] ++ keys | ||
136 | 177 | ||
137 | assimilateKeychain :: X () | 178 | assimilateKeychain :: X () |
138 | assimilateKeychain = liftIO $ assimilateKeychain' >> return () | 179 | assimilateKeychain = liftIO $ assimilateKeychain' >> return () |
@@ -183,7 +224,7 @@ sshOverrides = map (\h -> mkOverride { oHost = h, oCommand = moshCmd . inTmux } | |||
183 | [ "galois", "galois.praseodym.org" | 224 | [ "galois", "galois.praseodym.org" |
184 | ] | 225 | ] |
185 | 226 | ||
186 | myKeys' conf = Map.fromList $ | 227 | myKeys' conf host = Map.fromList $ |
187 | -- launch a terminal | 228 | -- launch a terminal |
188 | [ ((modm, xK_Return), spawn $ (XMonad.terminal conf) ++ " -e tmux") | 229 | [ ((modm, xK_Return), spawn $ (XMonad.terminal conf) ++ " -e tmux") |
189 | , ((modm .|. controlMask, xK_Return), scratchpadSpawnActionCustom $ (XMonad.terminal conf) ++ " -name scratchpad -title scratchpad -e tmux") | 230 | , ((modm .|. controlMask, xK_Return), scratchpadSpawnActionCustom $ (XMonad.terminal conf) ++ " -name scratchpad -title scratchpad -e tmux") |
@@ -269,7 +310,7 @@ myKeys' conf = Map.fromList $ | |||
269 | ] | 310 | ] |
270 | ++ | 311 | ++ |
271 | [((m .|. modm .|. controlMask, k), screenWorkspace i >>= (flip whenJust) (windows . f)) | 312 | [((m .|. modm .|. controlMask, k), screenWorkspace i >>= (flip whenJust) (windows . f)) |
272 | | (i, k) <- zip [0..] [xK_g, xK_c, xK_r, xK_l] | 313 | | (i, k) <- zip (hScreens host) [xK_g, xK_c, xK_r, xK_l] |
273 | , (f, m) <- [(W.view, 0), (W.shift, shiftMask)] | 314 | , (f, m) <- [(W.view, 0), (W.shift, shiftMask)] |
274 | ] | 315 | ] |
275 | where | 316 | where |