diff options
Diffstat (limited to '.stumpwm.d')
| -rw-r--r-- | .stumpwm.d/.gitignore | 1 | ||||
| -rwxr-xr-x | .stumpwm.d/init.lisp | 360 | 
2 files changed, 0 insertions, 361 deletions
| diff --git a/.stumpwm.d/.gitignore b/.stumpwm.d/.gitignore deleted file mode 100644 index 4c478cf..0000000 --- a/.stumpwm.d/.gitignore +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | stumpwm.log* \ No newline at end of file | ||
| diff --git a/.stumpwm.d/init.lisp b/.stumpwm.d/init.lisp deleted file mode 100755 index 0970718..0000000 --- a/.stumpwm.d/init.lisp +++ /dev/null | |||
| @@ -1,360 +0,0 @@ | |||
| 1 | (in-package :stumpwm) | ||
| 2 | |||
| 3 | |||
| 4 | (setq *message-window-gravity* :center) | ||
| 5 | (setq *message-window-input-gravity* :center) | ||
| 6 | (setq *input-window-gravity* :center) | ||
| 7 | (setq *window-border-style* :none) | ||
| 8 | |||
| 9 | (set-bg-color :gray10) | ||
| 10 | (setq *mode-line-background-color* "Gray10") | ||
| 11 | |||
| 12 | (set-prefix-key (kbd "C-z")) | ||
| 13 | (setq *float-window-modifier* :super) | ||
| 14 | |||
| 15 | (define-key *top-map* (kbd "s-w") "gselect") | ||
| 16 | |||
| 17 | (defcommand lock () () | ||
| 18 | (run-shell-command "slock")) | ||
| 19 | |||
| 20 | (define-key *top-map* (kbd "s-l") "lock") | ||
| 21 | |||
| 22 | (defcommand server-start () () | ||
| 23 | (slynk:create-server :port 4005) | ||
| 24 | (message "server started at port: \"4005\"!")) | ||
| 25 | |||
| 26 | |||
| 27 | (define-key *root-map* (kbd "C-q") "send-raw-key") | ||
| 28 | |||
| 29 | (define-key *root-map* (kbd "M") "mode-line") | ||
| 30 | (define-key *root-map* (kbd "C-n") "fnext") | ||
| 31 | (define-key *root-map* (kbd "C-p") "fprev") | ||
| 32 | (define-key *root-map* (kbd "b") "windowlist") | ||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | ;; (run-commands "gnew Code" | ||
| 37 | ;; "gnew Web" | ||
| 38 | ;; "gnew Music" | ||
| 39 | ;; "gnew Game" | ||
| 40 | ;; "gnew School") | ||
| 41 | |||
| 42 | (define-remapped-keys | ||
| 43 | '(("(Firefox|Chrome|qutebrowser)" | ||
| 44 | ("C-n" . "Down") | ||
| 45 | ("C-p" . "Up") | ||
| 46 | ("C-f" . "Right") | ||
| 47 | ("C-b" . "Left") | ||
| 48 | ("C-v" . "Next") | ||
| 49 | ("M-v" . "Prior") | ||
| 50 | ("M-w" . "C-c") | ||
| 51 | ("C-w" . "C-x") | ||
| 52 | ("C-y" . "C-v") | ||
| 53 | ("M-<" . "Home") | ||
| 54 | ("M->" . "End") | ||
| 55 | ("C-a" . "Home") | ||
| 56 | ("C-e" . "End") | ||
| 57 | ("C-M-b" . "M-Left") | ||
| 58 | ("C-M-f" . "M-Right") | ||
| 59 | ("C-g" . "ESC") | ||
| 60 | ("C-k" . ("C-S-End" "C-x"))))) | ||
| 61 | |||
| 62 | (define-frame-preference "chat" | ||
| 63 | (0 NIL T :create T :class "quassel") | ||
| 64 | (1 NIL T :create T :class "discord") | ||
| 65 | (2 NIL T :create T :class "nheko")) | ||
| 66 | |||
| 67 | (define-frame-preference "vm" | ||
| 68 | (0 NIL T :create T :class ".virt-manager-real")) | ||
| 69 | |||
| 70 | (run-shell-command "~/.fehbg") | ||
| 71 | |||
| 72 | (require :pamixer) | ||
| 73 | (require :pass) | ||
| 74 | |||
| 75 | (require :screenshot) | ||
| 76 | (pamixer:volume-down 10) | ||
| 77 | |||
| 78 | (defun get-brightness () | ||
| 79 | (let ((c (parse-integer (string-trim | ||
| 80 | (string #\newline) | ||
| 81 | (run-shell-command "brightnessctl g" t)))) | ||
| 82 | (m (parse-integer (string-trim | ||
| 83 | (string #\newline) | ||
| 84 | (run-shell-command "brightnessctl m" t))))) | ||
| 85 | (format nil "~3,1f%" (* (/ c m) 100)))) | ||
| 86 | |||
| 87 | (defun set-brightness (x) | ||
| 88 | (run-shell-command (concat "brightnessctl s " x)) | ||
| 89 | (message (concat "Brightness: " (get-brightness)))) | ||
| 90 | |||
| 91 | (defcommand my-volume-down () () | ||
| 92 | (pamixer:volume-down 5) | ||
| 93 | (message (format nil "Volume: ~s%" (pamixer:get-volume)))) | ||
| 94 | |||
| 95 | (defcommand my-volume-up () () | ||
| 96 | (pamixer:volume-up 5) | ||
| 97 | (message (format nil "Volume: ~s%" (pamixer:get-volume)))) | ||
| 98 | |||
| 99 | (defcommand my-toggle-mute () () | ||
| 100 | (pamixer:toggle-mute) | ||
| 101 | (if (pamixer:get-mute) | ||
| 102 | (message "Mute: ^2ON") | ||
| 103 | (message "Mute: ^1OFF"))) | ||
| 104 | |||
| 105 | (defcommand my-brightness-up () () | ||
| 106 | (set-brightness "+5%")) | ||
| 107 | |||
| 108 | (defcommand my-brightness-down () () | ||
| 109 | (set-brightness "5%-")) | ||
| 110 | |||
| 111 | (defcommand my-brightness-one () () | ||
| 112 | (set-brightness "1")) | ||
| 113 | |||
| 114 | |||
| 115 | (define-key *top-map* (kbd "XF86AudioMute") "my-toggle-mute") | ||
| 116 | (define-key *top-map* (kbd "XF86AudioRaiseVolume") "my-volume-up") | ||
| 117 | (define-key *top-map* (kbd "XF86AudioLowerVolume") "my-volume-down") | ||
| 118 | |||
| 119 | (define-key *top-map* (kbd "XF86MonBrightnessUp") "my-brightness-up") | ||
| 120 | (define-key *top-map* (kbd "XF86MonBrightnessDown") "my-brightness-down") | ||
| 121 | |||
| 122 | (defun my-screenshoot-command-wrapper (screenshot-command ss-name) | ||
| 123 | (apply screenshot-command (list (concat | ||
| 124 | "~/Pictures/Screenshots/" | ||
| 125 | (string-trim | ||
| 126 | (string #\newline) | ||
| 127 | (run-shell-command "date +%Y-%M-%d-%T" t)) | ||
| 128 | "-" (or ss-name "untitled") | ||
| 129 | ".png")))) | ||
| 130 | |||
| 131 | |||
| 132 | (defcommand my-screenshot-area (ss-name) | ||
| 133 | ((:string "Screenshot name: ")) | ||
| 134 | (my-screenshoot-command-wrapper #'screenshot:screenshot-area ss-name)) | ||
| 135 | |||
| 136 | (defcommand my-screenshot-window (ss-name) | ||
| 137 | ((:string "Screenshot name: ")) | ||
| 138 | (my-screenshoot-command-wrapper #'screenshot:screenshot-window ss-name)) | ||
| 139 | |||
| 140 | (defcommand my-screenshot (ss-name) | ||
| 141 | ((:string "Screenshot name: ")) | ||
| 142 | (my-screenshoot-command-wrapper #'screenshot:screenshot ss-name)) | ||
| 143 | |||
| 144 | (defvar *misc-keymap* | ||
| 145 | (let ((m (make-sparse-keymap))) | ||
| 146 | (define-key m (kbd "0") "my-toggle-mute") | ||
| 147 | (define-key m (kbd "+") "my-volume-up") | ||
| 148 | (define-key m (kbd "=") "my-volume-up") | ||
| 149 | (define-key m (kbd "-") "my-volume-down") | ||
| 150 | |||
| 151 | (define-key m (kbd "p") "pass-copy-menu") | ||
| 152 | (define-key m (kbd "C-p") "pass-copy-menu") | ||
| 153 | (define-key m (kbd "g") "pass-generate") | ||
| 154 | (define-key m (kbd "C-g") "pass-generate") | ||
| 155 | |||
| 156 | (define-key m (kbd "C-a") "my-screenshot-area") | ||
| 157 | (define-key m (kbd "a") "my-screenshot-area") | ||
| 158 | (define-key m (kbd "C-w") "my-screenshot-window") | ||
| 159 | (define-key m (kbd "w") "my-screenshot-window") | ||
| 160 | (define-key m (kbd "C-s") "my-screenshot") | ||
| 161 | (define-key m (kbd "s") "my-screenshot") | ||
| 162 | |||
| 163 | m)) | ||
| 164 | |||
| 165 | |||
| 166 | |||
| 167 | |||
| 168 | (define-key *root-map* (kbd "C-m") '*misc-keymap*) | ||
| 169 | |||
| 170 | ;; | ||
| 171 | ;; ;;; MODE-LINE | ||
| 172 | (require :cpu) | ||
| 173 | (require :mem) | ||
| 174 | (require :net) | ||
| 175 | |||
| 176 | (require :stumptray) | ||
| 177 | (stumptray:add-mode-line-hooks) | ||
| 178 | |||
| 179 | (defun update-stumptray-position (&rest args) | ||
| 180 | (setf (symbol-value (find-symbol "*TRAY-HEAD-SELECTION-FN*" :stumptray)) | ||
| 181 | (if (>= (list-length (stumpwm:screen-heads (stumpwm:current-screen))) 2) | ||
| 182 | #'second | ||
| 183 | #'first))) | ||
| 184 | |||
| 185 | (stumpwm:add-hook stumpwm:*new-head-hook* 'update-stumptray-position) | ||
| 186 | (update-stumptray-position) | ||
| 187 | |||
| 188 | (defun get-battery-status () | ||
| 189 | (let* ((state (string-trim | ||
| 190 | (string #\newline) | ||
| 191 | (run-shell-command | ||
| 192 | (concat "upower -i /org/freedesktop/UPower/devices/battery_BAT0 " | ||
| 193 | "| grep state: " | ||
| 194 | "| awk '{print $2}'") | ||
| 195 | t))) | ||
| 196 | (perc (string-trim | ||
| 197 | (string #\newline) | ||
| 198 | (run-shell-command (concat | ||
| 199 | "upower -i /org/freedesktop/UPower/devices/battery_BAT0 " | ||
| 200 | "| grep perc " | ||
| 201 | "| awk '{print $2}'") | ||
| 202 | t))) | ||
| 203 | (perc-num (parse-integer (aref (nth-value 1 (cl-ppcre:scan-to-strings "^(.*)\%$" perc)) 0)))) | ||
| 204 | (format | ||
| 205 | nil | ||
| 206 | (concat | ||
| 207 | "BAT: " | ||
| 208 | (cond | ||
| 209 | ((and (equal state "discharging") | ||
| 210 | (<= perc-num 20)) | ||
| 211 | "^1[-~a]^]") | ||
| 212 | ((equal state "discharging") "[-~a]") | ||
| 213 | ((equal state "charging") "[+~a]") | ||
| 214 | ((equal state "fully-charged") "[~a]") | ||
| 215 | (t (concat state " [~a]")))) | ||
| 216 | perc))) | ||
| 217 | |||
| 218 | |||
| 219 | |||
| 220 | (setq *screen-mode-line-format* (list "[^B%n^b] %W ^> %C | %M | %l | " | ||
| 221 | '(:eval (get-battery-status)) | ||
| 222 | " " ;; empty space for stumptray icons | ||
| 223 | )) | ||
| 224 | |||
| 225 | (require :yason) ;; json parser | ||
| 226 | (require :drakma) ;; http client | ||
| 227 | |||
| 228 | |||
| 229 | (defcommand kto-hakuje-p () () | ||
| 230 | (let* ((response (yason:parse | ||
| 231 | (flexi-streams:octets-to-string | ||
| 232 | (drakma:http-request "https://whois.at.hsp.sh/api/now")))) | ||
| 233 | (users (gethash "users" response)) | ||
| 234 | (unknown-devices (gethash "unknown_devices" response))) | ||
| 235 | (message (cond | ||
| 236 | ((and (= (list-length users) 0) | ||
| 237 | (= unknown-devices 0)) | ||
| 238 | "Spejs jest pusty!") | ||
| 239 | ((and (= (list-length users) 0) | ||
| 240 | (> unknown-devices 0)) | ||
| 241 | (format nil "W spejsie jest nieznanych ~a urzadzen." unknown-devices)) | ||
| 242 | ((and (> (list-length users) 0) | ||
| 243 | (= unknown-devices 0)) | ||
| 244 | (format nil "W spejsie jest ~a." users)) | ||
| 245 | ((and (> (list-length users) 0) | ||
| 246 | (> unknown-devices 0)) | ||
| 247 | (format nil "W spejsie jest ~a oraz ~a nieznane urzadzenia." users unknown-devices)))))) | ||
| 248 | |||
| 249 | |||
| 250 | (define-key *misc-keymap* (kbd "h") "kto-hakuje-p") | ||
| 251 | (define-key *misc-keymap* (kbd "C-h") "kto-hakuje-p") | ||
| 252 | |||
| 253 | |||
| 254 | (defun emacs-server-p () | ||
| 255 | (let ((status-code (caddr | ||
| 256 | (multiple-value-list | ||
| 257 | (uiop:run-program "ls /run/user/$(id -u)/emacs/server" | ||
| 258 | :ignore-error-status T))))) | ||
| 259 | (= status-code 0))) | ||
| 260 | |||
| 261 | (stumpwm:defcommand emacs-start-server (&optional (show-message T) (wait-for-start NIL)) () | ||
| 262 | (let ((mess (if (not (emacs-server-p)) | ||
| 263 | (progn (stumpwm:run-shell-command "emacs --daemon" wait-for-start) | ||
| 264 | "Emacs server is starting....") | ||
| 265 | "Emacs server is running already!"))) | ||
| 266 | (when show-message (message mess)))) | ||
| 267 | |||
| 268 | (stumpwm:defcommand emacs-stop-server (&optional (show-message T)) () | ||
| 269 | (let ((mess (if (emacs-server-p) | ||
| 270 | (progn (stumpwm:run-shell-command "emacsclient -e \"(server-force-delete)\"") | ||
| 271 | "Emacs server gone away :(....") | ||
| 272 | "Emacs server wasn't alive!"))) | ||
| 273 | (when show-message (message mess)))) | ||
| 274 | |||
| 275 | |||
| 276 | (stumpwm:defcommand emacs-restart-server (&optional (show-message T)) () | ||
| 277 | (emacs-stop-server NIL) | ||
| 278 | (emacs-start-server show-message)) | ||
| 279 | |||
| 280 | (defun postwalk (fun tree) | ||
| 281 | (if (consp tree) | ||
| 282 | (loop :for a :in tree | ||
| 283 | :if (consp a) | ||
| 284 | :collect (postwalk fun a) | ||
| 285 | :else | ||
| 286 | :collect (funcall fun a)) | ||
| 287 | (funcall fun tree))) | ||
| 288 | |||
| 289 | (defmacro eval-emacs-sexp (sexp | ||
| 290 | &key (create-new-frame NIL)) | ||
| 291 | `(stumpwm:run-shell-command | ||
| 292 | (format nil "emacsclient~{ ~A~} '~A'" | ||
| 293 | (list ,(if create-new-frame "-c" "") | ||
| 294 | "-e") | ||
| 295 | (postwalk (lambda (x) | ||
| 296 | (cond | ||
| 297 | ((stringp x) (concat "\"" x "\"")) | ||
| 298 | ((symbolp x) (string-downcase (string x))) | ||
| 299 | (T x))) | ||
| 300 | ,sexp)) | ||
| 301 | ,(not create-new-frame))) | ||
| 302 | |||
| 303 | |||
| 304 | (defmacro defcommand-from-emacs (name | ||
| 305 | (&rest args) | ||
| 306 | (&rest interactive-args) | ||
| 307 | (&key (create-new-frame T) (output-wrapper NIL)) | ||
| 308 | &body body) | ||
| 309 | `(stumpwm:defcommand ,name ,args ,interactive-args | ||
| 310 | (when (not (emacs-server-p)) | ||
| 311 | (emacs-start-server NIL T)) | ||
| 312 | |||
| 313 | ,(let ((x `(eval-emacs-sexp (progn ,@body) | ||
| 314 | :create-new-frame ,create-new-frame))) | ||
| 315 | (cond | ||
| 316 | ((and create-new-frame output-wrapper) | ||
| 317 | (error "Cannot wrap the output, becaouse create-new-frame is T.")) | ||
| 318 | (output-wrapper `(funcall ,output-wrapper ,x)) | ||
| 319 | (T `(funcall (lambda (x) (progn x nil)) ,x)))))) | ||
| 320 | |||
| 321 | |||
| 322 | (defcommand-from-emacs emacs-client () () () | ||
| 323 | nil) | ||
| 324 | |||
| 325 | (defcommand-from-emacs emacs-calc () () () | ||
| 326 | '(full-calc)) | ||
| 327 | |||
| 328 | (defcommand-from-emacs emacs-org-agenda () () () | ||
| 329 | '(org-agenda-list)) | ||
| 330 | |||
| 331 | (defcommand-from-emacs emacs-mu4e () () () | ||
| 332 | '(mu4e)) | ||
| 333 | |||
| 334 | (defcommand-from-emacs emacs-shell () () () | ||
| 335 | '(shell)) | ||
| 336 | |||
| 337 | (defcommand-from-emacs emacs-eshell () () () | ||
| 338 | '(eshell)) | ||
| 339 | |||
| 340 | (defvar *emacs-keymap* | ||
| 341 | (let ((e (make-sparse-keymap))) | ||
| 342 | (define-key e (kbd "a") "emacs-org-agenda") | ||
| 343 | (define-key e (kbd "C-a") "emacs-org-agenda") | ||
| 344 | (define-key e (kbd "c") "emacs-calc") | ||
| 345 | (define-key e (kbd "C-c") "emacs-calc") | ||
| 346 | (define-key e (kbd "m") "emacs-mu4e") | ||
| 347 | (define-key e (kbd "C-m") "emacs-mu4e") | ||
| 348 | |||
| 349 | e)) | ||
| 350 | |||
| 351 | |||
| 352 | |||
| 353 | |||
| 354 | (define-key *root-map* (kbd "C-e") '*emacs-keymap*) | ||
| 355 | (define-key *root-map* (kbd "e") "emacs-client") | ||
| 356 | (define-key *root-map* (kbd "c") "emacs-shell") | ||
| 357 | (define-key *root-map* (kbd "C") "emacs-eshell") | ||
| 358 | |||
| 359 | |||
| 360 | (emacs-start-server nil) | ||
