summaryrefslogtreecommitdiff
path: root/.stumpwm.d/commands.lisp
blob: dc9204d1ff725c8bcf97b24eebfc30bd76a2c083 (about) (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
;; Functions

(defun feh-set-wallpaper (wallpaper-name)
  "Set wallpaper using feh"
  (let ((wallpaper-dir "~/wallpapers/"))
    (format t "Setting wallpaper: ~a~%" wallpaper-name)
    (run-shell-command (format nil "feh --bg-scale ~a~a" wallpaper-dir wallpaper-name))))


(defun thanos/set-wallpapers ()
  "Set wallpapers depending on hostname."
  (cond ((equal (asdf:hostname) "zeus") (feh-set-wallpaper "anime-night-mountains.jpg"))
	((equal (asdf:hostname) "hermes") (feh-set-wallpaper "library-old-house.jpg"))))


(defmacro defnyxt-search (name search-url command)
  `(stumpwm:defcommand ,(intern (concatenate 'string "nyxt-" name)) (query)
       ((:string "Search: "))
     (stumpwm:run-shell-command
      (concatenate 'string "nyxt -r -e '(" ,command "\"" ,search-url query "\"" ")'"))))

(defvar thanos-searxng "https://search.thanosapollo.com/?q=")

(defnyxt-search "searxng" thanos-searxng "buffer-load")
(defnyxt-search "searxng-newb" thanos-searxng "set-url-new-buffer :url")
(defnyxt-search "http" "http://" "buffer-load")

;; Sly setup
(ql:quickload :slynk)

(defcommand sly-start-server () ()
  "Start a slynk server for sly."
  (sb-thread:make-thread (lambda () (slynk:create-server :dont-close t))))

(defcommand sly-stop-server () ()
  "Stop current slynk server for sly."
  (sb-thread:make-thread (lambda () (slynk:stop-server 4005))))


(defcommand firefox () ()
  "Run or raise Firefox."
  (sb-thread:make-thread (lambda () (run-or-raise "firefox" '(:class "firefox") t nil))))

(defcommand delete-window-and-frame () ()
  "Delete the current frame with its window."
  (delete-window)
  (remove-split))

(defcommand hsplit-and-focus () ()
  "Create a new frame on the right and focus it."
  (hsplit)
  (move-focus :right))

(defcommand vsplit-and-focus () ()
  "Create a new frame below and move focus to it."
  (vsplit)
  (move-focus :down))

(defcommand term (&optional program) ()
  "Invoke a terminal, possibly with a @arg{program}."
  (sb-thread:make-thread
   (lambda ()
     (run-shell-command (if program
			    (format nil "kitty ~A" program)
			    "kitty")))))

(when *initializing*
  (mapc #'run-shell-command
   '("picom"
     "transmission-daemon"
     "xsetroot -cursor_name left_ptr"))
  (thanos/set-wallpapers))