diff options
-rw-r--r-- | init.el | 78 |
1 files changed, 51 insertions, 27 deletions
@@ -251,6 +251,9 @@ (pdf-view-mode "application/pdf" (display-graphic-p)) ("zathura \"%s\"" "application/pdf") (image-mode "image/*" (display-graphic-p)) + ("firefox \"%s\" && swaymsg [app_id=Firefox] focus" "text/html" + (and jao-sway-enabled (not (display-graphic-p)))) + ("swayimg \"%s\"" "image/*" jao-sway-enabled) ("feh \"%s\"" "image/*"))))) ;;; Crypto ;;;; PGP, EPG, passwords @@ -455,8 +458,26 @@ (jao-swaymsg ,msg))) (jao-def-swaymsg firefox "[app_id=firefox] focus") -(defvar jao-sway-enabled - (and (eq window-system 'pgtk) (not jao-xmonad-enabled))) +(defvar jao-sway-enabled (and (featurep 'pgtk) (not jao-xmonad-enabled))) + +(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-send (txt) (jao-shell-string "wtype" txt)) + +(defun jao-zathura--open-cmd (file page &optional suffix) + (format "zathura %s -P %s%s" file (or page 1) (or suffix ""))) + +(defun jao-sway-open-with-zathura (file page) + (let* ((a (jao-zathura--open-cmd file page "")) + (n (file-name-nondirectory file)) + (c (format "swaymsg [title=\"%s\"] focus || %s" n a))) + (jao-shell-exec c) + (when page (jao-sway-send (format "%dg" page))))) (defun jao-sway-set-wallpaper (f) (jao-swaymsg (format "output * bg %s fill" f)) @@ -472,7 +493,9 @@ (interactive) (if (jao-shell-running-p "tidal-hifi") (jao-swaymsg "[app_id=tidal-hifi] scratchpad show") - (start-process-shell-command "tidal-hifi" nil "tidal-hifi &") + (let ((c + "tidal-hifi --enable-features=UseOzonePlatform --ozone-platform=wayland &")) + (start-process-shell-command "tidal-hifi" nil c)) (jao-sway-run-or-focus-tidal))) (defun jao-sway-run-or-focus-firefox () @@ -480,18 +503,15 @@ (jao-sway-run-or-focus "firefox")) (defun jao-sway-enable () - (setq jao-browse-doc-use-emacs-p t) - (setq jao-wallpaper-random-wake nil) - (jao-trisect) + (interactive) + (defalias 'x-change-window-property #'ignore) + (setq jao-sway-enabled t) (jao-set-transparency 85) (jao-themes-setup) - (xmobar-mode) - (global-set-key (kbd "s-f") #'jao-sway-run-or-focus-firefox) - (defalias 'jao-streaming-list #'jao-sway-run-or-focus-tidal) + (jao-trisect) (message "Welcome to sway")) (when jao-sway-enabled - (defalias 'x-change-window-property #'ignore) (add-hook 'after-init-hook #'jao-sway-enable)) ;;;; wallpaper @@ -1771,10 +1791,13 @@ (string-to-number (match-string 4 title)) (match-string 2 title)))) -(defun jao-zathura-goto-org (&optional title) - (when-let* ((title (or title (jao-shell-string "xdotool" - "getactivewindow" - "getwindowname"))) +(defun jao-zathura-goto-org (&optional title no-ask) + (when-let* ((title (or title + (and jao-sway-enabled + (jao-sway-get-active-title)) + (jao-shell-string "xdotool" + "getactivewindow" + "getwindowname"))) (info (jao-zathura-file-info title)) (file (jao-org-pdf-to-org-file (car info))) (page (cadr info)) @@ -1785,7 +1808,7 @@ (lnk (format "[[doc:%s::%d][Page %s]]" fn page pageno))) (find-file file) (unless exists (jao-org-insert-doc-skeleton)) - (if (or (not exists) (y-or-n-p "Insert link?")) + (if (or (not exists) no-ask (y-or-n-p "Insert link?")) (insert lnk "\n") (kill-new lnk) (message "Link to %s (%s) killed" file page))))) @@ -1797,7 +1820,7 @@ (progn (when jao-xmonad-enabled (jao-shell-exec "xdotool set_destktop 2")) - (jao-shell-exec (format "zathura %s -P %s" file (or page 1)))) + (jao-shell-string (jao-zathura--open-cmd file page " &"))) (let* ((page (if page (format " && xdotool type %dg" page) "")) (cmd (format "xdotool windowactivate %s%s" id page))) (jao-shell-string cmd))))) @@ -1812,17 +1835,18 @@ (setq jao-org-open-pdf-fun 'jao-find-or-open) (defun jao-find-or-open (file &optional page height) - (if (and jao-browse-doc-use-emacs-p window-system) - (let* ((buffs (buffer-list)) - (b (catch 'done - (while buffs - (when (string-equal (buffer-file-name (car buffs)) file) - (throw 'done (car buffs))) - (setq buffs (cdr buffs)))))) - (jao-afio--goto-docs) - (if b (pop-to-buffer b) (find-file file)) - (when page (jao-doc-view-goto-page page height))) - (jao-zathura-open file page))) + (cond ((and jao-browse-doc-use-emacs-p window-system) + (let* ((buffs (buffer-list)) + (b (catch 'done + (while buffs + (when (string-equal (buffer-file-name (car buffs)) file) + (throw 'done (car buffs))) + (setq buffs (cdr buffs)))))) + (jao-afio--goto-docs) + (if b (pop-to-buffer b) (find-file file)) + (when page (jao-doc-view-goto-page page height)))) + (jao-sway-enabled (jao-sway-open-with-zathura file page)) + (t (jao-zathura-open file page)))) (defun jao-open-doc (&optional file page height) (interactive) |