aboutsummaryrefslogtreecommitdiffstats
path: root/oni/home/services/stumpwm/pop-os-config.lisp
blob: 86b99436fe4de862887adbf80b2956e409738b96 (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
(in-package :stumpwm-user)

(defvar *distraction-hook* nil
  "Hook where application scan register functions to call when I'm distracted.")

(defcommand distraction! () ()
  (run-hook *distraction-hook*))

(define-key *top-map* (kbd "s-d") "distraction!")

(defun clock-out ()
  (sb-ext:run-program
   *shell-program* '("-c" "emacsclient --no-wait --eval \"(org-clock-out)\"")))

(add-hook *screen-locking-hook* 'clock-out)
(add-hook *distraction-hook* 'clock-out)

(defun pause-music ()
  (sb-ext:run-program
   *shell-program* '("-c" "[ \"$(playerctl status)\" = \"Playing\" ]] && playerctl pause")))

(add-hook *screen-locking-hook* 'pause-music)
(add-hook *distraction-hook* 'pause-music)

(defun pause-notifications ()
  (sb-ext:run-program
   *shell-program* '("-c" "dunstctl set-paused true")))

(defun resume-notifications ()
  (sb-ext:run-program
   *shell-program* '("-c" "dunstctl set-paused false")))

(add-hook *screen-locking-hook* 'pause-notifications)
(add-hook *screen-unlocked-hook* 'resume-notifications)

(defvar *applications* nil)

(defun pop-os-load-applications ()
  (mapcar (lambda (s) (split-string s "	"))
          (split-string (with-output-to-string (mystr)
                          (sb-ext:run-program "/home/tomwillemsen/code/diamond-interactive/chanced-scripts/list-desktop-files" '() :output mystr)))))

(define-stumpwm-type :application (input prompt)
  (or (argument-pop input)
      (let ((applications (setf *applications* (or *applications* (pop-os-load-applications)))))
        (cadr (assoc (completing-read (current-screen) prompt (mapcar #'car applications) :require-match t)
                     applications :test 'string=)))))

(defcommand reload-applications () ()
  (pop-os-load-applications)
  (message "OK!"))

(defcommand run-application (application)
    ((:application "Application: "))
  (sb-ext:run-program "/usr/bin/gtk-launch" (list application) :wait nil))

(define-key *user-bindings* (kbd "a") "run-application")

(defvar *xrandr-program* "/usr/bin/xrandr")

(defcommand laptop-screen () ()
  (sb-ext:run-program *xrandr-program* '("--output" "eDP-1" "--primary" "--auto" "--output" "HDMI-1" "--off" "--output" "DP-1" "--off"))
  (if (> (length (screen-heads (current-screen))) 1)
      (refresh-heads)))


(defcommand samsung-screen () ()
  (sb-ext:run-program *xrandr-program* '("--output" "eDP-1" "--off" "--output" "DP-1" "--auto" "--primary"))
  (when (and (= 1 (length (screen-heads (current-screen))))
             (/= (screen-width (current-screen))
                 (frame-width (car (screen-heads (current-screen))))))
    (refresh-heads)))

(defcommand laptop+mnn-screen () ()
  (sb-ext:run-program *xrandr-program* '("--output" "eDP-1" "--auto" "--output" "HDMI-1" "--auto" "--primary" "--right-of" "eDP-1")))