summaryrefslogtreecommitdiffhomepage
path: root/init.el
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-09-07 05:49:01 +0100
committerjao <jao@gnu.org>2022-09-07 05:49:01 +0100
commit8c6838311257cd90217801953ad8e4846384ef5e (patch)
treedc562bec05b22fdcc55d6ac9d60467b52232704f /init.el
parent0986db35bb51d5b3426a0aad9467bd3b1765358d (diff)
downloadelibs-8c6838311257cd90217801953ad8e4846384ef5e.tar.gz
elibs-8c6838311257cd90217801953ad8e4846384ef5e.tar.bz2
jao-wayland factored out
Diffstat (limited to 'init.el')
-rw-r--r--init.el132
1 files changed, 7 insertions, 125 deletions
diff --git a/init.el b/init.el
index de13c05..6c295f0 100644
--- a/init.el
+++ b/init.el
@@ -454,84 +454,16 @@
(add-hook 'after-init-hook #'jao-xmonad-enable t))
;;;; wayland
-(defvar jao-wayland-enabled
- (string= "wayland" (or (getenv "XDG_SESSION_TYPE") "")))
+
+(use-package jao-wayland :demand t)
(defun jao-wayland-enable ()
- (interactive)
- (defalias 'x-change-window-property #'ignore)
- (when (eq 'pgtk window-system) (jao-set-transparency 85))
- (jao-themes-setup)
- (jao-trisect)
- (message "Welcome to wayland"))
-
-(defsubst jao-wayland-type (&rest args)
- (apply #'jao-shell-exec* t "wtype" args))
-
-;;;; river
-(defvar jao-river-enabled (jao-shell-running-p "river"))
-(defun jao-river-enabled-p () jao-river-enabled)
-
-(defsubst jao-river-to-ws (n)
- (jao-wayland-type "-M" "win" (format "%s" n)))
-
-(defsubst jao-river-window-list ()
- (jao-shell-output "lswt -j" (lambda () (let ((json-false nil)) (json-read)))))
-
-(defun jao-river-focused ()
- (seq-some (lambda (w) (and (alist-get 'activated w) w))
- (jao-river-window-list)))
-
-(defsubst jao-river-get-focused-title ()
- (alist-get 'title (jao-river-focused)))
-
-(defun jao-river-focus-window (title &optional rx)
- (let* ((ws (jao-river-window-list))
- (fltr (if rx #'string-match-p #'string=) )
- (w (seq-find (lambda (w) (funcall fltr title (alist-get 'title w "")))
- ws)))
- (or (alist-get 'activated w)
- (seq-some (lambda (_ignored)
- (jao-shell-exec "riverctl focus-view next" t)
- (funcall fltr title (jao-river-get-focused-title)))
- (and w ws)))))
-
-(defun jao-river-zathura-to-org ()
- (let ((title (jao-river-get-focused-title)))
- (jao-river-to-ws 1)
- (jao-pdf-goto-zathura-org title t)))
-
-(defun jao-river-zathura-kill-link ()
- (when-let* ((title (jao-river-get-focused-title))
- (lnk (jao-pdf-zathura-org-link title)))
- (jao-river-to-ws 1)
- (kill-new lnk)
- (message "Link to %s killed" title)))
-
-(defun jao-river-find-zathura-window (file)
- (let ((frx (regexp-quote (file-name-nondirectory file))))
- (seq-some (lambda (w)
- (and (string-suffix-p ".zathura" (alist-get 'app_id w ""))
- (string-match-p frx (alist-get 'title w ""))
- w))
- (jao-river-window-list))))
-
-(defun jao-river-open-with-zathura (file page)
- (let ((wd (jao-river-find-zathura-window file)))
- (jao-river-to-ws 3)
- (or (and wd (jao-river-focus-window (alist-get 'title wd)))
- (jao-shell-exec* "riverctl" "spawn" (jao-pdf-zathura-open-cmd file page)))
- (when page (sit-for 0.2) (jao-wayland-type (format "%dg" page)))))
-
-(defun jao-river-set-wallpaper (f)
- (jao-shell-exec (concat "swaybg -m fill -i " f " &")))
-
-(defun jao-river-restart-i3bar ()
(interactive)
- (jao-shell-kill-p "i3bar-river")
- (jao-shell-exec "riverctl spawn i3bar-river")
- (sit-for 0.2)
- (jao-tracking-set-log ""))
+ (defalias 'x-change-window-property #'ignore)
+ (when (eq 'pgtk window-system) (jao-set-transparency 85))
+ (jao-themes-setup)
+ (jao-trisect)
+ (message "Welcome to wayland"))
(defun jao-river-enable ()
(jao-wayland-enable)
@@ -539,59 +471,9 @@
(jao-tracking-set-log ""))
(message "Welcome to river"))
-(defun jao-river-toggle-emacs ()
- (if (member (jao-river-get-focused-title) '("emacsclient" "emacs"))
- (jao-shell-exec "riverctl focus-previous-tags")
- (jao-river-to-ws 1)
- (unless (jao-river-focus-window "^emacs\\(client\\)?" t)
- (jao-shell-exec* "riverctl" "spawn" "efoot"))))
-
(when jao-river-enabled
(add-hook 'after-init-hook #'jao-river-enable))
-;;;; sway
-(defun jao-sway-msg (msg)
- (shell-command (format "swaymsg '%s' >/dev/null" msg)))
-
-(defmacro jao-def-swaymsg (name msg)
- `(defun ,(intern (format "jao-sway-%s" name)) ()
- (interactive)
- (jao-sway-msg ,msg)))
-
-(jao-def-swaymsg firefox "[app_id=Firefox] focus")
-
-(defvar jao-sway-enabled (jao-shell-running-p "sway"))
-
-(defconst jao-sway-get-active-title
- "swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true).name'")
-
-(defun jao-sway-get-active-title ()
- (let ((tl (jao-shell-string jao-sway-get-active-title)))
- (and (string-match "\"\\(.+\\)\"" tl) (match-string 1 tl))))
-
-(defun jao-sway-zathura-org ()
- (jao-pdf-goto-zathura-org (jao-sway-get-active-title) t))
-
-(defun jao-sway-open-with-zathura (file page)
- (let ((n (file-name-nondirectory file)))
- (jao-sway-msg "workspace number 3")
- (unless (= 0 (jao-sway-msg (format "[title=\"%s\"] focus" n)))
- (jao-shell-exec (jao-pdf-zathura-open-cmd file page)))
- (when page (sit-for 0.2) (jao-wayland-type (format "%dg" page)))))
-
-(defun jao-sway-set-wallpaper (f)
- (jao-sway-msg (format "output * bg %s fill" f)))
-
-(defun jao-sway-run-or-focus (cmd &optional ws)
- (if (jao-shell-running-p "firefox")
- (jao-sway-msg (format "[app_id=%s] focus" cmd))
- (jao-sway-msg (format "workspace %s" (or ws 2)))
- (start-process-shell-command cmd nil cmd)))
-
-(defun jao-sway-run-or-focus-firefox ()
- (interactive)
- (jao-sway-run-or-focus "firefox"))
-
(when jao-sway-enabled
(add-hook 'after-init-hook #'jao-wayland-enable))