-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathzathura-sync-theme.el
86 lines (76 loc) · 2.45 KB
/
zathura-sync-theme.el
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
76
77
78
79
80
81
82
83
84
85
86
;;; zathura-sync-theme.el --- Synchronize Zathura's look and feel with Emacs -*- lexical-binding: t; -*-
;; Copyright (C) 2024 Amol Vaidya
;; Author: Amol Vaidya
;; Version: 20240608.1444
;; Keywords: zathura, theming
;; URL: https://github.com/amolv06/zathura-sync-theme
;;; Commentary:
;; This package is inspired by the blog post at
;; https://blog.akaisuisei.org/communicating-with-zathura-via-dbus.html
;; written by mafty.
;;; Code:
(require 'cl-lib)
(require 'dbus)
(defgroup zathura-sync-theme nil
"Synchronize Zathura's look and feel with Emacs."
:prefix "zathura-"
:group 'applications)
(defun zathura-set (&rest _args)
"Set colors in Zathura. `_ARGS' is ignored."
(let ((zathura-services (cl-remove-if-not (lambda (x) (cl-search "zathura" x))
(dbus-list-names :session)))
(zathura-path "/org/pwmt/zathura")
(zathura-interface "org.pwmt.zathura")
(zathura-method "ExecuteCommand")
(zathura-timeout 3000)
(zathura-message-alist `(,(cons 'main-fg
(concat "set recolor-darkcolor "
"\""
(face-attribute 'default :foreground)
"\""))
,(cons 'main-bg
(concat "set recolor-lightcolor "
"\""
(face-attribute 'default :background)
"\""))
,(cons 'default-fg
(concat "set default-fg "
"\""
(face-attribute 'default :foreground)
"\""))
,(cons 'default-bg
(concat "set default-bg "
"\""
(face-attribute 'default :background)
"\""))
,(cons 'mode-line-bg
(concat "set statusbar-bg "
"\""
(face-attribute 'default :background nil 'default)
"\""))
,(cons 'mode-line-fg
(concat "set statusbar-fg "
"\""
(face-attribute 'default :foreground nil 'default)
"\""))
,(cons 'recolor (concat "set recolor true")))))
(dolist (svc zathura-services)
(dolist (msg zathura-message-alist)
(dbus-call-method :session
svc
zathura-path
zathura-interface
zathura-method
:timeout zathura-timeout
(cdr msg))))))
;;;###autoload
(define-minor-mode zathura-sync-theme-mode
"Synchronize the look and feel of Zathura with Emacs."
:global t
:init-value nil
:lighter "Zathura"
(if zathura-sync-theme-mode
(advice-add 'enable-theme :after #'zathura-set)
(advice-remove 'enable-theme #'zathura-set)))
(provide 'zathura-sync-theme)
;;; zathura-sync-theme.el ends here