diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2021-01-03 00:55:29 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2021-01-03 16:21:34 +0100 |
commit | 4a3d2a8ddaf4e546df360656bc54b2947bdb890b (patch) | |
tree | f571511e0b74fbd7e78f7e10966a8d6d5d400241 /accounts | |
parent | 3b5ab82fa714a0d483a7b90d60f9f7c857646e33 (diff) | |
download | nixos-4a3d2a8ddaf4e546df360656bc54b2947bdb890b.tar nixos-4a3d2a8ddaf4e546df360656bc54b2947bdb890b.tar.gz nixos-4a3d2a8ddaf4e546df360656bc54b2947bdb890b.tar.bz2 nixos-4a3d2a8ddaf4e546df360656bc54b2947bdb890b.tar.xz nixos-4a3d2a8ddaf4e546df360656bc54b2947bdb890b.zip |
gkleen@sif: import
Diffstat (limited to 'accounts')
22 files changed, 2231 insertions, 1 deletions
diff --git a/accounts/gkleen@sif.nix b/accounts/gkleen@sif.nix deleted file mode 100644 index c157af78..00000000 --- a/accounts/gkleen@sif.nix +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | { ... }: {} | ||
diff --git a/accounts/gkleen@sif/autorandr-profiles/bstr.nix b/accounts/gkleen@sif/autorandr-profiles/bstr.nix new file mode 100644 index 00000000..527f8321 --- /dev/null +++ b/accounts/gkleen@sif/autorandr-profiles/bstr.nix | |||
@@ -0,0 +1,21 @@ | |||
1 | { | ||
2 | fingerprint = { | ||
3 | "eDP-1-1" = "00ffffffffffff004c83414100000000131d0104b5221378029491ae513eb7240b505400000001010101010101010101010101010101f0d40040f17018803020440058c21000001bf0d40040f17018803020440058c21000001b0000000f00ff093cff093c2c800000000000000000fe0041544e413536575230382d3020011502030f00e3058000e6060501736d0700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ab"; | ||
4 | "DP-1.3" = "00ffffffffffff000469a3289bdd00000b190104a53e22783a1cb5a3574fa0270d5054bfef00d1c0814081809500b300714f81c0010122cc0050f0703e80181035006d552100001a04740030f2705a80b0588a006d552100001a000000fd001e5018a03c041100f0f838f03c000000fc0041535553205042323837510a2001a8020327714f0102031112130414051f900e0f1d1e23091707830100006a030c0010000078200000565e00a0a0a02950302035006d552100001ee26800a0a0402e60302036006d552100001a011d00bc52d01e20b82855406d552100001e8c0ad090204031200c4055006d55210000180000000000000000000000000000000064"; | ||
5 | }; | ||
6 | config = { | ||
7 | "DP-1.3" = { | ||
8 | enable = true; | ||
9 | primary = true; | ||
10 | position = "3840x0"; | ||
11 | rate = "60"; | ||
12 | mode = "3840x2160"; | ||
13 | }; | ||
14 | eDP-1-1 = { | ||
15 | enable = true; | ||
16 | primary = false; | ||
17 | position = "0x0"; | ||
18 | mode = "3840x2160"; | ||
19 | }; | ||
20 | }; | ||
21 | } | ||
diff --git a/accounts/gkleen@sif/autorandr-profiles/default.nix b/accounts/gkleen@sif/autorandr-profiles/default.nix new file mode 100644 index 00000000..304b4afe --- /dev/null +++ b/accounts/gkleen@sif/autorandr-profiles/default.nix | |||
@@ -0,0 +1,13 @@ | |||
1 | { | ||
2 | fingerprint = { | ||
3 | eDP-1-1 = "00ffffffffffff004c83414100000000131d0104b5221378029491ae513eb7240b505400000001010101010101010101010101010101f0d40040f17018803020440058c21000001bf0d40040f17018803020440058c21000001b0000000f00ff093cff093c2c800000000000000000fe0041544e413536575230382d3020011502030f00e3058000e6060501736d0700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ab"; | ||
4 | }; | ||
5 | config = { | ||
6 | eDP-1-1 = { | ||
7 | enable = true; | ||
8 | primary = true; | ||
9 | position = "0x0"; | ||
10 | mode = "3840x2160"; | ||
11 | }; | ||
12 | }; | ||
13 | } | ||
diff --git a/accounts/gkleen@sif/backup-patterns b/accounts/gkleen@sif/backup-patterns new file mode 100644 index 00000000..d9d12f5b --- /dev/null +++ b/accounts/gkleen@sif/backup-patterns | |||
@@ -0,0 +1,24 @@ | |||
1 | R . | ||
2 | |||
3 | - pp:.cache | ||
4 | - pp:.antigen | ||
5 | + pf:.cabal/config | ||
6 | - pp:.cabal | ||
7 | + pf:.stack/config.yaml | ||
8 | - pp:.stack | ||
9 | - pp:.nox | ||
10 | - pp:.local/share/Steam | ||
11 | - sh:**/.stack-work | ||
12 | - sh:**/.~lock.* | ||
13 | - sh:**/.gup | ||
14 | + pf:.config/pulse/default.pa | ||
15 | - pp:.config/pulse | ||
16 | - pp:.zplug/log | ||
17 | - pp:.zplug/cache | ||
18 | - pp:.compose-cache | ||
19 | - pp:.undo-tree | ||
20 | - pp:.saves | ||
21 | - pp:.mozilla | ||
22 | - pp:Downloads/tmp | ||
23 | - pp:secret | ||
24 | - pp:mail \ No newline at end of file | ||
diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix new file mode 100644 index 00000000..9f2df668 --- /dev/null +++ b/accounts/gkleen@sif/default.nix | |||
@@ -0,0 +1,181 @@ | |||
1 | { flake, userName, pkgs, customUtils, lib, config, ... }: | ||
2 | let | ||
3 | cfg = config.home-manager.users.${userName}; | ||
4 | xmonad = import ./xmonad pkgs.haskellPackages; | ||
5 | in { | ||
6 | imports = with flake.nixosModules.userProfiles.${userName}; [ | ||
7 | mpv | ||
8 | ]; | ||
9 | |||
10 | home-manager.users.${userName} = { | ||
11 | programs = { | ||
12 | ssh = { | ||
13 | matchBlocks = import ./ssh-hosts.nix; # customUtils.recImport { dir = ./ssh-hosts; }; | ||
14 | extraConfig = '' | ||
15 | Match host uniworx3.ifi.lmu.de,uniworx4.ifi.lmu.de,uni2workgw.ifi.lmu.de,blackbeard.tcs.ifi.lmu.de,gitlab2.rz.ifi.lmu.de,oregon.tcs.ifi.lmu.de !exec "nc -z -w 1 %h %p &>/dev/null" | ||
16 | ProxyJump gate | ||
17 | ''; | ||
18 | }; | ||
19 | |||
20 | emacs = { | ||
21 | enable = true; | ||
22 | extraPackages = epkgs: with epkgs; [ | ||
23 | evil evil-dvorak evil-magit undo-tree magit haskell-mode | ||
24 | nix-mode yaml-mode json-mode shakespeare-mode | ||
25 | smart-mode-line highlight-parentheses highlight-symbol | ||
26 | notmuch ag sass-mode lua-mode | ||
27 | ]; | ||
28 | }; | ||
29 | firefox = { | ||
30 | enable = true; | ||
31 | profiles.default = { | ||
32 | settings = { | ||
33 | "layout.css.devPixelsPerPx" = "1.75"; | ||
34 | "browser.tabs.drawInTitlebar" = false; | ||
35 | "toolkit.legacyUserProfileCustomizations.stylesheets" = true; | ||
36 | }; | ||
37 | }; | ||
38 | }; | ||
39 | |||
40 | urxvt = { | ||
41 | enable = true; | ||
42 | package = pkgs.rxvt_unicode-with-plugins; | ||
43 | fonts = [ "xft:Fira Mono for Powerline:style=Medium:pixelsize=20" ]; | ||
44 | scroll = { | ||
45 | lines = 0; | ||
46 | bar.enable = false; | ||
47 | }; | ||
48 | extraConfig = { | ||
49 | urgentOnBell = false; | ||
50 | print-pipe = "cat >/dev/null"; | ||
51 | perl-ext-common = "52-osc,url-select"; | ||
52 | "url-select.launcher" = "firefox"; | ||
53 | "url-select.underline" = true; | ||
54 | }; | ||
55 | keybindings = { | ||
56 | "M-u" = "perl:url-select:select_next"; | ||
57 | }; | ||
58 | }; | ||
59 | |||
60 | zathura = { | ||
61 | enable = true; | ||
62 | package = pkgs.zathura.override { useMupdf = false; }; | ||
63 | }; | ||
64 | |||
65 | mpv.config = { | ||
66 | demuxer-max-bytes = 1073741824; | ||
67 | demuxer-max-back-bytes = 268435456; | ||
68 | }; | ||
69 | |||
70 | autorandr = { | ||
71 | enable = true; | ||
72 | hooks.postswitch = { | ||
73 | # "restart-compton" = "${pkgs.systemd}/bin/systemctl --user try-restart picom"; | ||
74 | "restart-trays" = '' | ||
75 | ${pkgs.coreutils}/bin/sleep 5 | ||
76 | ${pkgs.systemd}/bin/systemctl --user try-restart trayer xmobar | ||
77 | ''; | ||
78 | }; | ||
79 | profiles = customUtils.recImport { dir = ./autorandr-profiles; }; | ||
80 | }; | ||
81 | }; | ||
82 | |||
83 | services = { | ||
84 | dunst = { | ||
85 | settings = import ./dunst-settings.nix; | ||
86 | iconTheme = cfg.gtk.iconTheme; | ||
87 | enable = true; | ||
88 | }; | ||
89 | emacs.enable = true; | ||
90 | gpg-agent = { | ||
91 | enable = true; | ||
92 | enableSshSupport = true; | ||
93 | extraConfig = '' | ||
94 | pinentry-program ${pkgs.pinentry-gtk2}/bin/pinentry | ||
95 | grab | ||
96 | ''; | ||
97 | }; | ||
98 | pasystray.enable = true; | ||
99 | udiskie = { | ||
100 | enable = true; | ||
101 | automount = false; | ||
102 | }; | ||
103 | unclutter = { | ||
104 | enable = true; | ||
105 | timeout = 5; | ||
106 | }; | ||
107 | network-manager-applet.enable = true; | ||
108 | blueman-applet.enable = true; | ||
109 | |||
110 | sxhkd = { | ||
111 | enable = true; | ||
112 | keybindings = { | ||
113 | "button8" = "pacmd set-source-mute @DEFAULT_SOURCE@ 0"; | ||
114 | "@button8" = "pacmd set-source-mute @DEFAULT_SOURCE@ 1"; | ||
115 | "button9" = "pacmd set-sink-mute @DEFAULT_SINK@ 1"; | ||
116 | "@button9" = "pacmd set-sink-mute @DEFAULT_SINK@ 0"; | ||
117 | }; | ||
118 | }; | ||
119 | }; | ||
120 | |||
121 | gtk = { | ||
122 | enable = true; | ||
123 | font.name = "DejaVu Sans 6"; | ||
124 | theme = { | ||
125 | package = pkgs.equilux-theme; | ||
126 | name = "Equilux-compact"; | ||
127 | }; | ||
128 | iconTheme = { | ||
129 | package = pkgs.paper-icon-theme; | ||
130 | name = "Paper"; | ||
131 | }; | ||
132 | }; | ||
133 | |||
134 | xsession = { | ||
135 | enable = true; | ||
136 | |||
137 | windowManager.command = "${xmonad}/bin/xmonad"; | ||
138 | |||
139 | initExtra = let | ||
140 | lockScript = pkgs.writeScript "lock" '' | ||
141 | #!${pkgs.stdenv.shell} | ||
142 | ${pkgs.playerctl}/bin/playerctl -a pause | ||
143 | exec ${pkgs.xsecurelock}/bin/xsecurelock | ||
144 | ''; | ||
145 | in '' | ||
146 | ${pkgs.coreutils}/bin/env XSECURELOCK_WANT_FIRST_KEYPRESS=1 XSECURELOCK_DIM_ALPHA=1 ${pkgs.xss-lock}/bin/xss-lock -l -n ${pkgs.xsecurelock}/libexec/xsecurelock/dimmer -- ${lockScript} & | ||
147 | ${pkgs.xorg.xinput}/bin/xinput disable 'SynPS/2 Synaptics TouchPad' # Synaptics TM3512-010 | ||
148 | ${pkgs.xorg.xset}/bin/xset s 590 10 | ||
149 | ''; | ||
150 | }; | ||
151 | |||
152 | xresources.properties = import ./xresources.nix; | ||
153 | |||
154 | home = { | ||
155 | packages = with pkgs; [ | ||
156 | fira-code powerline-fonts nerdfonts pavucontrol keepassxc | ||
157 | youtube-dl sxiv xclip mumble pulseaudio-ctl libnotify synergy | ||
158 | xorg.xbacklight screen-message pidgin-with-plugins | ||
159 | google-play-music-desktop-player qt5ct playerctl evince | ||
160 | thunderbird zulip zoom-us steam steam-run wireshark skype | ||
161 | virt-manager rclone cached-nix-shell xournal discord xmonad | ||
162 | ]; | ||
163 | |||
164 | file = { | ||
165 | ".emacs".source = ./emacs.el; | ||
166 | ".backup-munin".source = ./backup-patterns; | ||
167 | ".mozilla/firefox/default/chrome/userChrome.css".source = ./firefox-chrome.css; | ||
168 | ".mozilla/firefox/default/chrome/userContent.css".source = ./firefox-content.css; | ||
169 | }; | ||
170 | |||
171 | sessionVariables = { | ||
172 | GDK_SCALE = 96.0 / 282.0; | ||
173 | XDG_DATA_DIRS = "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS"; | ||
174 | QT_AUTO_SCREEN_SCALE_FACTOR = 1; | ||
175 | QT_QPA_PLATFORMTHEME = "qt5ct"; | ||
176 | }; | ||
177 | |||
178 | stateVersion = "20.03"; | ||
179 | }; | ||
180 | }; | ||
181 | } | ||
diff --git a/accounts/gkleen@sif/dunst-settings.nix b/accounts/gkleen@sif/dunst-settings.nix new file mode 100644 index 00000000..8319da03 --- /dev/null +++ b/accounts/gkleen@sif/dunst-settings.nix | |||
@@ -0,0 +1,64 @@ | |||
1 | { | ||
2 | global = { | ||
3 | font = "Monospace 6"; | ||
4 | markup = "full"; | ||
5 | format = "<i>%s</i> %p\\n%b"; | ||
6 | alignment = "left"; | ||
7 | geometry = "1216x10-32+64"; | ||
8 | shrink = true; | ||
9 | monitor = 0; | ||
10 | follow = "none"; | ||
11 | padding = 6; | ||
12 | horizontal_padding = 6; | ||
13 | separator_height = 1; | ||
14 | separator_color = "frame"; | ||
15 | idle_threshold = 0; | ||
16 | |||
17 | transparency = 10; | ||
18 | |||
19 | frame_width = 1; | ||
20 | frame_color = "#999999"; | ||
21 | |||
22 | word_wrap = true; | ||
23 | show_age_threshold = 15; | ||
24 | show_indicators = false; | ||
25 | icon_position = "right"; | ||
26 | sort = false; | ||
27 | sticky_history = false; | ||
28 | }; | ||
29 | shortcuts = { | ||
30 | close = "ctrl+space"; | ||
31 | close_all = "ctrl+shift+space"; | ||
32 | history = "ctrl+comma"; | ||
33 | context = "ctrl+period"; | ||
34 | }; | ||
35 | urgency_low = { | ||
36 | background = "#000000"; | ||
37 | foreground = "#999999"; | ||
38 | timeout = 5; | ||
39 | }; | ||
40 | urgency_normal = { | ||
41 | background = "#000000"; | ||
42 | foreground = "#ffffff"; | ||
43 | timeout = 15; | ||
44 | }; | ||
45 | urgency_critical = { | ||
46 | background = "#900000"; | ||
47 | foreground = "#ffffff"; | ||
48 | timeout = 0; | ||
49 | }; | ||
50 | pulseaudio-ctl = { | ||
51 | summary = "Volume *"; | ||
52 | body = "Current is *"; | ||
53 | set_stack_tag = "volume"; | ||
54 | history_ignore = true; | ||
55 | }; | ||
56 | mail = { | ||
57 | appname = "notmuch"; | ||
58 | timeout = 0; | ||
59 | }; | ||
60 | zulip = { | ||
61 | appname = "Zulip"; | ||
62 | timeout = 0; | ||
63 | }; | ||
64 | } | ||
diff --git a/accounts/gkleen@sif/emacs.el b/accounts/gkleen@sif/emacs.el new file mode 100644 index 00000000..7bfd5c18 --- /dev/null +++ b/accounts/gkleen@sif/emacs.el | |||
@@ -0,0 +1,99 @@ | |||
1 | (menu-bar-mode -1) | ||
2 | (scroll-bar-mode -1) | ||
3 | (tool-bar-mode -1) | ||
4 | |||
5 | (set-face-attribute 'default nil :height 50) | ||
6 | |||
7 | (require 'evil) | ||
8 | (evil-mode 1) | ||
9 | |||
10 | (global-subword-mode) | ||
11 | (global-undo-tree-mode) | ||
12 | |||
13 | (global-set-key (kbd "RET") 'newline-and-indent) | ||
14 | (global-set-key (kbd "M-g") 'magit-status) | ||
15 | (global-set-key (kbd "M-?") 'vc-git-grep) | ||
16 | |||
17 | (setq backup-directory-alist `(("." . "~/.saves"))) | ||
18 | (setq delete-old-versions t | ||
19 | kept-new-versions 6 | ||
20 | kept-old-versions 2 | ||
21 | version-control t) | ||
22 | |||
23 | (add-hook 'haskell-mode-hook 'haskell-indentation-mode) | ||
24 | (add-hook 'haskell-mode-hook 'subword-mode) | ||
25 | (add-hook 'haskell-mode-hook 'highlight-symbol-mode) | ||
26 | (add-hook 'haskell-mode-hook 'highlight-paretheses-mode) | ||
27 | |||
28 | (add-hook 'js-mode-hook 'highlight-symbol-mode) | ||
29 | (add-hook 'js-mode-hook 'highlight-parentheses-mode) | ||
30 | (defun my-js-mode-hook () | ||
31 | "Custom `js-mode' behaviours." | ||
32 | (setq js-indent-level 2) | ||
33 | ) | ||
34 | (add-hook 'js-mode-hook 'my-js-mode-hook) | ||
35 | |||
36 | (setq notmuch-address-internal-completion '(received nil)) | ||
37 | (setq notmuch-always-prompt-for-sender t) | ||
38 | (setq notmuch-command "notmuch-ssh") | ||
39 | (setq notmuch-crypto-process-mime t) | ||
40 | (setq notmuch-draft-tags '("+draft" "-inbox")) | ||
41 | (setq notmuch-fcc-dirs nil) | ||
42 | (setq notmuch-hello-sections '(notmuch-hello-insert-header notmuch-hello-insert-saved-searches)) | ||
43 | (setq notmuch-hello-thousands-separator " ") | ||
44 | (setq notmuch-identities '("gkleen@yggdrasil.li" "g@141.li" "kleen@cip.ifi.lmu.de" "Gregor.Kleen@stud.ifi.lmu.de" "G.Kleen@campus.lmu.de" "G.Kleen@lmu.de" "gregor.kleen@ifi.lmu.de" "uni2work@ifi.lmu.de" "gregor@kleen.li")) | ||
45 | (setq notmuch-message-headers '("Subject" "To" "Cc" "Date")) | ||
46 | (setq notmuch-message-replied-tags '("+replied" "-unread" "-inbox")) | ||
47 | (setq notmuch-saved-searches | ||
48 | (quote | ||
49 | ((:name "inbox" :query "tag:inbox" :key "i") | ||
50 | (:name "unread" :query "tag:unread AND tag:inbox" :key "u") | ||
51 | (:name "drafts" :query "tag:draft" :key "d") | ||
52 | (:name "all mail" :query "date:month.." :key "a" :count-query "*") | ||
53 | (:name "sent" :query "is:sent" :key "s" :count-query "is:sent") | ||
54 | ))) | ||
55 | (setq notmuch-search-oldest-first nil) | ||
56 | (setq notmuch-show-all-tags-list t) | ||
57 | (setq notmuch-show-logo nil) | ||
58 | |||
59 | (setq send-mail-function 'sendmail-send-it) | ||
60 | (setq mail-envelope-from 'header) | ||
61 | (setq mail-specify-envelope-from 't) | ||
62 | (setq mail-default-headers nil) | ||
63 | (setq message-default-headers "") | ||
64 | (setq message-default-mail-headers "") | ||
65 | (setq message-sendmail-envelope-from 'header) | ||
66 | |||
67 | (setq highlight-symbol-idle-delay 0) | ||
68 | |||
69 | (setq indent-tabs-mode nil) | ||
70 | |||
71 | (setq ido-enable-flex-matching t) | ||
72 | (setq ido-everywhere t) | ||
73 | (ido-mode 1) | ||
74 | |||
75 | (setq mail-host-address "sif.midgard.yggdrasil") | ||
76 | (setq user-full-name "Gregor Kleen") | ||
77 | |||
78 | (defun tell-emacsclients-for-buffer-to-die () | ||
79 | "Sends error exit command to every client for the current buffer." | ||
80 | (interactive) | ||
81 | (dolist (proc server-buffer-clients) | ||
82 | (server-send-string proc "-error die"))) | ||
83 | |||
84 | (defun kill-buffer-with-special-emacsclient-handling () | ||
85 | "Wrapper around kill-buffer that ensures tell-emacsclients-for-buffer-to-die is on the hooks" | ||
86 | (interactive) | ||
87 | (add-hook 'kill-buffer-hook 'tell-emacsclients-for-buffer-to-die nil t) | ||
88 | (kill-buffer)) | ||
89 | |||
90 | ;; (global-set-key (kbd "C-x k") 'kill-buffer) | ||
91 | |||
92 | (defun install-emacsclient-wrapped-kill-buffer () | ||
93 | "Installs wrapped kill-buffer with special emacsclient handling. | ||
94 | Best not to install it unconditionally because the server is not | ||
95 | necessarily running." | ||
96 | (interactive) | ||
97 | (global-set-key (kbd "C-x k") 'kill-buffer-with-special-emacsclient-handling)) | ||
98 | |||
99 | (add-hook 'server-switch-hook 'install-emacsclient-wrapped-kill-buffer) | ||
diff --git a/accounts/gkleen@sif/firefox-chrome.css b/accounts/gkleen@sif/firefox-chrome.css new file mode 100644 index 00000000..2d359771 --- /dev/null +++ b/accounts/gkleen@sif/firefox-chrome.css | |||
@@ -0,0 +1,25 @@ | |||
1 | @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); | ||
2 | |||
3 | * { | ||
4 | font-size:12px; | ||
5 | } | ||
6 | |||
7 | #sidebar { | ||
8 | min-width:20em !important; | ||
9 | max-width:20em !important; | ||
10 | border-right:1px solid rgba(30,30,30) !important; | ||
11 | } | ||
12 | |||
13 | #sidebar-header:nth-last-child(2) > *:last-child { | ||
14 | visibility: collapse; | ||
15 | } | ||
16 | |||
17 | #sidebar-splitter { | ||
18 | visibility: collapse; | ||
19 | } | ||
20 | |||
21 | #toolbar-menubar[inactive="true"] + #TabsToolbar { | ||
22 | visibility: collapse !important; | ||
23 | } | ||
24 | |||
25 | #sidebar-box[sidebarcommand="tabcenter-reborn_ariasuni-sidebar-action"] #sidebar-header { visibility: collapse !important; } | ||
diff --git a/accounts/gkleen@sif/firefox-content.css b/accounts/gkleen@sif/firefox-content.css new file mode 100644 index 00000000..3ac53a9d --- /dev/null +++ b/accounts/gkleen@sif/firefox-content.css | |||
@@ -0,0 +1,12 @@ | |||
1 | @-moz-document url("about:blank") { | ||
2 | html { | ||
3 | background-color: rgb(40,40,40); | ||
4 | } | ||
5 | } | ||
6 | |||
7 | @-moz-document url(about:newtab) { | ||
8 | body, #newtab-customize-overlay { | ||
9 | background-color: rgb(40,40,40) !important; | ||
10 | color: rgb(166,166,166) !important; | ||
11 | } | ||
12 | } | ||
diff --git a/accounts/gkleen@sif/ssh-hosts.nix b/accounts/gkleen@sif/ssh-hosts.nix new file mode 100644 index 00000000..ffbd8c00 --- /dev/null +++ b/accounts/gkleen@sif/ssh-hosts.nix | |||
@@ -0,0 +1,190 @@ | |||
1 | { | ||
2 | "git.ymir" = | ||
3 | { hostname = "ymir.yggdrasil.li"; | ||
4 | user = "gitolite"; | ||
5 | identityFile = "~/.ssh/gkleen@sif.midgard.yggdrasil"; | ||
6 | }; | ||
7 | "git.yggdrasil.li" = | ||
8 | { user = "gitolite"; | ||
9 | identityFile = "~/.ssh/gkleen@sif.midgard.yggdrasil"; | ||
10 | }; | ||
11 | "git.rheperire.org" = | ||
12 | { user = "gitolite"; | ||
13 | identityFile = "~/.ssh/gkleen@sif.midgard.yggdrasil"; | ||
14 | }; | ||
15 | "borg.munin" = | ||
16 | { hostname = "u120515.your-storagebox.de"; | ||
17 | user = "u120515"; | ||
18 | identityFile = "~/.ssh/borg.munin"; | ||
19 | port = 23; | ||
20 | }; | ||
21 | "munin" = | ||
22 | { hostname = "u120515.your-storagebox.de"; | ||
23 | user = "u120515"; | ||
24 | identityFile = "~/.ssh/munin"; | ||
25 | }; | ||
26 | "ymir" = | ||
27 | { hostname = "ymir.yggdrasil.li"; | ||
28 | identityFile = "~/.ssh/gkleen@sif.midgard.yggdrasil"; | ||
29 | }; | ||
30 | "odin" = | ||
31 | { hostname = "odin.asgard.yggdrasil"; | ||
32 | identityFile = "~/.ssh/gkleen@sif.midgard.yggdrasil"; | ||
33 | }; | ||
34 | "init.odin" = | ||
35 | { hostname = "odin.asgard.yggdrasil"; | ||
36 | user = "root"; | ||
37 | identityFile = "~/.ssh/rsa.gkleen@hel.midgard.yggdrasil"; | ||
38 | extraOptions = { | ||
39 | StrictHostKeyChecking = "off"; | ||
40 | }; | ||
41 | }; | ||
42 | "heimdallr" = | ||
43 | { hostname = "heimdallr.asgard.yggdrasil"; | ||
44 | user = "root"; | ||
45 | identityFile = "~/.ssh/gkleen@sif.midgard.yggdrasil"; | ||
46 | }; | ||
47 | "gitlab2.rz.ifi.lmu.de" = | ||
48 | { user = "git"; | ||
49 | identityFile = "~/.ssh/gkleen@gitlab2.rz.ifi.lmu.de"; | ||
50 | }; | ||
51 | "gitlab2.cip.ifi.lmu.de" = | ||
52 | { user = "git"; | ||
53 | identityFile = "~/.ssh/gkleen@sif.midgard.yggdrasil"; | ||
54 | }; | ||
55 | "hel".hostname = "hel.midgard.yggdrasil"; | ||
56 | "blackbeard" = | ||
57 | { hostname = "blackbeard.tcs.ifi.lmu.de"; | ||
58 | user = "pi"; | ||
59 | identityFile = "~/.ssh/blackbeard"; | ||
60 | }; | ||
61 | "github.com" = | ||
62 | { user = "git"; | ||
63 | identityFile = "~/.ssh/gkleen@github.com"; | ||
64 | }; | ||
65 | "ullr.playat.ch" = | ||
66 | { hostname = "ullr.playat.ch"; | ||
67 | user = "minecraft"; | ||
68 | identityFile = "~/.ssh/minecraft@ullr.playat.ch"; | ||
69 | }; | ||
70 | "ullr" = | ||
71 | { hostname = "185.170.112.70"; | ||
72 | identityFile = "~/.ssh/gkleen@sif.midgard.yggdrasil"; | ||
73 | }; | ||
74 | "testworx" = | ||
75 | { hostname = "testworx.tcs.ifi.lmu.de"; | ||
76 | user = "root"; | ||
77 | port = 30363; | ||
78 | identityFile = "~/.ssh/testworx"; | ||
79 | }; | ||
80 | "remote.cip.ifi.lmu.de".user = "kleen"; | ||
81 | "uniworx3" = | ||
82 | { hostname = "uniworx3.ifi.lmu.de"; | ||
83 | user = "root"; | ||
84 | identityFile = "~/.ssh/uni2work"; | ||
85 | }; | ||
86 | "uniworx4" = | ||
87 | { hostname = "uniworx4.ifi.lmu.de"; | ||
88 | user = "root"; | ||
89 | identityFile = "~/.ssh/uni2work"; | ||
90 | }; | ||
91 | "uni2workgw" = | ||
92 | { hostname = "uni2workgw.ifi.lmu.de"; | ||
93 | user = "root"; | ||
94 | identityFile = "~/.ssh/uni2work"; | ||
95 | }; | ||
96 | "uniworxdb" = | ||
97 | { hostname = "uniworxdb"; | ||
98 | proxyJump = "uniworx4"; | ||
99 | user = "root"; | ||
100 | identityFile = "~/.ssh/uni2work"; | ||
101 | }; | ||
102 | "uniworxdb2" = | ||
103 | { hostname = "uniworxdb2"; | ||
104 | proxyJump = "uniworx4"; | ||
105 | user = "root"; | ||
106 | identityFile = "~/.ssh/uni2work"; | ||
107 | }; | ||
108 | "gate2" = | ||
109 | { hostname = "gate2.tcs.ifi.lmu.de"; | ||
110 | user = "gkleen"; | ||
111 | identityFile = "~/.ssh/tcs"; | ||
112 | }; | ||
113 | "proxy.gate2" = | ||
114 | { hostname = "gate2.tcs.ifi.lmu.de"; | ||
115 | user = "gkleen"; | ||
116 | identityFile = "~/.ssh/proxy.gkleen@tcs.ifi.lmu.de"; | ||
117 | dynamicForwards = [ { port = 8118; } ]; | ||
118 | extraOptions = { | ||
119 | ExitOnForwardFailure = "yes"; | ||
120 | }; | ||
121 | }; | ||
122 | "jump.gate2" = | ||
123 | { hostname = "gate2.tcs.ifi.lmu.de"; | ||
124 | user = "gkleen"; | ||
125 | identityFile = "~/.ssh/proxy.gkleen@tcs.ifi.lmu.de"; | ||
126 | extraOptions = { | ||
127 | ExitOnForwardFailure = "yes"; | ||
128 | }; | ||
129 | }; | ||
130 | "gate" = | ||
131 | { hostname = "gate.tcs.ifi.lmu.de"; | ||
132 | user = "gkleen"; | ||
133 | identityFile = "~/.ssh/tcs"; | ||
134 | }; | ||
135 | "proxy.gate" = | ||
136 | { hostname = "gate.tcs.ifi.lmu.de"; | ||
137 | user = "gkleen"; | ||
138 | identityFile = "~/.ssh/proxy.gkleen@tcs.ifi.lmu.de"; | ||
139 | dynamicForwards = [ { port = 8118; } ]; | ||
140 | extraOptions = { | ||
141 | ExitOnForwardFailure = "yes"; | ||
142 | }; | ||
143 | }; | ||
144 | "jump.gate" = | ||
145 | { hostname = "gate.tcs.ifi.lmu.de"; | ||
146 | user = "gkleen"; | ||
147 | identityFile = "~/.ssh/proxy.gkleen@tcs.ifi.lmu.de"; | ||
148 | extraOptions = { | ||
149 | ExitOnForwardFailure = "yes"; | ||
150 | }; | ||
151 | }; | ||
152 | "oregon" = | ||
153 | { hostname = "oregon.tcs.ifi.lmu.de"; | ||
154 | user = "root"; | ||
155 | identityFile = "~/.ssh/tcs"; | ||
156 | }; | ||
157 | "witbank" = | ||
158 | { hostname = "witbank.tcs.ifi.lmu.de"; | ||
159 | user = "uni2work"; | ||
160 | identityFile = "~/.ssh/letz"; | ||
161 | }; | ||
162 | "git.odin" = | ||
163 | { hostname = "odin.asgard.yggdrasil"; | ||
164 | user = "gitolite"; | ||
165 | }; | ||
166 | "notmuch.odin" = | ||
167 | { hostname = "odin.asgard.yggdrasil"; | ||
168 | identityFile = "~/.ssh/notmuch.odin.asgard.yggdrasil"; | ||
169 | }; | ||
170 | "status.odin" = | ||
171 | { hostname = "odin.asgard.yggdrasil"; | ||
172 | identityFile = "~/.ssh/status.odin.asgard.yggdrasil"; | ||
173 | extraOptions.ControlPath = "~/.ssh/status-%r@%n:%p"; | ||
174 | }; | ||
175 | "moden" = | ||
176 | { hostname = "oristano.tcs.ifi.lmu.de"; | ||
177 | user = "gkleen"; | ||
178 | port = 30363; | ||
179 | identityFile = "~/.ssh/gkleen@oristano.tcs.ifi.lmu.de"; | ||
180 | }; | ||
181 | "ubuntu1804" = | ||
182 | { hostname = "192.168.122.30"; | ||
183 | identityFile = "~/.ssh/gkleen@sif.midgard.yggdrasil"; | ||
184 | forwardAgent = true; | ||
185 | }; | ||
186 | "gitlab.haskell.org" = | ||
187 | { hostname = "gitlab.haskell.org"; | ||
188 | identityFile = "~/.ssh/gkleen@gitlab.haskell.org"; | ||
189 | }; | ||
190 | } | ||
diff --git a/accounts/gkleen@sif/xmonad/.gitignore b/accounts/gkleen@sif/xmonad/.gitignore new file mode 100644 index 00000000..c11891cd --- /dev/null +++ b/accounts/gkleen@sif/xmonad/.gitignore | |||
@@ -0,0 +1,4 @@ | |||
1 | **/#*# | ||
2 | **/.stack-work/ | ||
3 | /stack.yaml.lock | ||
4 | /*.cabal | ||
diff --git a/accounts/gkleen@sif/xmonad/default.nix b/accounts/gkleen@sif/xmonad/default.nix new file mode 100644 index 00000000..8790c12f --- /dev/null +++ b/accounts/gkleen@sif/xmonad/default.nix | |||
@@ -0,0 +1,7 @@ | |||
1 | argumentPackages@{ ... }: | ||
2 | |||
3 | let | ||
4 | # defaultPackages = (import ./stackage.nix {}); | ||
5 | # haskellPackages = defaultPackages // argumentPackages; | ||
6 | haskellPackages = argumentPackages; | ||
7 | in haskellPackages.callPackage ./xmonad-yggdrasil.nix {} | ||
diff --git a/accounts/gkleen@sif/xmonad/lib/XMonad/Mpv.hs b/accounts/gkleen@sif/xmonad/lib/XMonad/Mpv.hs new file mode 100644 index 00000000..e6accdcc --- /dev/null +++ b/accounts/gkleen@sif/xmonad/lib/XMonad/Mpv.hs | |||
@@ -0,0 +1,127 @@ | |||
1 | {-# LANGUAGE DeriveGeneric, OverloadedLists, OverloadedStrings, ViewPatterns, ExistentialQuantification, MultiWayIf #-} | ||
2 | |||
3 | module XMonad.Mpv | ||
4 | ( MpvCommand(..), MpvResponse(..), MpvException(..) | ||
5 | , mpv | ||
6 | , mpvDir | ||
7 | , mpvAll, mpvOne | ||
8 | , mpvResponse | ||
9 | ) where | ||
10 | |||
11 | import Data.Aeson | ||
12 | |||
13 | import Data.Monoid | ||
14 | |||
15 | import Network.Socket hiding (recv) | ||
16 | import Network.Socket.ByteString | ||
17 | |||
18 | import qualified Data.ByteString as BS | ||
19 | import qualified Data.ByteString.Char8 as CBS | ||
20 | import qualified Data.ByteString.Lazy as LBS | ||
21 | |||
22 | import GHC.Generics (Generic) | ||
23 | import Data.Typeable (Typeable) | ||
24 | import Data.String (IsString(..)) | ||
25 | |||
26 | import Control.Exception | ||
27 | |||
28 | import System.IO.Temp (getCanonicalTemporaryDirectory) | ||
29 | |||
30 | import Control.Monad | ||
31 | import Control.Exception (bracket) | ||
32 | import Control.Monad.IO.Class (MonadIO(..)) | ||
33 | |||
34 | import System.FilePath | ||
35 | import System.Directory (getDirectoryContents) | ||
36 | |||
37 | import Data.List | ||
38 | import Data.Either | ||
39 | import Data.Maybe | ||
40 | |||
41 | import Debug.Trace | ||
42 | |||
43 | |||
44 | data MpvCommand | ||
45 | = forall a. ToJSON a => MpvSetProperty String a | ||
46 | | MpvGetProperty String | ||
47 | data MpvResponse | ||
48 | = MpvError String | ||
49 | | MpvSuccess (Maybe Value) | ||
50 | deriving (Read, Show, Generic, Eq) | ||
51 | data MpvException = MpvException String | ||
52 | | MpvNoValue | ||
53 | | MpvNoParse String | ||
54 | deriving (Generic, Typeable, Read, Show) | ||
55 | instance Exception MpvException | ||
56 | |||
57 | |||
58 | instance ToJSON MpvCommand where | ||
59 | toJSON (MpvSetProperty name val) = Array ["set_property", fromString name, toJSON val] | ||
60 | toJSON (MpvGetProperty name) = Array ["get_property", fromString name] | ||
61 | |||
62 | instance FromJSON MpvResponse where | ||
63 | parseJSON = withObject "response object" $ \obj -> do | ||
64 | mval <- obj .:? "data" | ||
65 | err <- obj .: "error" | ||
66 | |||
67 | let ret | ||
68 | | err == "success" = MpvSuccess mval | ||
69 | | otherwise = MpvError err | ||
70 | |||
71 | return ret | ||
72 | |||
73 | mpvSocket :: FilePath -> (Socket -> IO a) -> IO a | ||
74 | mpvSocket sockPath = withSocketsDo . bracket mkSock close | ||
75 | where | ||
76 | mkSock = do | ||
77 | sock <- socket AF_UNIX Stream defaultProtocol | ||
78 | connect sock $ SockAddrUnix (traceId sockPath) | ||
79 | return sock | ||
80 | |||
81 | mpvResponse :: FromJSON v => MpvResponse -> IO v | ||
82 | mpvResponse (MpvError str) = throwIO $ MpvException str | ||
83 | mpvResponse (MpvSuccess Nothing) = throwIO MpvNoValue | ||
84 | mpvResponse (MpvSuccess (Just v)) = case fromJSON v of | ||
85 | Success v' -> return v' | ||
86 | Error str -> throwIO $ MpvNoParse str | ||
87 | |||
88 | mpv :: FilePath -> MpvCommand -> IO MpvResponse | ||
89 | mpv sockPath cmd = mpvSocket sockPath $ \sock -> do | ||
90 | let message = (`BS.append` "\n") . LBS.toStrict . encode $ Object [("command", toJSON cmd)] | ||
91 | traceIO $ show message | ||
92 | sendAll sock message | ||
93 | let recvAll = do | ||
94 | prefix <- recv sock 4096 | ||
95 | if | ||
96 | | (prefix', rest) <- CBS.break (== '\n') prefix | ||
97 | , not (BS.null rest) -> return prefix' | ||
98 | | BS.null prefix -> return prefix | ||
99 | | otherwise -> BS.append prefix <$> recvAll | ||
100 | response <- recvAll | ||
101 | traceIO $ show response | ||
102 | either (ioError . userError) return . traceShowId $ eitherDecodeStrict' response | ||
103 | |||
104 | mpvDir :: Exception e => FilePath -> (FilePath -> [(FilePath, Either e MpvResponse)] -> Maybe MpvCommand) -> IO [(FilePath, Either e MpvResponse)] | ||
105 | mpvDir dir step = do | ||
106 | socks <- filter (".sock" `isSuffixOf`) <$> getDirectoryContents dir | ||
107 | go [] socks | ||
108 | where | ||
109 | go acc [] = return acc | ||
110 | go acc (sock:socks) | ||
111 | | Just cmd <- step sock acc = do | ||
112 | res <- try $ mpv (dir </> sock) cmd | ||
113 | go ((sock, res) : acc) socks | ||
114 | | otherwise = | ||
115 | go acc socks | ||
116 | |||
117 | mpvAll :: FilePath -> MpvCommand -> IO [MpvResponse] | ||
118 | mpvAll dir cmd = do | ||
119 | results <- map snd <$> (mpvDir dir (\_ _ -> Just cmd) :: IO [(FilePath, Either SomeException MpvResponse)]) | ||
120 | mapM (either throwIO return) results | ||
121 | |||
122 | mpvOne :: FilePath -> MpvCommand -> IO (Maybe MpvResponse) | ||
123 | mpvOne dir cmd = listToMaybe . snd . partitionEithers . map snd <$> (mpvDir dir step :: IO [(FilePath, Either SomeException MpvResponse)]) | ||
124 | where | ||
125 | step _ results | ||
126 | | any (isRight . snd) results = Nothing | ||
127 | | otherwise = Just cmd | ||
diff --git a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyPass.hs b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyPass.hs new file mode 100644 index 00000000..1caefae5 --- /dev/null +++ b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyPass.hs | |||
@@ -0,0 +1,94 @@ | |||
1 | module XMonad.Prompt.MyPass | ||
2 | ( | ||
3 | -- * Usages | ||
4 | -- $usages | ||
5 | mkPassPrompt | ||
6 | ) where | ||
7 | |||
8 | import Control.Monad (liftM) | ||
9 | import XMonad.Core | ||
10 | import XMonad.Prompt ( XPrompt | ||
11 | , showXPrompt | ||
12 | , commandToComplete | ||
13 | , nextCompletion | ||
14 | , getNextCompletion | ||
15 | , XPConfig | ||
16 | , mkXPrompt | ||
17 | , searchPredicate) | ||
18 | import System.Directory (getHomeDirectory) | ||
19 | import System.FilePath (takeExtension, dropExtension, combine) | ||
20 | import System.Posix.Env (getEnv) | ||
21 | import XMonad.Util.Run (runProcessWithInput) | ||
22 | |||
23 | -- $usages | ||
24 | -- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: | ||
25 | -- | ||
26 | -- > import XMonad.Prompt.Pass | ||
27 | -- | ||
28 | -- Then add a keybinding for 'passPrompt', 'passGeneratePrompt' or 'passRemovePrompt': | ||
29 | -- | ||
30 | -- > , ((modMask x , xK_p) , passPrompt xpconfig) | ||
31 | -- > , ((modMask x .|. controlMask, xK_p) , passGeneratePrompt xpconfig) | ||
32 | -- > , ((modMask x .|. controlMask .|. shiftMask, xK_p), passRemovePrompt xpconfig) | ||
33 | -- | ||
34 | -- For detailed instructions on: | ||
35 | -- | ||
36 | -- - editing your key bindings, see "XMonad.Doc.Extending#Editing_key_bindings". | ||
37 | -- | ||
38 | -- - how to setup the password storage, see <http://git.zx2c4.com/password-store/about/> | ||
39 | -- | ||
40 | |||
41 | type Predicate = String -> String -> Bool | ||
42 | |||
43 | getPassCompl :: [String] -> Predicate -> String -> IO [String] | ||
44 | getPassCompl compls p s | ||
45 | | length s <= minL | ||
46 | , all ((> minL) . length) compls = return [] | ||
47 | | otherwise = do return $ filter (p s) compls | ||
48 | where | ||
49 | minL = 3 | ||
50 | |||
51 | type PromptLabel = String | ||
52 | |||
53 | data Pass = Pass PromptLabel | ||
54 | |||
55 | instance XPrompt Pass where | ||
56 | showXPrompt (Pass prompt) = prompt ++ ": " | ||
57 | commandToComplete _ c = c | ||
58 | nextCompletion _ = getNextCompletion | ||
59 | |||
60 | -- | Default password store folder in $HOME/.password-store | ||
61 | -- | ||
62 | passwordStoreFolderDefault :: String -> String | ||
63 | passwordStoreFolderDefault home = combine home ".password-store" | ||
64 | |||
65 | -- | Compute the password store's location. | ||
66 | -- Use the PASSWORD_STORE_DIR environment variable to set the password store. | ||
67 | -- If empty, return the password store located in user's home. | ||
68 | -- | ||
69 | passwordStoreFolder :: IO String | ||
70 | passwordStoreFolder = | ||
71 | getEnv "PASSWORD_STORE_DIR" >>= computePasswordStoreDir | ||
72 | where computePasswordStoreDir Nothing = liftM passwordStoreFolderDefault getHomeDirectory | ||
73 | computePasswordStoreDir (Just storeDir) = return storeDir | ||
74 | |||
75 | -- | A pass prompt factory | ||
76 | -- | ||
77 | mkPassPrompt :: PromptLabel -> (String -> X ()) -> XPConfig -> X () | ||
78 | mkPassPrompt promptLabel passwordFunction xpconfig = do | ||
79 | passwords <- io (passwordStoreFolder >>= getPasswords) | ||
80 | mkXPrompt (Pass promptLabel) xpconfig (getPassCompl passwords $ searchPredicate xpconfig) passwordFunction | ||
81 | |||
82 | -- | Retrieve the list of passwords from the password storage 'passwordStoreDir | ||
83 | getPasswords :: FilePath -> IO [String] | ||
84 | getPasswords passwordStoreDir = do | ||
85 | files <- runProcessWithInput "find" [ | ||
86 | passwordStoreDir, | ||
87 | "-type", "f", | ||
88 | "-name", "*.gpg", | ||
89 | "-printf", "%P\n"] [] | ||
90 | return $ map removeGpgExtension $ lines files | ||
91 | |||
92 | removeGpgExtension :: String -> String | ||
93 | removeGpgExtension file | takeExtension file == ".gpg" = dropExtension file | ||
94 | | otherwise = file | ||
diff --git a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyShell.hs b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyShell.hs new file mode 100644 index 00000000..c268f87d --- /dev/null +++ b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MyShell.hs | |||
@@ -0,0 +1,105 @@ | |||
1 | module XMonad.Prompt.MyShell | ||
2 | ( Shell (..) | ||
3 | , shellPrompt | ||
4 | , prompt | ||
5 | , safePrompt | ||
6 | , unsafePrompt | ||
7 | , getCommands | ||
8 | , getShellCompl | ||
9 | , split | ||
10 | ) where | ||
11 | |||
12 | import Codec.Binary.UTF8.String (encodeString) | ||
13 | import Control.Exception as E | ||
14 | import Control.Monad (forM) | ||
15 | import Data.List (isPrefixOf) | ||
16 | import System.Directory (doesDirectoryExist, getDirectoryContents) | ||
17 | import System.Environment (getEnv) | ||
18 | import System.Posix.Files (getFileStatus, isDirectory) | ||
19 | |||
20 | import XMonad hiding (config) | ||
21 | import XMonad.Prompt | ||
22 | import XMonad.Util.Run | ||
23 | |||
24 | econst :: Monad m => a -> IOException -> m a | ||
25 | econst = const . return | ||
26 | |||
27 | data Shell = Shell String | ||
28 | |||
29 | instance XPrompt Shell where | ||
30 | showXPrompt (Shell q) = q | ||
31 | completionToCommand _ = escape | ||
32 | |||
33 | shellPrompt :: String -> XPConfig -> X () | ||
34 | shellPrompt q c = do | ||
35 | cmds <- io getCommands | ||
36 | mkXPrompt (Shell q) c (getShellCompl cmds) spawn | ||
37 | |||
38 | {- $spawns | ||
39 | See safe and unsafeSpawn in "XMonad.Util.Run". | ||
40 | prompt is an alias for safePrompt; | ||
41 | safePrompt and unsafePrompt work on the same principles, but will use | ||
42 | XPrompt to interactively query the user for input; the appearance is | ||
43 | set by passing an XPConfig as the second argument. The first argument | ||
44 | is the program to be run with the interactive input. | ||
45 | You would use these like this: | ||
46 | |||
47 | > , ((modm, xK_b), safePrompt "firefox" greenXPConfig) | ||
48 | > , ((modm .|. shiftMask, xK_c), prompt ("xterm" ++ " -e") greenXPConfig) | ||
49 | |||
50 | Note that you want to use safePrompt for Firefox input, as Firefox | ||
51 | wants URLs, and unsafePrompt for the XTerm example because this allows | ||
52 | you to easily start a terminal executing an arbitrary command, like | ||
53 | 'top'. -} | ||
54 | |||
55 | prompt, unsafePrompt, safePrompt :: String -> FilePath -> XPConfig -> X () | ||
56 | prompt = unsafePrompt | ||
57 | safePrompt q c config = mkXPrompt (Shell q) config (getShellCompl [c]) run | ||
58 | where run = safeSpawn c . return | ||
59 | unsafePrompt q c config = mkXPrompt (Shell q) config (getShellCompl [c]) run | ||
60 | where run a = unsafeSpawn $ c ++ " " ++ a | ||
61 | |||
62 | getShellCompl :: [String] -> String -> IO [String] | ||
63 | getShellCompl cmds s | s == "" || last s == ' ' = return [] | ||
64 | | otherwise = do | ||
65 | f <- fmap lines $ runProcessWithInput "bash" [] ("compgen -A file -- " | ||
66 | ++ s ++ "\n") | ||
67 | files <- case f of | ||
68 | [x] -> do fs <- getFileStatus (encodeString x) | ||
69 | if isDirectory fs then return [x ++ "/"] | ||
70 | else return [x] | ||
71 | _ -> return f | ||
72 | return . uniqSort $ files ++ commandCompletionFunction cmds s | ||
73 | |||
74 | commandCompletionFunction :: [String] -> String -> [String] | ||
75 | commandCompletionFunction cmds str | '/' `elem` str = [] | ||
76 | | otherwise = filter (isPrefixOf str) cmds | ||
77 | |||
78 | getCommands :: IO [String] | ||
79 | getCommands = do | ||
80 | p <- getEnv "PATH" `E.catch` econst [] | ||
81 | let ds = filter (/= "") $ split ':' p | ||
82 | es <- forM ds $ \d -> do | ||
83 | exists <- doesDirectoryExist d | ||
84 | if exists | ||
85 | then getDirectoryContents d | ||
86 | else return [] | ||
87 | return . uniqSort . filter ((/= '.') . head) . concat $ es | ||
88 | |||
89 | split :: Eq a => a -> [a] -> [[a]] | ||
90 | split _ [] = [] | ||
91 | split e l = | ||
92 | f : split e (rest ls) | ||
93 | where | ||
94 | (f,ls) = span (/=e) l | ||
95 | rest s | s == [] = [] | ||
96 | | otherwise = tail s | ||
97 | |||
98 | escape :: String -> String | ||
99 | escape [] = "" | ||
100 | escape (x:xs) | ||
101 | | isSpecialChar x = '\\' : x : escape xs | ||
102 | | otherwise = x : escape xs | ||
103 | |||
104 | isSpecialChar :: Char -> Bool | ||
105 | isSpecialChar = flip elem " &\\@\"'#?$*()[]{};" | ||
diff --git a/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs new file mode 100644 index 00000000..c85d0f92 --- /dev/null +++ b/accounts/gkleen@sif/xmonad/lib/XMonad/Prompt/MySsh.hs | |||
@@ -0,0 +1,243 @@ | |||
1 | module XMonad.Prompt.MySsh | ||
2 | ( -- * Usage | ||
3 | -- $usage | ||
4 | sshPrompt, | ||
5 | Ssh, | ||
6 | Override (..), | ||
7 | mkOverride, | ||
8 | Conn (..), | ||
9 | moshCmd, | ||
10 | moshCmd', | ||
11 | sshCmd, | ||
12 | inTmux, | ||
13 | withEnv | ||
14 | ) where | ||
15 | |||
16 | import XMonad | ||
17 | import XMonad.Util.Run | ||
18 | import XMonad.Prompt | ||
19 | |||
20 | import System.Directory | ||
21 | import System.Environment | ||
22 | import qualified Control.Exception as E | ||
23 | |||
24 | import Control.Monad | ||
25 | import Data.Maybe | ||
26 | |||
27 | import Text.Parsec.String | ||
28 | import Text.Parsec | ||
29 | import Data.Char (isSpace) | ||
30 | |||
31 | econst :: Monad m => a -> E.IOException -> m a | ||
32 | econst = const . return | ||
33 | |||
34 | -- $usage | ||
35 | -- 1. In your @~\/.xmonad\/xmonad.hs@: | ||
36 | -- | ||
37 | -- > import XMonad.Prompt | ||
38 | -- > import XMonad.Prompt.Ssh | ||
39 | -- | ||
40 | -- 2. In your keybindings add something like: | ||
41 | -- | ||
42 | -- > , ((modm .|. controlMask, xK_s), sshPrompt defaultXPConfig) | ||
43 | -- | ||
44 | -- Keep in mind, that if you want to use the completion you have to | ||
45 | -- disable the "HashKnownHosts" option in your ssh_config | ||
46 | -- | ||
47 | -- For detailed instruction on editing the key binding see | ||
48 | -- "XMonad.Doc.Extending#Editing_key_bindings". | ||
49 | |||
50 | data Override = Override | ||
51 | { oUser :: Maybe String | ||
52 | , oHost :: String | ||
53 | , oPort :: Maybe Int | ||
54 | , oCommand :: Conn -> String | ||
55 | } | ||
56 | |||
57 | mkOverride = Override { oUser = Nothing, oHost = "", oPort = Nothing, oCommand = sshCmd } | ||
58 | sshCmd c = concat | ||
59 | [ "ssh -t " | ||
60 | , if isJust $ cUser c then (fromJust $ cUser c) ++ "@" else "" | ||
61 | , cHost c | ||
62 | , if isJust $ cPort c then " -p " ++ (show $ fromJust $ cPort c) else "" | ||
63 | , " -- " | ||
64 | , cCommand c | ||
65 | ] | ||
66 | moshCmd c = concat | ||
67 | [ "mosh " | ||
68 | , if isJust $ cUser c then (fromJust $ cUser c) ++ "@" else "" | ||
69 | , cHost c | ||
70 | , if isJust $ cPort c then " --ssh=\"ssh -p " ++ (show $ fromJust $ cPort c) ++ "\"" else "" | ||
71 | , " -- " | ||
72 | , cCommand c | ||
73 | ] | ||
74 | moshCmd' p c = concat | ||
75 | [ "mosh " | ||
76 | , "--server=" ++ p ++ " " | ||
77 | , if isJust $ cUser c then (fromJust $ cUser c) ++ "@" else "" | ||
78 | , cHost c | ||
79 | , if isJust $ cPort c then " --ssh=\"ssh -p " ++ (show $ fromJust $ cPort c) ++ "\"" else "" | ||
80 | , " -- " | ||
81 | , cCommand c | ||
82 | ] | ||
83 | inTmux c | ||
84 | | null $ cCommand c = c { cCommand = "tmux new-session" } | ||
85 | | otherwise = c { cCommand = "tmux new-session \"" ++ (cCommand c) ++ "\"" } | ||
86 | withEnv :: [(String, String)] -> Conn -> Conn | ||
87 | withEnv envs c = c { cCommand = "env" ++ (concat $ map (\(n, v) -> ' ' : (n ++ "=" ++ v)) envs) ++ " " ++ (cCommand c) } | ||
88 | |||
89 | data Conn = Conn | ||
90 | { cUser :: Maybe String | ||
91 | , cHost :: String | ||
92 | , cPort :: Maybe Int | ||
93 | , cCommand :: String | ||
94 | } deriving (Eq, Show, Read) | ||
95 | |||
96 | data Ssh = Ssh | ||
97 | |||
98 | instance XPrompt Ssh where | ||
99 | showXPrompt Ssh = "SSH to: " | ||
100 | commandToComplete _ c = c | ||
101 | nextCompletion _ = getNextCompletion | ||
102 | |||
103 | toConn :: String -> Maybe Conn | ||
104 | toConn = toConn' . parse connParser "(unknown)" | ||
105 | toConn' :: Either ParseError Conn -> Maybe Conn | ||
106 | toConn' (Left _) = Nothing | ||
107 | toConn' (Right a) = Just a | ||
108 | |||
109 | connParser :: Parser Conn | ||
110 | connParser = do | ||
111 | spaces | ||
112 | user' <- optionMaybe $ try $ do | ||
113 | str <- many1 $ satisfy (\c -> (not $ isSpace c) && (c /= '@')) | ||
114 | char '@' | ||
115 | return str | ||
116 | host' <- many1 $ satisfy (not . isSpace) | ||
117 | port' <- optionMaybe $ try $ do | ||
118 | space | ||
119 | string "-p" | ||
120 | spaces | ||
121 | int <- many1 digit | ||
122 | (space >> return ()) <|> eof | ||
123 | return $ (read int :: Int) | ||
124 | spaces | ||
125 | command' <- many anyChar | ||
126 | eof | ||
127 | return $ Conn | ||
128 | { cHost = host' | ||
129 | , cUser = user' | ||
130 | , cPort = port' | ||
131 | , cCommand = command' | ||
132 | } | ||
133 | |||
134 | sshPrompt :: [Override] -> XPConfig -> X () | ||
135 | sshPrompt o c = do | ||
136 | sc <- io sshComplList | ||
137 | mkXPrompt Ssh c (mkComplFunFromList sc) $ ssh o | ||
138 | |||
139 | ssh :: [Override] -> String -> X () | ||
140 | ssh overrides str = do | ||
141 | let cmd = applyOverrides overrides str | ||
142 | liftIO $ putStr "SSH Command: " | ||
143 | liftIO $ putStrLn cmd | ||
144 | runInTerm "" cmd | ||
145 | |||
146 | applyOverrides :: [Override] -> String -> String | ||
147 | applyOverrides [] str = "ssh " ++ str | ||
148 | applyOverrides (o:os) str = case (applyOverride o str) of | ||
149 | Just str -> str | ||
150 | Nothing -> applyOverrides os str | ||
151 | |||
152 | applyOverride :: Override -> String -> Maybe String | ||
153 | applyOverride o str = let | ||
154 | conn = toConn str | ||
155 | in | ||
156 | if isNothing conn then Nothing else | ||
157 | case (fromJust conn) `matches` o of | ||
158 | True -> Just $ (oCommand o) (fromJust conn) | ||
159 | False -> Nothing | ||
160 | |||
161 | matches :: Conn -> Override -> Bool | ||
162 | a `matches` b = and | ||
163 | [ justBool (cUser a) (oUser b) (==) | ||
164 | , (cHost a) == (oHost b) | ||
165 | , justBool (cPort a) (oPort b) (==) | ||
166 | ] | ||
167 | |||
168 | justBool :: Eq a => Maybe a -> Maybe a -> (a -> a -> Bool) -> Bool | ||
169 | justBool Nothing _ _ = True | ||
170 | justBool _ Nothing _ = True | ||
171 | justBool (Just a) (Just b) match = a `match` b | ||
172 | |||
173 | sshComplList :: IO [String] | ||
174 | sshComplList = uniqSort `fmap` liftM2 (++) sshComplListLocal sshComplListGlobal | ||
175 | |||
176 | sshComplListLocal :: IO [String] | ||
177 | sshComplListLocal = do | ||
178 | h <- getEnv "HOME" | ||
179 | s1 <- sshComplListFile $ h ++ "/.ssh/known_hosts" | ||
180 | s2 <- sshComplListConf $ h ++ "/.ssh/config" | ||
181 | return $ s1 ++ s2 | ||
182 | |||
183 | sshComplListGlobal :: IO [String] | ||
184 | sshComplListGlobal = do | ||
185 | env <- getEnv "SSH_KNOWN_HOSTS" `E.catch` econst "/nonexistent" | ||
186 | fs <- mapM fileExists [ env | ||
187 | , "/usr/local/etc/ssh/ssh_known_hosts" | ||
188 | , "/usr/local/etc/ssh_known_hosts" | ||
189 | , "/etc/ssh/ssh_known_hosts" | ||
190 | , "/etc/ssh_known_hosts" | ||
191 | ] | ||
192 | case catMaybes fs of | ||
193 | [] -> return [] | ||
194 | (f:_) -> sshComplListFile' f | ||
195 | |||
196 | sshComplListFile :: String -> IO [String] | ||
197 | sshComplListFile kh = do | ||
198 | f <- doesFileExist kh | ||
199 | if f then sshComplListFile' kh | ||
200 | else return [] | ||
201 | |||
202 | sshComplListFile' :: String -> IO [String] | ||
203 | sshComplListFile' kh = do | ||
204 | l <- readFile kh | ||
205 | return $ map (getWithPort . takeWhile (/= ',') . concat . take 1 . words) | ||
206 | $ filter nonComment | ||
207 | $ lines l | ||
208 | |||
209 | sshComplListConf :: String -> IO [String] | ||
210 | sshComplListConf kh = do | ||
211 | f <- doesFileExist kh | ||
212 | if f then sshComplListConf' kh | ||
213 | else return [] | ||
214 | |||
215 | sshComplListConf' :: String -> IO [String] | ||
216 | sshComplListConf' kh = do | ||
217 | l <- readFile kh | ||
218 | return $ map (!!1) | ||
219 | $ filter isHost | ||
220 | $ map words | ||
221 | $ lines l | ||
222 | where | ||
223 | isHost ws = take 1 ws == ["Host"] && length ws > 1 | ||
224 | |||
225 | fileExists :: String -> IO (Maybe String) | ||
226 | fileExists kh = do | ||
227 | f <- doesFileExist kh | ||
228 | if f then return $ Just kh | ||
229 | else return Nothing | ||
230 | |||
231 | nonComment :: String -> Bool | ||
232 | nonComment [] = False | ||
233 | nonComment ('#':_) = False | ||
234 | nonComment ('|':_) = False -- hashed, undecodeable | ||
235 | nonComment _ = True | ||
236 | |||
237 | getWithPort :: String -> String | ||
238 | getWithPort ('[':str) = host ++ " -p " ++ port | ||
239 | where (host,p) = break (==']') str | ||
240 | port = case p of | ||
241 | ']':':':x -> x | ||
242 | _ -> "22" | ||
243 | getWithPort str = str | ||
diff --git a/accounts/gkleen@sif/xmonad/package.yaml b/accounts/gkleen@sif/xmonad/package.yaml new file mode 100644 index 00000000..48de1a53 --- /dev/null +++ b/accounts/gkleen@sif/xmonad/package.yaml | |||
@@ -0,0 +1,30 @@ | |||
1 | name: xmonad-yggdrasil | ||
2 | |||
3 | executables: | ||
4 | xmonad: | ||
5 | dependencies: | ||
6 | - base | ||
7 | - xmonad | ||
8 | - xmonad-contrib | ||
9 | - aeson | ||
10 | - bytestring | ||
11 | - text | ||
12 | - temporary | ||
13 | - filepath | ||
14 | - directory | ||
15 | - network | ||
16 | - unix | ||
17 | - utf8-string | ||
18 | - parsec | ||
19 | - process | ||
20 | - mtl | ||
21 | - X11 | ||
22 | - transformers | ||
23 | - containers | ||
24 | - hostname | ||
25 | - libnotify | ||
26 | |||
27 | main: xmonad.hs | ||
28 | source-dirs: | ||
29 | - . | ||
30 | - lib | ||
diff --git a/accounts/gkleen@sif/xmonad/stack.nix b/accounts/gkleen@sif/xmonad/stack.nix new file mode 100644 index 00000000..17a49e04 --- /dev/null +++ b/accounts/gkleen@sif/xmonad/stack.nix | |||
@@ -0,0 +1,17 @@ | |||
1 | { ghc, nixpkgs ? import ./nixpkgs.nix {} }: | ||
2 | |||
3 | let | ||
4 | haskellPackages = import ./stackage.nix { inherit nixpkgs; }; | ||
5 | inherit (nixpkgs {}) pkgs; | ||
6 | in pkgs.haskell.lib.buildStackProject { | ||
7 | inherit ghc; | ||
8 | inherit (haskellPackages) stack; | ||
9 | name = "stackenv"; | ||
10 | buildInputs = (with pkgs; | ||
11 | [ xorg.libX11 xorg.libXrandr xorg.libXinerama xorg.libXScrnSaver xorg.libXext xorg.libXft | ||
12 | cairo | ||
13 | glib | ||
14 | ]) ++ (with haskellPackages; | ||
15 | [ | ||
16 | ]); | ||
17 | } | ||
diff --git a/accounts/gkleen@sif/xmonad/stack.yaml b/accounts/gkleen@sif/xmonad/stack.yaml new file mode 100644 index 00000000..b8ed1147 --- /dev/null +++ b/accounts/gkleen@sif/xmonad/stack.yaml | |||
@@ -0,0 +1,10 @@ | |||
1 | nix: | ||
2 | enable: true | ||
3 | shell-file: stack.nix | ||
4 | |||
5 | resolver: lts-13.21 | ||
6 | |||
7 | packages: | ||
8 | - . | ||
9 | |||
10 | extra-deps: [] | ||
diff --git a/accounts/gkleen@sif/xmonad/xmonad-yggdrasil.nix b/accounts/gkleen@sif/xmonad/xmonad-yggdrasil.nix new file mode 100644 index 00000000..e8786d35 --- /dev/null +++ b/accounts/gkleen@sif/xmonad/xmonad-yggdrasil.nix | |||
@@ -0,0 +1,21 @@ | |||
1 | { mkDerivation, aeson, base, bytestring, containers, directory | ||
2 | , filepath, hostname, hpack, mtl, network, parsec, process, stdenv | ||
3 | , temporary, transformers, unix, utf8-string, X11, xmonad | ||
4 | , xmonad-contrib, libnotify | ||
5 | }: | ||
6 | mkDerivation { | ||
7 | pname = "xmonad-yggdrasil"; | ||
8 | version = "0.0.0"; | ||
9 | src = ./.; | ||
10 | isLibrary = false; | ||
11 | isExecutable = true; | ||
12 | libraryToolDepends = [ hpack ]; | ||
13 | executableHaskellDepends = [ | ||
14 | aeson base bytestring containers directory filepath hostname mtl | ||
15 | network parsec process temporary transformers unix utf8-string X11 | ||
16 | xmonad xmonad-contrib libnotify | ||
17 | ]; | ||
18 | preConfigure = "hpack"; | ||
19 | license = "unknown"; | ||
20 | hydraPlatforms = stdenv.lib.platforms.none; | ||
21 | } | ||
diff --git a/accounts/gkleen@sif/xmonad/xmonad.hs b/accounts/gkleen@sif/xmonad/xmonad.hs new file mode 100644 index 00000000..f3a59f34 --- /dev/null +++ b/accounts/gkleen@sif/xmonad/xmonad.hs | |||
@@ -0,0 +1,898 @@ | |||
1 | {-# LANGUAGE TupleSections, ViewPatterns, OverloadedStrings, FlexibleInstances, UndecidableInstances, MultiWayIf #-} | ||
2 | |||
3 | import XMonad | ||
4 | import XMonad.Hooks.DynamicLog | ||
5 | import XMonad.Hooks.ManageDocks | ||
6 | import XMonad.Util.Run | ||
7 | import XMonad.Util.Loggers | ||
8 | import XMonad.Util.EZConfig(additionalKeys) | ||
9 | import System.IO | ||
10 | import System.IO.Error | ||
11 | import System.Environment | ||
12 | import Data.Map (Map) | ||
13 | import qualified Data.Map as Map | ||
14 | import qualified XMonad.StackSet as W | ||
15 | import System.Exit | ||
16 | import Control.Monad.State (get) | ||
17 | -- import XMonad.Layout.Spiral | ||
18 | import Data.Ratio | ||
19 | import Data.List | ||
20 | import Data.Char | ||
21 | import Data.Maybe (fromMaybe, listToMaybe, maybeToList, catMaybes, isJust) | ||
22 | import XMonad.Layout.Tabbed | ||
23 | import XMonad.Prompt | ||
24 | import XMonad.Prompt.Input | ||
25 | import XMonad.Util.Scratchpad | ||
26 | import XMonad.Util.NamedScratchpad | ||
27 | import Control.Monad (sequence, liftM, liftM2, join, void) | ||
28 | import XMonad.Util.WorkspaceCompare | ||
29 | import XMonad.Layout.NoBorders | ||
30 | import XMonad.Layout.PerWorkspace | ||
31 | import XMonad.Layout.SimplestFloat | ||
32 | import XMonad.Layout.Renamed | ||
33 | import XMonad.Layout.Reflect | ||
34 | import XMonad.Layout.OnHost | ||
35 | import XMonad.Layout.Combo | ||
36 | import XMonad.Layout.ComboP | ||
37 | import XMonad.Layout.Column | ||
38 | import XMonad.Layout.TwoPane | ||
39 | import XMonad.Layout.IfMax | ||
40 | import XMonad.Layout.LayoutBuilder | ||
41 | import XMonad.Layout.WindowNavigation | ||
42 | import XMonad.Layout.Dwindle | ||
43 | import XMonad.Layout.TrackFloating | ||
44 | import System.Process | ||
45 | import System.Directory (removeFile) | ||
46 | import System.Posix.Files | ||
47 | import System.FilePath ((</>)) | ||
48 | import Control.Concurrent | ||
49 | import System.Posix.Process (getProcessID) | ||
50 | import System.IO.Error | ||
51 | import System.IO | ||
52 | import XMonad.Hooks.ManageHelpers hiding (CW) | ||
53 | import XMonad.Hooks.UrgencyHook as U | ||
54 | import XMonad.Hooks.EwmhDesktops | ||
55 | import XMonad.StackSet (RationalRect (..)) | ||
56 | import Control.Monad (when, filterM, (<=<)) | ||
57 | import Graphics.X11.ExtraTypes.XF86 | ||
58 | import XMonad.Util.Cursor | ||
59 | import XMonad.Actions.Warp | ||
60 | import XMonad.Actions.FloatKeys | ||
61 | import XMonad.Util.SpawnOnce | ||
62 | import System.Directory | ||
63 | import System.FilePath | ||
64 | import XMonad.Actions.CopyWindow | ||
65 | import XMonad.Hooks.ServerMode | ||
66 | import XMonad.Actions.Commands | ||
67 | import XMonad.Actions.CycleWS | ||
68 | import XMonad.Actions.RotSlaves | ||
69 | import XMonad.Actions.UpdatePointer | ||
70 | import XMonad.Prompt.Window | ||
71 | import Data.IORef | ||
72 | import Data.Monoid | ||
73 | import Data.String | ||
74 | import qualified XMonad.Actions.PhysicalScreens as P | ||
75 | |||
76 | import XMonad.Layout.IM | ||
77 | |||
78 | import XMonad.Prompt.MyShell | ||
79 | import XMonad.Prompt.MyPass | ||
80 | import XMonad.Prompt.MySsh | ||
81 | |||
82 | import XMonad.Mpv | ||
83 | |||
84 | import Network.HostName | ||
85 | |||
86 | import Control.Applicative ((<$>)) | ||
87 | |||
88 | import Libnotify as Notify hiding (appName) | ||
89 | import qualified Libnotify as Notify (appName) | ||
90 | import Libnotify (Notification) | ||
91 | -- import System.Information.Battery | ||
92 | |||
93 | import Data.Int (Int32) | ||
94 | |||
95 | import System.Posix.Process | ||
96 | import System.Posix.Signals | ||
97 | import System.Posix.IO as Posix | ||
98 | import Control.Exception | ||
99 | |||
100 | import System.IO.Unsafe | ||
101 | |||
102 | import Control.Monad.Trans.Class | ||
103 | import Control.Monad.Trans.Maybe | ||
104 | |||
105 | import Data.Fixed (Micro) | ||
106 | |||
107 | import qualified Data.Text as Text | ||
108 | import Data.Ord (comparing) | ||
109 | import Debug.Trace | ||
110 | |||
111 | instance MonadIO m => IsString (m ()) where | ||
112 | fromString = spawn | ||
113 | |||
114 | type KeyMap = Map (ButtonMask, KeySym) (X ()) | ||
115 | |||
116 | data Host = Host | ||
117 | { hName :: HostName | ||
118 | , hManageHook :: ManageHook | ||
119 | , hWsp :: Integer -> WorkspaceId | ||
120 | , hCoWsp :: String -> Maybe WorkspaceId | ||
121 | , hKeysMod :: XConfig Layout -> (KeyMap -> KeyMap) | ||
122 | , hScreens :: [P.PhysicalScreen] | ||
123 | , hKbLayouts :: [(String, Maybe String)] | ||
124 | , hCmds :: X [(String, X ())] | ||
125 | , hKeyUpKeys :: XConfig Layout -> KeyMap | ||
126 | } | ||
127 | |||
128 | defaultHost = Host { hName = "unkown" | ||
129 | , hManageHook = composeOne [manageScratchTerm] | ||
130 | , hWsp = show | ||
131 | , hCoWsp = const Nothing | ||
132 | , hKeysMod = const id | ||
133 | , hScreens = [0,1..] | ||
134 | , hKbLayouts = [ ("us", Just "dvp") | ||
135 | , ("us", Nothing) | ||
136 | , ("de", Nothing) | ||
137 | ] | ||
138 | , hCmds = return [] | ||
139 | , hKeyUpKeys = const Map.empty | ||
140 | } | ||
141 | |||
142 | browser :: String | ||
143 | browser = "env MOZ_USE_XINPUT2=1 firefox" | ||
144 | |||
145 | hostFromName :: HostName -> Host | ||
146 | hostFromName h@("vali") = defaultHost { hName = h | ||
147 | , hManageHook = composeOne $ catMaybes [ Just manageScratchTerm | ||
148 | , assign "web" $ className =? ".dwb-wrapped" | ||
149 | , assign "web" $ className =? "Chromium" | ||
150 | , assign "work" $ className =? "Emacs" | ||
151 | , assign "media" $ className =? "mpv" | ||
152 | ] | ||
153 | , hWsp = hWsp | ||
154 | , hCoWsp = hCoWsp | ||
155 | , hKeysMod = \conf -> Map.union $ (Map.fromList $ join $ map (spawnBindings conf) [ (xK_d, ["chromium", "chromium $(xclip -o)"]) | ||
156 | , (xK_e, ["emacsclient -c"]) | ||
157 | ]) | ||
158 | `Map.union` | ||
159 | ( Map.fromList [ ((XMonad.modMask conf .|. controlMask, xK_Return), scratchpadSpawnActionCustom $ (XMonad.terminal conf) ++ " -name scratchpad -title scratchpad -e tmux new-session -D -s scratch") | ||
160 | ] ) | ||
161 | , hScreens = hScreens defaultHost | ||
162 | } | ||
163 | where | ||
164 | workspaceNames = Map.fromList [ (2, "web") | ||
165 | , (3, "work") | ||
166 | , (10, "media") | ||
167 | ] | ||
168 | hWsp = wspFromMap workspaceNames | ||
169 | hCoWsp = coWspFromMap workspaceNames | ||
170 | assign wsp test = (\wsp -> test -?> doShift wsp) <$> hCoWsp wsp | ||
171 | hostFromName h | ||
172 | | h `elem` ["hel", "sif"] = defaultHost { hName = h | ||
173 | , hManageHook = namedScratchpadManageHook scratchpads <+> composeOne (catMaybes | ||
174 | [ assign "mpv" $ className =? "mpv" | ||
175 | , assign "mpv" $ (className =? "URxvt" <&&> title =? "irssi") | ||
176 | , assign "mpv" $ (className =? "URxvt" <&&> resource =? "presentation") | ||
177 | , assign "mpv" $ stringProperty "WM_WINDOW_ROLE" =? "presentation" | ||
178 | , assign "read" $ stringProperty "WM_WINDOW_ROLE" =? "presenter" | ||
179 | , assign "mpv" $ className =? "factorio" | ||
180 | , assign "web" $ className =? "chromium-browser" | ||
181 | , assign "web" $ className =? "Google-chrome" | ||
182 | , assign "work" $ (appName =? "Devtools" <&&> className =? "Firefox") | ||
183 | , assign "work" $ className =? "Postman" | ||
184 | , assign "web" $ className =? "Firefox" | ||
185 | , assign "comm" $ (className =? "URxvt" <&&> resource =? "comm") | ||
186 | , assign "comm" $ (className =? "Emacs" <&&> title =? "Mail") | ||
187 | , assign "comm" $ className =? "Zulip" | ||
188 | , assign "comm" $ className =? "Discord" | ||
189 | , assign "media" $ (className =? "URxvt" <&&> resource =? "media") | ||
190 | , assign "media" $ (className =? "URxvt" <&&> title =? "streamlink") | ||
191 | , assign "media" $ (className =? "URxvt" <&&> title =? "mpv") | ||
192 | , assign "monitor" $ (className =? "URxvt" <&&> fmap ("monitor" `isInfixOf`) title) | ||
193 | , assign "monitor" $ className =? "Grafana" | ||
194 | , Just $ (className =? "URxvt" <&&> resource =? "htop") -?> centerFloat | ||
195 | , Just $ (className =? "Scp-dbus-service.py") -?> centerFloat | ||
196 | , Just $ (className =? "URxvt" <&&> resource =? "log") -?> centerFloat | ||
197 | , assign "work" $ className =? "URxvt" | ||
198 | , assign' ["work", "uni"] $ (className =? "Emacs" <&&> appName /=? "Edit_with_Emacs_FRAME") | ||
199 | , assign' ["work", "uni"] $ className =? "jetbrains-idea-ce" | ||
200 | , assign "read" $ className =? "llpp" | ||
201 | , assign "read" $ className =? "Evince" | ||
202 | , assign "read" $ fmap ("zathura" `isInfixOf`) title | ||
203 | , assign "read" $ className =? "MuPDF" | ||
204 | , assign "read" $ className =? "Xournal" | ||
205 | , assign "read" $ appName =? "com-trollworks-gcs-app-GCS" | ||
206 | , assign "read" $ appName =? "Tux.py" | ||
207 | , assign "read" $ className =? "Gnucash" | ||
208 | , assign "comm" $ className =? "Skype" | ||
209 | , assign "comm" $ className =? "Daily" | ||
210 | , assign "comm" $ className =? "Pidgin" | ||
211 | , assign "comm" $ className =? "Slack" | ||
212 | , Just $ (resource =? "xvkbd") -?> doRectFloat $ RationalRect (1 % 8) (3 % 8) (6 % 8) (4 % 8) | ||
213 | , Just $ (stringProperty "_NET_WM_WINDOW_TYPE" =? "_NET_WM_WINDOW_TYPE_DIALOG") -?> doFloat | ||
214 | , Just $ (className =? "Dunst") -?> doFloat | ||
215 | , Just $ (className =? "Xmessage") -?> doCenterFloat | ||
216 | , Just $ (className =? "Nm-openconnect-auth-dialog") -?> centerFloat | ||
217 | , Just $ (className =? "Pinentry") -?> doCenterFloat | ||
218 | , Just $ (className =? "pinentry") -?> doCenterFloat | ||
219 | , Just $ (appName =? "Edit_with_Emacs_FRAME") -?> centerFloat | ||
220 | , Just $ (stringProperty "WM_WINDOW_ROLE" =? "GtkFileChooseDialog") -?> centerFloatSmall | ||
221 | , Just $ (className =? "Nvidia-settings") -?> doCenterFloat | ||
222 | , Just $ fmap ("Minetest" `isInfixOf`) title -?> doIgnore | ||
223 | , Just $ fmap ("Automachef" `isInfixOf`) title -?> doIgnore | ||
224 | ]) | ||
225 | , hWsp = hWsp | ||
226 | , hCoWsp = hCoWsp | ||
227 | , hKeysMod = \conf -> Map.union $ (Map.fromList $ join $ map (spawnBindings conf) [ (xK_e, ["emacsclient -c"]) | ||
228 | , (xK_d, [fromString browser, fromString $ browser ++ " $(xclip -o)", fromString $ "notmuch-links"]) | ||
229 | , (xK_f, ["urxvtc -name comm -title Feeds -e mosh odin -- tmux new-session -ADs comm"]) | ||
230 | , (xK_c, [ inputPrompt xPConfig "dc" ?+ dc ]) | ||
231 | , (xK_g, ["pidgin"]) | ||
232 | , (xK_s, ["skype"]) | ||
233 | -- , (xK_p, [mkPassPrompt "Type password" pwType xPConfig, mkPassPrompt "Show password" pwShow xPConfig, mkPassPrompt "Copy password" pwClip xPConfig]) | ||
234 | , (xK_w, ["sudo rewacom"]) | ||
235 | , (xK_y, [ "tmux new-window -dt media /var/media/link.hs $(xclip -o)" | ||
236 | , "urxvtc -name media -e tmuxp load /var/media" | ||
237 | ]) | ||
238 | , (xK_l, [ "tmux new-window -dt media mpv $(xclip -o)" | ||
239 | , "tmux new-window -dt media streamlink --retry-open 10 $(xclip -o)" | ||
240 | ]) | ||
241 | , (xK_m, [ "emacsclient -c -F \"'(title . \\\"Mail\\\")\" -e '(notmuch)'" | ||
242 | , "emacsclient -c -F \"'(title . \\\"Mail\\\")\" -e '(notmuch-mua-new-mail)'" | ||
243 | , "emacsclient -c -F \"'(title . \\\"Mail\\\")\" -e \"(browse-url-mail \"$(xclip -o)\")\"" | ||
244 | ]) | ||
245 | , (xK_Return, ["keynav start,windowzoom", "keynav start"]) | ||
246 | , (xK_t, [inputPrompt xPConfig "fuzzytime timer" ?+ fuzzytime, fuzzytime "unset", work_fuzzytime]) | ||
247 | , (xK_a, [inputPrompt xPConfig "adjmix" ?+ adjmix]) | ||
248 | , (xK_s, [ inputPromptWithCompl xPConfig "start synergy" synergyCompl ?+ synergyStart | ||
249 | , inputPromptWithCompl xPConfig "stop synergy" synergyCompl ?+ synergyStop | ||
250 | ]) | ||
251 | , (xK_h, [ "urxvtc -name htop -e htop" | ||
252 | , "urxvtc -name log -e journalctl -xef" | ||
253 | ]) | ||
254 | , (xK_x, [ "autorandr -c" | ||
255 | , "autorandr -fl default" | ||
256 | ]) | ||
257 | , (xK_z, [ "zulip -- --force-device-scale-factor=2" | ||
258 | ]) | ||
259 | ]) | ||
260 | `Map.union` | ||
261 | ( Map.fromList [ ((XMonad.modMask conf .|. controlMask, xK_Return), namedScratchpadAction scratchpads "term") | ||
262 | , ((XMonad.modMask conf .|. controlMask, xK_a), namedScratchpadAction scratchpads "pavucontrol") | ||
263 | , ((XMonad.modMask conf .|. controlMask, xK_w), namedScratchpadAction scratchpads "alarms") | ||
264 | , ((XMonad.modMask conf .|. controlMask, xK_b), namedScratchpadAction scratchpads "blueman") | ||
265 | , ((XMonad.modMask conf .|. controlMask, xK_p), namedScratchpadAction scratchpads "keepassxc") | ||
266 | , ((XMonad.modMask conf .|. controlMask, xK_t), namedScratchpadAction scratchpads "toggl") | ||
267 | , ((XMonad.modMask conf .|. controlMask, xK_e), namedScratchpadAction scratchpads "emacs") | ||
268 | , ((XMonad.modMask conf .|. controlMask, xK_m), namedScratchpadAction scratchpads "calendar") | ||
269 | , ((XMonad.modMask conf .|. controlMask, xK_f), namedScratchpadAction scratchpads "music") | ||
270 | , ((XMonad.modMask conf .|. mod1Mask, xK_Up), rotate U) | ||
271 | , ((XMonad.modMask conf .|. mod1Mask, xK_Down), rotate D) | ||
272 | , ((XMonad.modMask conf .|. mod1Mask, xK_Left), rotate L) | ||
273 | , ((XMonad.modMask conf .|. mod1Mask, xK_Right), rotate R) | ||
274 | -- , ((XMonad.modMask conf .|. shiftMask, xK_a), startMute "hel") | ||
275 | ] ) | ||
276 | , hKeyUpKeys = \conf -> Map.fromList [ -- ((XMonad.modMask conf .|. shiftMask, xK_a), stopMute "hel") | ||
277 | ] | ||
278 | , hScreens = hScreens defaultHost | ||
279 | , hCmds = return [ ("prev-workspace", prevWS) | ||
280 | , ("next-workspace", nextWS) | ||
281 | , ("prev-window", rotAllDown) | ||
282 | , ("next-window", rotAllUp) | ||
283 | , ("banish", banishScreen LowerRight) | ||
284 | , ("update-gpg-tty", safeSpawn "gpg-connect-agent" ["UPDATESTARTUPTTY", "/bye"]) | ||
285 | , ("rescreen", rescreen) | ||
286 | , ("repanel", do | ||
287 | spawn "nm-applet" | ||
288 | spawn "blueman-applet" | ||
289 | spawn "pasystray" | ||
290 | spawn "kdeconnect-indicator" | ||
291 | spawn "dunst -print" | ||
292 | spawn "udiskie" | ||
293 | spawn "autocutsel -s PRIMARY" | ||
294 | spawn "autocutsel -s CLIPBOARD" | ||
295 | ) | ||
296 | , ("pause", mediaMpv $ MpvSetProperty "pause" True) | ||
297 | , ("unpause", mediaMpv $ MpvSetProperty "pause" False) | ||
298 | , ("exit", io $ exitWith ExitSuccess) | ||
299 | ] | ||
300 | } | ||
301 | where | ||
302 | withGdkScale act = void . xfork $ setEnv "GDK_SCALE" "2" >> act | ||
303 | workspaceNames = Map.fromList [ (1, "comm") | ||
304 | , (2, "web") | ||
305 | , (3, "work") | ||
306 | , (4, "read") | ||
307 | , (5, "monitor") | ||
308 | , (6, "uni") | ||
309 | , (9, "media") | ||
310 | , (10, "mpv") | ||
311 | ] | ||
312 | scratchpads = [ NS "term" "urxvtc -name scratchpad -title scratchpad -e tmux new-session -AD -s scratch" (resource =? "scratchpad") centerFloat | ||
313 | , NS "pavucontrol" "pavucontrol" (resource =? "pavucontrol") centerFloat | ||
314 | , NS "alarms" "alarm-clock-applet" (className =? "Alarm-clock-applet" <&&> title =? "Alarms") centerFloat | ||
315 | , NS "blueman" "blueman-manager" (className =? ".blueman-manager-wrapped") centerFloat | ||
316 | , NS "keepassxc" "keepassxc" (className =? "KeePassXC") centerFloat | ||
317 | , NS "toggl" "toggldesktop" (className =? "Toggl Desktop") centerFloat | ||
318 | , NS "calendar" "minetime -- --force-device-scale-factor=1.6" (className =? "MineTime") centerFloat | ||
319 | , NS "emacs" "emacsclient -c -F \"'(title . \\\"Scratchpad\\\")\"" (className =? "Emacs" <&&> title =? "Scratchpad") centerFloat | ||
320 | , NS "music" "google-play-music-desktop-player --force-device-scale-factor=1.6" (className =? "Google Play Music Desktop Player") centerFloat | ||
321 | ] | ||
322 | centerFloat = customFloating $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8) | ||
323 | centerFloatSmall = customFloating $ RationalRect (1 % 4) (1 % 4) (1 % 2) (1 % 2) | ||
324 | hWsp = wspFromMap workspaceNames | ||
325 | hCoWsp = coWspFromMap workspaceNames | ||
326 | assign wsp test = (\wsp -> test -?> doShift wsp) <$> hCoWsp wsp | ||
327 | assign' :: [String] -> Query Bool -> Maybe MaybeManageHook | ||
328 | assign' wsps test = do | ||
329 | wsIds <- mapM hCoWsp wsps | ||
330 | return $ test -?> go wsIds | ||
331 | where | ||
332 | go :: [WorkspaceId] -> ManageHook | ||
333 | go wsps = do | ||
334 | visWsps <- liftX $ (\wset -> W.tag . W.workspace <$> W.current wset : W.visible wset) <$> gets windowset | ||
335 | case (filter (`elem` visWsps) wsps, wsps) of | ||
336 | (wsp : _, _) -> doShift wsp | ||
337 | (_, wsp : _) -> doShift wsp | ||
338 | ([], []) -> return mempty | ||
339 | rotate rot = do | ||
340 | safeSpawn "xrandr" ["--output", "eDP-1", "--rotate", xrandrDir] | ||
341 | mapM_ rotTouch touchscreens | ||
342 | where | ||
343 | xrandrDir = case rot of | ||
344 | U -> "normal" | ||
345 | L -> "left" | ||
346 | R -> "right" | ||
347 | D -> "inverted" | ||
348 | matrix = case rot of | ||
349 | U -> [ [ 1, 0, 0] | ||
350 | , [ 0, 1, 0] | ||
351 | , [ 0, 0, 1] | ||
352 | ] | ||
353 | L -> [ [ 0, -1, 1] | ||
354 | , [ 1, 0, 0] | ||
355 | , [ 0, 0, 1] | ||
356 | ] | ||
357 | R -> [ [ 0, 1, 0] | ||
358 | , [-1, 0, 1] | ||
359 | , [ 0, 0, 1] | ||
360 | ] | ||
361 | D -> [ [-1, 0, 1] | ||
362 | , [ 0, -1, 1] | ||
363 | , [ 0, 0, 1] | ||
364 | ] | ||
365 | touchscreens = [ "Wacom Co.,Ltd. Pen and multitouch sensor Finger touch" | ||
366 | , "Wacom Co.,Ltd. Pen and multitouch sensor Pen stylus" | ||
367 | , "Wacom Co.,Ltd. Pen and multitouch sensor Pen eraser" | ||
368 | ] | ||
369 | rotTouch screen = do | ||
370 | safeSpawn "xinput" $ ["set-prop", screen, "Coordinate Transformation Matrix"] ++ map (\n -> show n ++ ",") (concat matrix) | ||
371 | safeSpawn "xinput" ["map-to-output", screen, "eDP-1"] | ||
372 | withPw f label = io . void . forkProcess $ do | ||
373 | uninstallSignalHandlers | ||
374 | void $ createSession | ||
375 | (dropWhileEnd isSpace -> pw) <- readCreateProcess (proc "pass" ["show", label]) "" | ||
376 | void $ f pw | ||
377 | pwType :: String -> X () | ||
378 | pwType = withPw $ readCreateProcess (proc "xdotool" ["type", "--clearmodifiers", "--file", "-"]) | ||
379 | pwClip label = safeSpawn "pass" ["show", "--clip", label] | ||
380 | pwShow :: String -> X () | ||
381 | pwShow = withPw $ \pw -> do | ||
382 | xmessage <- fromMaybe "xmessage" <$> liftIO (lookupEnv "XMONAD_XMESSAGE") | ||
383 | readCreateProcess (proc xmessage ["-file", "-"]) pw | ||
384 | fuzzytime str = safeSpawn "fuzzytime" $ "timer" : words str | ||
385 | work_fuzzytime = io . void . forkProcess $ do | ||
386 | readCreateProcess (proc "worktime" []) "" >>= safeSpawn "fuzzytime" . ("timer" : ) . pure | ||
387 | adjmix str = safeSpawn "adjmix" $ words str | ||
388 | dc expr = void . xfork $ do | ||
389 | result <- readProcess "dc" [] $ expr ++ "f" | ||
390 | let | ||
391 | (first : rest) = filter (not . null) $ lines result | ||
392 | notification = Notify.summary first <> Notify.body (unlines rest) <> Notify.timeout Infinite <> Notify.urgency Normal <> Notify.appName "dc" | ||
393 | void $ Notify.display notification | ||
394 | synergyCompl = mkComplFunFromList' ["mathw86"] | ||
395 | synergyStart host = safeSpawn "systemctl" ["--user", "start", "synergy-rtunnel@" ++ host ++ ".service"] | ||
396 | synergyStop host = safeSpawn "systemctl" ["--user", "stop", "synergy-rtunnel@" ++ host ++ ".service"] | ||
397 | |||
398 | hostFromName _ = defaultHost | ||
399 | |||
400 | -- muteRef :: IORef (Maybe (String, Notification)) | ||
401 | -- {-# NOINLINE muteRef #-} | ||
402 | -- muteRef = unsafePerformIO $ newIORef Nothing | ||
403 | |||
404 | -- startMute, stopMute :: String -> X () | ||
405 | -- startMute sink = liftIO $ do | ||
406 | -- muted <- isJust <$> readIORef muteRef | ||
407 | -- when (not muted) $ do | ||
408 | -- let | ||
409 | -- notification = Notify.summary "Muted" <> Notify.timeout Infinite <> Notify.urgency Normal | ||
410 | -- level = "0.0dB" | ||
411 | -- -- level <- runProcessWithInput "ssh" ["bragi", "cat", "/dev/shm/mix/" ++ sink ++ "/level"] "" | ||
412 | -- -- callProcess "ssh" ["bragi", "adjmix", "-t", sink, "-o", "0"] | ||
413 | -- hPutStrLn stderr "Mute" | ||
414 | -- writeIORef muteRef . Just . (level, ) =<< Notify.display notification | ||
415 | -- stopMute sink = liftIO $ do | ||
416 | -- let | ||
417 | -- unmute (Just (level, notification)) = do | ||
418 | -- hPutStrLn stderr "Unmute" | ||
419 | -- -- callProcess "ssh" ["bragi", "adjmix", "-t", sink, "-o", level] | ||
420 | -- Notify.close notification | ||
421 | -- unmute Nothing = return () | ||
422 | -- muted <- isJust <$> readIORef muteRef | ||
423 | -- when muted . join . atomicModifyIORef muteRef $ (Nothing, ) . unmute | ||
424 | |||
425 | wspFromMap workspaceNames = \i -> case Map.lookup i workspaceNames of | ||
426 | Just str -> show i ++ " " ++ str | ||
427 | Nothing -> show i | ||
428 | |||
429 | coWspFromMap workspaceNames = \str -> case filter ((== str) . snd) $ Map.toList workspaceNames of | ||
430 | [] -> Nothing | ||
431 | [(i, _)] -> Just $ wspFromMap workspaceNames i | ||
432 | _ -> Nothing | ||
433 | |||
434 | spawnModifiers = [0, controlMask, shiftMask .|. controlMask] | ||
435 | spawnBindings :: XConfig layout -> (KeySym, [X ()]) -> [((KeyMask, KeySym), X ())] | ||
436 | spawnBindings conf (k, cmds) = zipWith (\m cmd -> ((modm .|. mod1Mask .|. m, k), cmd)) spawnModifiers cmds | ||
437 | where | ||
438 | modm = XMonad.modMask conf | ||
439 | |||
440 | manageScratchTerm = (resource =? "scratchpad" <||> resource =? "keysetup") -?> doRectFloat $ RationalRect (1 % 16) (1 % 16) (7 % 8) (7 % 8) | ||
441 | |||
442 | tabbedLayout t = renamed [Replace "Tabbed"] $ reflectHoriz $ t CustomShrink $ tabbedTheme | ||
443 | tabbedLayoutHoriz t = renamed [Replace "Tabbed Horiz"] $ reflectVert $ t CustomShrink $ tabbedTheme | ||
444 | tabbedTheme = def | ||
445 | { activeColor = "black" | ||
446 | , inactiveColor = "black" | ||
447 | , urgentColor = "black" | ||
448 | , activeBorderColor = "grey" | ||
449 | , inactiveBorderColor = "#202020" | ||
450 | , urgentBorderColor = "#bb0000" | ||
451 | , activeTextColor = "grey" | ||
452 | , inactiveTextColor = "grey" | ||
453 | , urgentTextColor = "grey" | ||
454 | , decoHeight = 32 | ||
455 | , fontName = "xft:Fira Mono for Powerline:style=Medium:pixelsize=22.5" | ||
456 | } | ||
457 | |||
458 | main :: IO () | ||
459 | main = do | ||
460 | arguments <- either (const []) id <$> tryIOError getArgs | ||
461 | case arguments of | ||
462 | ["--command", s] -> do | ||
463 | d <- openDisplay "" | ||
464 | rw <- rootWindow d $ defaultScreen d | ||
465 | a <- internAtom d "XMONAD_COMMAND" False | ||
466 | m <- internAtom d s False | ||
467 | allocaXEvent $ \e -> do | ||
468 | setEventType e clientMessage | ||
469 | setClientMessageEvent e rw a 32 m currentTime | ||
470 | sendEvent d rw False structureNotifyMask e | ||
471 | sync d False | ||
472 | _ -> do | ||
473 | -- batteryMon <- xfork $ monitorBattery Nothing Nothing | ||
474 | hostname <- getHostName | ||
475 | let | ||
476 | host = hostFromName hostname | ||
477 | setEnv "HOST" hostname | ||
478 | let myConfig = withHostUrgency . ewmh $ docks def | ||
479 | { manageHook = hManageHook host | ||
480 | , terminal = "urxvtc" | ||
481 | , layoutHook = smartBorders . avoidStruts $ windowNavigation layout' | ||
482 | , logHook = do | ||
483 | dynamicLogString xmobarPP' >>= writeProps | ||
484 | updatePointer (99 % 100, 98 % 100) (0, 0) | ||
485 | , modMask = mod4Mask | ||
486 | , keys = \conf -> hKeysMod host conf $ myKeys' conf host | ||
487 | , workspaces = take (length numKeys) $ map wsp [1..] | ||
488 | , startupHook = setDefaultCursor xC_left_ptr | ||
489 | , normalBorderColor = "#202020" | ||
490 | , focusedBorderColor = "grey" | ||
491 | , handleEventHook = fullscreenEventHook <+> (serverModeEventHookCmd' $ hCmds host) <+> keyUpEventHook | ||
492 | } | ||
493 | writeProps str = do | ||
494 | let encodeCChar = map $ fromIntegral . fromEnum | ||
495 | atoms = [ "_XMONAD_WORKSPACES" | ||
496 | , "_XMONAD_LAYOUT" | ||
497 | , "_XMONAD_TITLE" | ||
498 | ] | ||
499 | (flip mapM_) (zip atoms (lines str)) $ \(atom', content) -> do | ||
500 | ustring <- getAtom "UTF8_STRING" | ||
501 | atom <- getAtom atom' | ||
502 | withDisplay $ \dpy -> io $ do | ||
503 | root <- rootWindow dpy $ defaultScreen dpy | ||
504 | changeProperty8 dpy root atom ustring propModeReplace $ encodeCChar content | ||
505 | sync dpy True | ||
506 | wsp = hWsp host | ||
507 | -- We can´t define per-host layout modifiers because we lack dependent types | ||
508 | layout' = onHost "skadhi" ( onWorkspace (wsp 1) (Full ||| withIM (1%5) (Title "Buddy List") tabbedLayout') $ | ||
509 | onWorkspace (wsp 10) Full $ | ||
510 | onWorkspace (wsp 2) (Full ||| tabbedLayout') $ | ||
511 | onWorkspace (wsp 5) tabbedLayout' $ | ||
512 | onWorkspace (wsp 8) (withIM (1%5) (Title "Friends") tabbedLayout') $ | ||
513 | defaultLayouts | ||
514 | ) $ | ||
515 | onHost "vali" ( onWorkspace (wsp 2) (Full ||| tabbedLayout' ||| combineTwo (TwoPane 0.01 0.57) Full tabbedLayout') $ | ||
516 | onWorkspace (wsp 3) workLayouts $ | ||
517 | defaultLayouts | ||
518 | ) $ | ||
519 | onHost "hel" ( onWorkspace (wsp 1) (withIM (1 % 8) (Title "Buddy List") $ trackFloating tabbedLayout') $ | ||
520 | onWorkspace (wsp 2) (tabbedLayout''' ||| Dwindle R CW 1 (5 % 100)) $ | ||
521 | onWorkspace (wsp 3) workLayouts $ | ||
522 | onWorkspace (wsp 6) workLayouts $ | ||
523 | onWorkspace (wsp 4) (tabbedLayout' ||| tabbedLayoutHoriz' ||| Dwindle R CW 1 (5 % 100)) $ | ||
524 | onWorkspace (wsp 5) (tabbedLayout''' ||| Dwindle R CW 1 (5 % 100)) $ | ||
525 | onWorkspace (wsp 10) (tabbedLayout''' ||| combineTwoP (TwoPane (1 % 100) (3 % 4)) tabbedLayout''' tabbedLayout''' (ClassName "mpv") ||| Dwindle R CW 1 (5 % 100)) $ | ||
526 | defaultLayouts | ||
527 | ) $ | ||
528 | onHost "sif" ( onWorkspace (wsp 1) (withIM (1 % 8) (Title "Buddy List") $ trackFloating tabbedLayout') $ | ||
529 | onWorkspace (wsp 2) (tabbedLayout''' ||| Dwindle R CW 1 (5 % 100)) $ | ||
530 | onWorkspace (wsp 3) workLayouts $ | ||
531 | onWorkspace (wsp 6) workLayouts $ | ||
532 | onWorkspace (wsp 4) (tabbedLayout' ||| tabbedLayoutHoriz' ||| Dwindle R CW 1 (5 % 100)) $ | ||
533 | onWorkspace (wsp 5) (tabbedLayout''' ||| Dwindle R CW 1 (5 % 100)) $ | ||
534 | onWorkspace (wsp 10) (tabbedLayout''' ||| combineTwoP (TwoPane (1 % 100) (3 % 4)) tabbedLayout''' tabbedLayout''' (ClassName "mpv") ||| Dwindle R CW 1 (5 % 100)) $ | ||
535 | defaultLayouts | ||
536 | ) $ | ||
537 | defaultLayouts | ||
538 | -- tabbedLayout''' = renamed [Replace "Tabbed'"] $ IfMax 1 (noBorders Full) (tabbedLayout tabbedBottomAlways) | ||
539 | tabbedLayout''' = tabbedLayout tabbedBottom | ||
540 | tabbedLayout' = tabbedLayout tabbedBottomAlways | ||
541 | tabbedLayoutHoriz' = tabbedLayoutHoriz tabbedLeftAlways | ||
542 | defaultLayouts = {- spiralWithDir East CW (1 % 2) -} Dwindle R CW 1 (5 % 100) ||| tabbedLayout' ||| Full | ||
543 | -- workLayouts = {- spiralWithDir East CW (1 % 2) -} Dwindle R CW (2 % 1) (5 % 100) ||| tabbedLayout' ||| Full | ||
544 | workLayouts = tabbedLayout' ||| (renamed [Replace "Combined"] $ combineTwoP (TwoPane (1 % 100) (1891 % 2560)) tabbedLayout''' (Column 1.6) (ClassName "Postman" `Or` ClassName "Emacs" `Or` ClassName "jetbrains-idea-ce" `Or` (Resource "Devtools" `And` ClassName "Firefox"))) ||| Full ||| Dwindle R CW 1 (5 % 100) | ||
545 | sqrtTwo = approxRational (sqrt 2) (1 / 2560) | ||
546 | xmobarPP' = xmobarPP { ppTitle = shorten 80 | ||
547 | , ppSort = (liftM2 (.)) getSortByIndex $ return scratchpadFilterOutWorkspace | ||
548 | , ppUrgent = wrap "(" ")" . xmobarColor "red" "" | ||
549 | , ppHiddenNoWindows = xmobarColor "#202020" "" . wrap "(" ")" | ||
550 | , ppVisible = wrap "(" ")" . xmobarColor "yellow" "" | ||
551 | , ppCurrent = wrap "(" ")" . xmobarColor "green" "" | ||
552 | , ppHidden = wrap "(" ")" | ||
553 | , ppWsSep = " " | ||
554 | , ppSep = "\n" | ||
555 | } | ||
556 | withHostUrgency = case hostname of | ||
557 | "hel" -> withUrgencyHookC urgencyHook' $ urgencyConfig { suppressWhen = U.Never, remindWhen = Dont } | ||
558 | "sif" -> withUrgencyHookC urgencyHook' $ urgencyConfig { suppressWhen = U.Never, remindWhen = Dont } | ||
559 | _ -> id | ||
560 | urgencyHook' window = do | ||
561 | runQuery ((resource =? "comm" <||> resource =? "Pidgin" <||> className =? "Gajim" <||> className =? "Skype") --> safeSpawn "thinklight" ["Blink", "100"]) window | ||
562 | urgencyHook (BorderUrgencyHook { urgencyBorderColor = "#bb0000" }) window | ||
563 | shutdown :: SomeException -> IO a | ||
564 | shutdown e = do | ||
565 | let pids = [ -- batteryMon | ||
566 | ] | ||
567 | mapM_ (signalProcess sigTERM) pids | ||
568 | mapM_ (getProcessStatus False False) pids | ||
569 | throw e | ||
570 | keyUpEventHook :: Event -> X All | ||
571 | keyUpEventHook event = handle event >> return (All True) | ||
572 | where | ||
573 | handle (KeyEvent { ev_event_type = t, ev_state = m, ev_keycode = code }) | ||
574 | | t == keyRelease = withDisplay $ \dpy -> do | ||
575 | s <- io $ keycodeToKeysym dpy code 0 | ||
576 | mClean <- cleanMask m | ||
577 | ks <- asks $ hKeyUpKeys host . config | ||
578 | userCodeDef () $ whenJust (Map.lookup (mClean, s) ks) id | ||
579 | | otherwise = return () | ||
580 | handle _ = return () | ||
581 | handle shutdown $ launch myConfig | ||
582 | |||
583 | secs :: Int -> Int | ||
584 | secs = (* 1000000) | ||
585 | |||
586 | -- monitorBattery :: Maybe BatteryContext -> Maybe Notification -> IO () | ||
587 | -- monitorBattery Nothing n = do | ||
588 | -- ctx <- batteryContextNew | ||
589 | -- case ctx of | ||
590 | -- Nothing -> threadDelay (secs 10) >> monitorBattery Nothing n | ||
591 | -- Just _ -> monitorBattery ctx n | ||
592 | -- monitorBattery ctx@(Just ctx') n = do | ||
593 | -- batInfo <- getBatteryInfo ctx' | ||
594 | -- case batInfo of | ||
595 | -- Nothing -> threadDelay (secs 1) >> monitorBattery ctx n | ||
596 | -- Just batInfo -> do | ||
597 | -- let n' | ||
598 | -- | batteryState batInfo == BatteryStateDischarging | ||
599 | -- , timeLeft <= 1200 | ||
600 | -- , timeLeft > 0 = Just $ summary "Discharging" <> hint "value" percentage <> urgency u <> body (duz timeLeft ++ "left") | ||
601 | -- | otherwise = Nothing | ||
602 | -- u | ||
603 | -- | timeLeft <= 600 = Critical | ||
604 | -- | timeLeft <= 1800 = Normal | ||
605 | -- | otherwise = Low | ||
606 | -- timeLeft = batteryTimeToEmpty batInfo | ||
607 | -- percentage :: Int32 | ||
608 | -- percentage = round $ batteryPercentage batInfo | ||
609 | -- ts = [("s", 60), ("m", 60), ("h", 24), ("d", 365), ("y", 1)] | ||
610 | -- duz ms = ss | ||
611 | -- where (ss, _) = foldl (\(ss, x) (s, y) -> ((if rem x y > 0 then show (rem x y) ++ s ++ " " else "") ++ ss , quot x y)) ("", ms) ts | ||
612 | -- case n' of | ||
613 | -- Just n' -> Notify.display (maybe mempty reuse n <> Notify.appName "monitorBattery" <> n') >>= (\n -> threadDelay (secs 2) >> monitorBattery ctx (Just n)) | ||
614 | -- Nothing -> threadDelay (secs 30) >> monitorBattery ctx n | ||
615 | |||
616 | disableTouchpad, disableTrackpoint, enableTrackpoint, enableTouchpad :: X () | ||
617 | enableTouchpad = safeSpawn "xinput" ["enable", "SynPS/2 Synaptics TouchPad"] | ||
618 | disableTouchpad = safeSpawn "xinput" ["disable", "SynPS/2 Synaptics TouchPad"] | ||
619 | enableTrackpoint = safeSpawn "xinput" ["enable", "TPPS/2 IBM TrackPoint"] | ||
620 | disableTrackpoint = safeSpawn "xinput" ["disable", "TPPS/2 IBM TrackPoint"] | ||
621 | |||
622 | isDisabled :: String -> X Bool | ||
623 | isDisabled str = do | ||
624 | out <- runProcessWithInput "xinput" ["list", str] "" | ||
625 | return $ "disabled" `isInfixOf` out | ||
626 | |||
627 | |||
628 | spawnKeychain :: X () | ||
629 | spawnKeychain = do | ||
630 | home <- liftIO getHomeDirectory | ||
631 | let keys = (map ((home </>) . (".ssh/" ++)) ["id", "id-rsa"]) ++ ["6B13AA67"] | ||
632 | liftIO (maybe (return ()) (setEnv "SSH_ASKPASS") =<< findAskpass) | ||
633 | safeSpawn "keychain" . (["--agents", "gpg,ssh"] ++)=<< liftIO (filterM doesFileExist keys) | ||
634 | where | ||
635 | findAskpass = filter `liftM` readFile "/etc/zshrc" | ||
636 | filter = listToMaybe . catMaybes . map (stripPrefix "export SSH_ASKPASS=") . lines | ||
637 | |||
638 | assimilateKeychain :: X () | ||
639 | assimilateKeychain = liftIO $ assimilateKeychain' >> return () | ||
640 | assimilateKeychain' = tryIOError $ do | ||
641 | -- pid <- getProcessID | ||
642 | -- tmpDir <- lookupEnv "TMPDIR" | ||
643 | -- let tmpDir' = fromMaybe "/tmp" tmpDir | ||
644 | -- tmpFile = tmpDir' </> "xmonad-keychain" ++ (show pid) ++ ".env" | ||
645 | env <- runProcessWithInput "sh" ["-c", "eval $(keychain --eval --noask --agents gpg,ssh); env"] "" -- > " ++ tmpFile] "" | ||
646 | -- env <- readFile tmpFile | ||
647 | let envVars = Map.fromList $ map (\(k, v) -> (k, tail' v)) $ map (span (/= '=')) $ envLines | ||
648 | envVars' = Map.filterWithKey (\k _ -> k `elem` transfer) envVars | ||
649 | transfer = ["SSH_AUTH_SOCK", "SSH_AGENT_PID", "GPG_AGENT_INFO"] | ||
650 | envLines = filter (elem '=') $ lines env :: [String] | ||
651 | sequence $ map (\(k, c) -> setEnv k c) $ Map.toList envVars' | ||
652 | -- removeFile tmpFile | ||
653 | where | ||
654 | tail' [] = [] | ||
655 | tail' (x:xs) = xs | ||
656 | |||
657 | |||
658 | numKeys = [xK_parenleft, xK_parenright, xK_braceright, xK_plus, xK_braceleft, xK_bracketright, xK_bracketleft, xK_exclam, xK_equal, xK_asterisk] | ||
659 | |||
660 | instance Shrinker CustomShrink where | ||
661 | shrinkIt _ "" = [""] | ||
662 | shrinkIt s cs | ||
663 | | length cs >= 4 = cs : shrinkIt s ((reverse . drop 4 . reverse $ cs) ++ "...") | ||
664 | | otherwise = cs : shrinkIt s (init cs) | ||
665 | |||
666 | xPConfig :: XPConfig | ||
667 | xPConfig = def | ||
668 | { font = "xft:Fira Mono for Powerline:style=Medium:pixelsize=22.5" | ||
669 | , height = 32 | ||
670 | , bgColor = "black" | ||
671 | , fgColor = "grey" | ||
672 | , fgHLight = "green" | ||
673 | , bgHLight = "black" | ||
674 | , borderColor = "grey" | ||
675 | , searchPredicate = (\needle haystack -> all (`isInfixOf` map toLower haystack) . map (map toLower) $ words needle) | ||
676 | , position = Top | ||
677 | } | ||
678 | |||
679 | sshOverrides = map (\h -> mkOverride { oHost = h, oCommand = moshCmd . inTmux } ) | ||
680 | [ | ||
681 | "odin", "odin.asgard.yggdrasil" | ||
682 | , "ymir", "ymir.yggdrasil.li", "ymir.niflheim.yggdrasil" | ||
683 | , "surtr", "yggdrasil.li", "surtr.yggdrasil.li", "praseodym.org", "surtr.praseodym.org", "surtr.141.li", "141.li" | ||
684 | , "vindler", "vindler.alfheim.yggdrasil" | ||
685 | , "ullr" | ||
686 | , "heimdallr", "heimdallr.asgard.yggdrasil" | ||
687 | , "testworx" | ||
688 | ] | ||
689 | ++ | ||
690 | map (\h -> mkOverride { oHost = h, oCommand = moshCmd' "/run/current-system/sw/bin/mosh-server" . withEnv [("TERM", "xterm")] . inTmux} ) | ||
691 | [ "bragi", "bragi.asgard.yggdrasil" | ||
692 | ] | ||
693 | ++ | ||
694 | map (\h -> mkOverride { oHost = h, oCommand = sshCmd . withEnv [("TERM", "xterm")] . inTmux } ) | ||
695 | [ "remote.cip.ifi.lmu.de" | ||
696 | , "uniworx3", "uniworx4", "uniworxdb" | ||
697 | ] | ||
698 | |||
699 | backlight :: (Rational -> Rational) -> X () | ||
700 | backlight f = void . xfork . liftIO $ do | ||
701 | [ _device | ||
702 | , _class | ||
703 | , read . Text.unpack -> currentBright | ||
704 | , _currentPercentage | ||
705 | , read . Text.unpack -> maximumBright | ||
706 | ] <- Text.splitOn "," . Text.pack <$> readProcess "brightnessctl" ["-m"] "" | ||
707 | let current = currentBright % maximumBright | ||
708 | new' = f current * fromIntegral maximumBright | ||
709 | new :: Integer | ||
710 | new | floor new' < 0 = 0 | ||
711 | | ceiling new' > maximumBright = maximumBright | ||
712 | | new' >= maximumBright % 2 = ceiling new' | ||
713 | | otherwise = floor new' | ||
714 | callProcess "brightnessctl" ["-m", "s", show new] | ||
715 | |||
716 | cycleThrough :: [Rational] -> (Rational -> Rational) | ||
717 | cycleThrough opts current = fromMaybe currentOpt $ listToMaybe next' | ||
718 | where currentOpt = minimumBy (comparing $ abs . subtract current) opts | ||
719 | (_, _ : next') = break (== currentOpt) opts | ||
720 | |||
721 | cycleKbLayout :: [(String, Maybe String)] -> X () | ||
722 | cycleKbLayout [] = return () | ||
723 | cycleKbLayout layouts = liftIO $ do | ||
724 | next <- (getNext . extract) `liftM` runProcessWithInput "setxkbmap" ["-query"] "" | ||
725 | let | ||
726 | args = case next of | ||
727 | (l, Just v) -> [l, v] | ||
728 | (l, Nothing) -> [l] | ||
729 | safeSpawn "setxkbmap" args | ||
730 | where | ||
731 | extract :: String -> Maybe (String, Maybe String) | ||
732 | extract str = listToMaybe $ do | ||
733 | ["layout:", l] <- str' | ||
734 | [(l, Just v) | ["variant:", v] <- str'] ++ pure (l, Nothing) | ||
735 | where | ||
736 | str' = map words $ lines str | ||
737 | getNext :: Maybe (String, Maybe String) -> (String, Maybe String) | ||
738 | getNext = maybe (head layouts) getNext' | ||
739 | getNext' x = case elemIndex x layouts of | ||
740 | Nothing -> getNext Nothing | ||
741 | Just i -> layouts !! ((i + 1) `mod` length layouts) | ||
742 | |||
743 | mpvAll' :: MpvCommand -> IO [MpvResponse] | ||
744 | mpvAll' = mpvAll "/var/media/.mpv-ipc" | ||
745 | |||
746 | mpvOne' :: MpvCommand -> IO (Maybe MpvResponse) | ||
747 | mpvOne' = mpvOne "/var/media/.mpv-ipc" | ||
748 | |||
749 | mediaMpv :: MpvCommand -> X () | ||
750 | mediaMpv cmd = void . xfork $ print =<< mpvAll' cmd | ||
751 | |||
752 | mediaMpvTogglePause :: X () | ||
753 | mediaMpvTogglePause = void . xfork $ do | ||
754 | paused <- mapM mpvResponse <=< mpvAll' $ MpvGetProperty "pause" | ||
755 | if | ||
756 | | and paused -> print <=< mpvAll' $ MpvSetProperty "pause" False | ||
757 | | otherwise -> print <=< mpvOne' $ MpvSetProperty "pause" True | ||
758 | |||
759 | myKeys' conf host = Map.fromList $ | ||
760 | -- launch a terminal | ||
761 | [ ((modm, xK_Return), spawn $ (XMonad.terminal conf) ++ " -e tmux") | ||
762 | , ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) | ||
763 | |||
764 | -- launch dmenu | ||
765 | --, ((modm, xK_d ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"") | ||
766 | , ((modm, xK_d ), shellPrompt "Run: " xPConfig) | ||
767 | , ((modm .|. shiftMask, xK_d ), prompt "Run in Terminal: " ("urxvtc" ++ " -e") xPConfig) | ||
768 | , ((modm, xK_at ), sshPrompt sshOverrides xPConfig) | ||
769 | |||
770 | -- close focused window | ||
771 | , ((modm .|. shiftMask, xK_q ), kill) | ||
772 | , ((modm .|. controlMask .|. shiftMask, xK_q ), spawn "xkill") | ||
773 | |||
774 | -- Rotate through the available layout algorithms | ||
775 | , ((modm, xK_space ), sendMessage NextLayout) | ||
776 | |||
777 | -- Reset the layouts on the current workspace to default | ||
778 | , ((modm .|. controlMask, xK_r ), (setLayout $ XMonad.layoutHook conf) >> refresh) | ||
779 | |||
780 | -- Resize viewed windows to the correct size | ||
781 | , ((modm, xK_r ), refresh) | ||
782 | |||
783 | -- Move focus to the next window | ||
784 | , ((modm, xK_t ), windows W.focusDown) | ||
785 | |||
786 | -- Move focus to the previous window | ||
787 | , ((modm, xK_n ), windows W.focusUp ) | ||
788 | |||
789 | -- Move focus to the master window | ||
790 | , ((modm, xK_m ), windows W.focusMaster ) | ||
791 | |||
792 | -- Swap the focused window and the master window | ||
793 | , ((modm .|. shiftMask, xK_m ), windows W.swapMaster) | ||
794 | |||
795 | -- Swap the focused window with the next window | ||
796 | , ((modm .|. shiftMask, xK_t ), windows W.swapDown ) | ||
797 | |||
798 | -- Swap the focused window with the previous window | ||
799 | , ((modm .|. shiftMask, xK_n ), windows W.swapUp ) | ||
800 | |||
801 | -- Swap the focused window with the previous window | ||
802 | , ((modm .|. shiftMask .|. controlMask, xK_m), sendMessage SwapWindow) | ||
803 | |||
804 | , ((modm, xK_Right), sendMessage $ Go R) | ||
805 | , ((modm, xK_Left ), sendMessage $ Go L) | ||
806 | , ((modm, xK_Up ), sendMessage $ Go U) | ||
807 | , ((modm, xK_Down ), sendMessage $ Go D) | ||
808 | , ((modm .|. shiftMask , xK_Right), sendMessage $ Move R) | ||
809 | , ((modm .|. shiftMask , xK_Left ), sendMessage $ Move L) | ||
810 | , ((modm .|. shiftMask , xK_Up ), sendMessage $ Move U) | ||
811 | , ((modm .|. shiftMask , xK_Down ), sendMessage $ Move D) | ||
812 | -- , ((modm .|. controlMask, xK_Right), withFocused $ keysMoveWindow (10, 0)) | ||
813 | -- , ((modm .|. controlMask, xK_Left ), withFocused $ keysMoveWindow (-10, 0)) | ||
814 | -- , ((modm .|. controlMask, xK_Up ), withFocused $ keysMoveWindow (0, -10)) | ||
815 | -- , ((modm .|. controlMask, xK_Down ), withFocused $ keysMoveWindow (0, 10)) | ||
816 | -- Shrink the master area | ||
817 | , ((modm, xK_h ), sendMessage Shrink) | ||
818 | |||
819 | -- Expand the master area | ||
820 | , ((modm, xK_s ), sendMessage Expand) | ||
821 | |||
822 | -- Push window back into tiling | ||
823 | , ((modm .|. shiftMask, xK_space ), withFocused $ windows . W.sink) | ||
824 | , ((modm, xK_BackSpace), focusUrgent) | ||
825 | , ((modm .|. shiftMask, xK_BackSpace), clearUrgents) | ||
826 | |||
827 | -- Increment the number of windows in the master area | ||
828 | , ((modm , xK_comma ), sendMessage (IncMasterN 1)) | ||
829 | |||
830 | -- Deincrement the number of windows in the master area | ||
831 | , ((modm , xK_period), sendMessage (IncMasterN (-1))) | ||
832 | |||
833 | , ((0, xF86XK_AudioRaiseVolume), safeSpawn "pulseaudio-ctl" ["up", "2"]) | ||
834 | , ((0, xF86XK_AudioLowerVolume), safeSpawn "pulseaudio-ctl" ["down", "2"]) | ||
835 | , ((0, xF86XK_AudioMute), safeSpawn "pulseaudio-ctl" ["mute"]) | ||
836 | , ((0, xF86XK_AudioPause), mediaMpv $ MpvSetProperty "pause" False) | ||
837 | , ((0, {-xF86XK_AudioMicMute-} 269025202), safeSpawn "pulseaudio-ctl" ["mute-input"]) | ||
838 | , ((0, xF86XK_AudioPlay), mediaMpvTogglePause) | ||
839 | , ((modm .|. mod1Mask, xK_space), mediaMpvTogglePause) | ||
840 | |||
841 | , ((0, xF86XK_MonBrightnessDown), backlight (subtract 5)) | ||
842 | , ((0, xF86XK_MonBrightnessUp), backlight (+ 5)) | ||
843 | |||
844 | , ((modm , xK_Escape), cycleKbLayout (hKbLayouts host)) | ||
845 | , ((modm .|. controlMask, xK_Escape), safeSpawn "setxkbmap" $ fst (head $ hKbLayouts host) : maybeToList (snd . head $ hKbLayouts host)) | ||
846 | |||
847 | -- Toggle the status bar gap | ||
848 | -- Use this binding with avoidStruts from Hooks.ManageDocks. | ||
849 | -- See also the statusBar function from Hooks.DynamicLog. | ||
850 | -- | ||
851 | , ((modm , xK_b ), sendMessage ToggleStruts) | ||
852 | |||
853 | , ((modm .|. shiftMask, xK_p ), safeSpawn "playerctl" ["-a", "pause"]) | ||
854 | |||
855 | -- Quit xmonad | ||
856 | , ((modm .|. shiftMask, xK_e ), io (exitWith ExitSuccess)) | ||
857 | |||
858 | -- Restart xmonad | ||
859 | -- , ((modm .|. shiftMask .|. controlMask, xK_r ), void . xfork $ recompile False >>= flip when (safeSpawn "xmonad" ["--restart"])) | ||
860 | , ((modm .|. shiftMask, xK_r ), void . liftIO $ executeFile "xmonad" True [] Nothing) | ||
861 | , ((modm .|. shiftMask, xK_l ), void . xfork $ do | ||
862 | sessId <- getEnv "XDG_SESSION_ID" | ||
863 | safeSpawn "loginctl" ["lock-session", sessId] | ||
864 | ) | ||
865 | , ((modm .|. shiftMask, xK_s ), safeSpawn "systemctl" ["suspend"]) | ||
866 | , ((modm .|. shiftMask, xK_h ), safeSpawn "systemctl" ["hibernate"]) | ||
867 | , ((modm .|. shiftMask, xK_b ), backlight $ cycleThrough [1, 3 % 4, 1 % 2, 1 % 4, 1 % 10, 1 % 100, 0] | ||
868 | ) | ||
869 | , ((modm .|. shiftMask .|. controlMask, xK_b), backlight $ cycleThrough [0, 1 % 100, 1 % 10, 1 % 4, 1 % 2, 3 % 4, 1] | ||
870 | ) | ||
871 | , ((modm, xK_v ), windows copyToAll) -- @@ Make focused window always visible | ||
872 | , ((modm .|. shiftMask, xK_v ), killAllOtherCopies) -- @@ Toggle window state back | ||
873 | , ((modm .|. shiftMask, xK_g ), windowPrompt xPConfig Goto wsWindows) | ||
874 | , ((modm .|. shiftMask .|. controlMask, xK_g ), windowPrompt xPConfig Bring allWindows) | ||
875 | ] | ||
876 | ++ | ||
877 | |||
878 | -- | ||
879 | -- mod-[1..9], Switch to workspace N | ||
880 | -- | ||
881 | -- mod-[1..9], Switch to workspace N | ||
882 | -- mod-shift-[1..9], Move client to workspace N | ||
883 | -- | ||
884 | [((m .|. modm, k), windows $ f i) | ||
885 | | (i, k) <- zip (XMonad.workspaces conf) $ numKeys | ||
886 | , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)] | ||
887 | ] | ||
888 | ++ | ||
889 | [((m .|. modm .|. controlMask, k), void . runMaybeT $ | ||
890 | MaybeT (P.getScreen def i) >>= MaybeT . screenWorkspace >>= lift . windows . f | ||
891 | ) | ||
892 | | (i, k) <- zip (hScreens host) [xK_g, xK_c, xK_r, xK_l] | ||
893 | , (f, m) <- [(W.view, 0), (W.shift, shiftMask)] | ||
894 | ] | ||
895 | where | ||
896 | modm = XMonad.modMask conf | ||
897 | |||
898 | |||
diff --git a/accounts/gkleen@sif/xresources.nix b/accounts/gkleen@sif/xresources.nix new file mode 100644 index 00000000..3bd9af2c --- /dev/null +++ b/accounts/gkleen@sif/xresources.nix | |||
@@ -0,0 +1,46 @@ | |||
1 | { | ||
2 | "Xft.dpi" = 282; | ||
3 | "Xft.autohint" = false; | ||
4 | "Xft.lcdfilter" = "lcddefault"; | ||
5 | "Xft.hintstyle" = "hintfull"; | ||
6 | "Xft.hinting" = true; | ||
7 | "Xft.antialias" = true; | ||
8 | "Xft.rgba" = "rgb"; | ||
9 | |||
10 | # special | ||
11 | "*.foreground" = "#d9d9d9"; | ||
12 | "*.background" = "#000000"; | ||
13 | "*.cursorColor" = "#d9d9d9"; | ||
14 | |||
15 | # black | ||
16 | "*.color0" = "#000000"; | ||
17 | "*.color8" = "#757a80"; | ||
18 | |||
19 | # red | ||
20 | "*.color1" = "#bf4949"; | ||
21 | "*.color9" = "#e66e6e"; | ||
22 | |||
23 | # green | ||
24 | "*.color2" = "#9fb346"; | ||
25 | "*.color10" = "#cbd676"; | ||
26 | |||
27 | # yellow | ||
28 | "*.color3" = "#e69650"; | ||
29 | "*.color11" = "#ffa74f"; | ||
30 | |||
31 | # blue | ||
32 | "*.color4" = "#759fbf"; | ||
33 | "*.color12" = "#98b8d9"; | ||
34 | |||
35 | # magenta | ||
36 | "*.color5" = "#9b79a6"; | ||
37 | "*.color13" = "#ceadd9"; | ||
38 | |||
39 | # cyan | ||
40 | "*.color6" = "#79a69b"; | ||
41 | "*.color14" = "#a3d9ce"; | ||
42 | |||
43 | # white | ||
44 | "*.color7" = "#d9d9d9"; | ||
45 | "*.color15" = "#ffffff"; | ||
46 | } \ No newline at end of file | ||