aboutsummaryrefslogtreecommitdiffstats
path: root/oni/home/services/stumpwm/config
blob: d4cfc38c5ee9f2ebcee30149a4a7ebdf3065ed82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
;; -*- mode: lisp; -*-
(in-package :stumpwm-user)

(require 'swank)

(set-prefix-key (kbd "s-x"))

(defvar *screen-locking-hook* nil
  "Hook that gets called right before the screen gets locked.")

(defvar *screen-unlocked-hook* nil
  "Hook that gets called right after the screen is unlocked.")

(defun run-screen-unlocked-hook (process)
  "Run `*screen-unlocked-hook* if PROCESS' status is `:exited'."
  (when (eq (sb-ext:process-status process) :exited)
    (run-hook *screen-unlocked-hook*)))

(defun vpn-connected-p ()
  (probe-file "/sys/class/net/vpn"))

(defcommand lock-screen () ()
  "Lock the screen using i3lock.
Run `*screen-locking-hook*' before locking it and run `*screen-unlocked-hook*'
after it has been unlocked."
  (run-hook *screen-locking-hook*)
  (sb-ext:run-program
   *shell-program* '("-c" "i3lock --nofork --color=000000")
   :wait nil
   :status-hook #'run-screen-unlocked-hook))

(defcommand raise-browser () ()
  "Open or show my browser"
  (run-or-raise "firefox" '(:class "firefox")))

(defcommand raise-emacs () ()
  "Open or show Emacs"
  (run-or-raise "emacsclient -c" '(:class "Emacs")))

(defcommand raise-terminal () ()
  "Open or show my terminal"
  (run-or-raise "kitty" '(:class "kitty")))

(define-key *top-map* (kbd "C-M-l") "lock-screen")
(define-key *top-map* (kbd "s-b") "raise-browser")
(define-key *top-map* (kbd "s-e") "raise-emacs")
(define-key *top-map* (kbd "s-t") "raise-terminal")
(define-key *top-map* (kbd "s-!") "exec rofi -show drun")
(define-key *top-map* (kbd "s-w") "exec rofi -show window")

(define-remapped-keys
    `(("teams-for-linux"
       ;; Mute microphone in meetings.
       ("XF86Launch6" . "C-S-m"))
      ("[Ff]irefox"
       ;; Generally cancel action.
       ("XF86Launch6" . "ESC"))
      ("[Ee]macs"
       ;; Save document.
       ("XF86Launch5" . ("C-x" "C-s"))
       ;; Quit command.
       ("XF86Launch6" . "C-g")
       ;; Revert (reload) file.
       ("XF86Launch7" . ("C-x" "x" "g")))
      ;; Portal: Revolution
      ("revolution"
       ;; Quick Save
       ("XF86Launch5" . "F6")
       ;; Quick Load
       ("XF86Launch7" . "F7"))))

(set-bg-color "#222424")
(set-border-color "#3f4242")
(set-fg-color "#bfbfbf")
(set-float-focus-color "#5b6161")
(set-float-unfocus-color "#3f4242")
(set-focus-color "#ff9800")
(set-unfocus-color "#3f4242")

(setf *mode-line-background-color* "#5b6161"
      *mode-line-foreground-color* "#bfbfbf")
(setf *screen-mode-line-format*
      (list " [^B%n^b] "
            "^[^(:bg \"#f17272\")^(:fg \"#222424\") "
            '(:eval
              (or (ignore-errors (window-title (current-window)))
               "Unknown"))
            " ^]^>"
            '(:eval
              (if (vpn-connected-p)
                  "^*5^B[VPN]^b^n "
                  ""))
            "%d "))
(mode-line)

;;; Screenshots

(defvar *screenshot-bindings*
  (let ((m (make-sparse-keymap)))
    (define-key m (kbd "s") "exec flameshot gui")
    (define-key m (kbd "c") "exec flameshot screen")
    (define-key m (kbd "f") "exec flameshot full")
    m))

(defvar *notification-bindings*
  (let ((m (make-sparse-keymap)))
    (define-key m (kbd "RET") "exec dunstctl action")
    (define-key m (kbd "c") "exec dunstctl close")
    (define-key m (kbd "S-c") "exec dunstctl close-all")
    (define-key m (kbd "SPC") "exec dunstctl context")
    (define-key m (kbd ",") "exec dunstctl history-pop")
    (define-key m (kbd "p") "exec dunstctl set-paused toggle")
    m))

(defvar *user-bindings*
  (let ((m (make-sparse-keymap)))
    (define-key m (kbd "s") '*screenshot-bindings*)
    (define-key m (kbd "n") '*notification-bindings*)
    m))

(define-key *top-map* (kbd "s-c") '*user-bindings*)

(restore-from-file "default")

(define-frame-preference "Default"
  (0 t nil :class "kitty")
  (1 t nil :class "Emacs")
  (3 t nil :class "firefox"))

(define-frame-preference "teams"
  (0 t t :class "teams-for-linux" :create t))

(swank:create-server :dont-close t)

(which-key-mode)