diff options
author | jao <jao@gnu.org> | 2022-09-10 22:07:35 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-09-10 22:08:00 +0100 |
commit | 4fe17709a2abc20d3abab05f17770682cd79c2ec (patch) | |
tree | 3366c673683776f3df214ec12272c003aee4446f | |
parent | 63afafd29696a2cd74c66a005d32a7ed61ace22b (diff) | |
download | elibs-4fe17709a2abc20d3abab05f17770682cd79c2ec.tar.gz elibs-4fe17709a2abc20d3abab05f17770682cd79c2ec.tar.bz2 |
xdotool helpers
-rw-r--r-- | init.el | 33 |
1 files changed, 25 insertions, 8 deletions
@@ -427,6 +427,26 @@ (let ((level (if jao-transparent-frame 100 jao-frames-default-alpha))) (jao-set-transparency level all))) +;;;; x11 utils +(defun jao-xdotool (arg-or-wait &rest args) + (apply 'jao-shell-exec* + (if (stringp arg-or-wait) "xdotool" arg-or-wait) + (if (stringp arg-or-wait) arg-or-wait "xdotool") + args)) + +(defsubst jao-xdotool-string (&rest args) + (apply 'jao-shell-string "xdotool" args)) + +(defsubst jao-x11-focused-id () (jao-xdotool-string "getwindowfocus")) + +(defsubst jao-x11-window-name (&optional wid) + (jao-xdotool-string "getwindowname" (or wid (jao-x11-focused-id)))) + +(defsubst jao-x11-search-window (title) + (jao-xdotool-string "search" "--name" title)) + +(defsubst jao-x11-goto-ws (n) (jao-xdotool t "set_desktop" (format "%s" n))) + ;;;; exwm (defvar jao-exwm-enabled nil) (defun jao-exwm-enabled-p () jao-exwm-enabled) @@ -527,12 +547,11 @@ (defun jao-screensaver-toggle () (interactive) - (let ((wid (jao-shell-string "xdotool getwindowfocus"))) + (let ((wid (jao-x11-focused-id))) (if (jao-screensaver-enabled) (jao-shell-exec* "xdg-screensaver" "suspend" wid) (jao-shell-exec* "xdg-screensaver" wid)) - (jao-notify (format "Using '%s'" - (jao-shell-string "xdotool getwindownames" wid)) + (jao-notify (format "Using '%s'" (jao-x11-window-name wid)) (format "Screensaver %s" (jao-shell-string "xdg-screensaver status"))))) @@ -1742,13 +1761,11 @@ (setq jao-org-open-pdf-fun 'jao-find-or-open) (defun jao-zathura-open (file page) - (let ((id (jao-shell-string (format "xdotool search --name %s" - (file-name-nondirectory file))))) + (let ((id (jao-x11-search-window (file-name-nondirectory file)))) (if (string-blank-p id) (progn - (when jao-xmonad-enabled - (jao-shell-exec "xdotool set_destktop 2" t)) - (jao-shell-exec (jao-pdf-zathura-open-cmd file page) t)) + (when jao-xmonad-enabled (jao-x11-goto-ws 2)) + (jao-shell-exec (jao-pdf-zathura-open-cmd file page))) (let* ((page (if page (format " && xdotool type %dg" page) "")) (cmd (format "xdotool windowactivate %s%s" id page))) (jao-shell-exec cmd t))))) |