summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-02-14 01:53:43 +0000
committerjao <jao@gnu.org>2021-02-14 01:53:43 +0000
commit6e2c3d8d2b39a53df8b41f06c3bb9ff3d5cb9538 (patch)
tree466bf1f389ae79683c812b222640fe6322626962
parent480c556e4f34480aff46375a346736b3ba12eb60 (diff)
downloadelibs-6e2c3d8d2b39a53df8b41f06c3bb9ff3d5cb9538.tar.gz
elibs-6e2c3d8d2b39a53df8b41f06c3bb9ff3d5cb9538.tar.bz2
config: fix for transparency handling in sway
-rw-r--r--init.org40
1 files changed, 24 insertions, 16 deletions
diff --git a/init.org b/init.org
index 722b975..7153422 100644
--- a/init.org
+++ b/init.org
@@ -294,32 +294,40 @@
* Fonts and colour themes
*** Transparency
#+begin_src emacs-lisp
- (defvar jao-frames-default-alpha (if (eq window-system 'pgtk) 96 90))
+ (defvar jao-frames-default-alpha (if (eq window-system 'pgtk) 100 90))
+ (defvar jao-transparent-p t)
- (defun jao-sway-set-transparency ()
+ (defun jao-sway-set-transparency (level)
(when jao-sway-enabled-p
- (let ((alpha (/ (or (cadr (frame-parameter nil 'alpha)) 100) 100.0)))
+ (let ((alpha (/ level 100.0)))
(jao-swaymsg (format "[app_id=emacs] opacity %s" alpha)))))
(defun jao-toggle-transparency (&optional all)
(interactive "P")
- (if all
- (let* ((trans (/= jao-frames-default-alpha 100))
- (new-alpha (if trans 100 jao-frames-default-alpha)))
- (modify-all-frames-parameters `((alpha . (,new-alpha ,new-alpha)))))
- (if (/= (or (cadr (frame-parameter nil 'alpha)) 100) 100)
- (set-frame-parameter nil 'alpha '(100 100))
- (set-frame-parameter nil 'alpha (list jao-frames-default-alpha
- jao-frames-default-alpha))))
- (jao-sway-set-transparency))
+ (setq jao-transparent-p (not jao-transparent-p))
+ (cond (jao-sway-enabled-p
+ (jao-sway-set-transparency (if jao-transparent-p 90 100)))
+ (all (let* ((trans (/= jao-frames-default-alpha 100))
+ (new-alpha (if trans 100 jao-frames-default-alpha))
+ (a `((alpha . (,new-alpha ,new-alpha)))))
+ (modify-all-frames-parameters a)))
+ ((/= (or (cadr (frame-parameter nil 'alpha)) 100) 100)
+ (set-frame-parameter nil 'alpha '(100 100)))
+ (t (set-frame-parameter nil 'alpha `(,jao-frames-default-alpha
+ ,jao-frames-default-alpha)))))
(defun jao-transparent-p ()
- (/= (or (cadr (frame-parameter nil 'alpha)) 100) 100))
+ (if jao-sway-enabled-p
+ jao-transparent-p
+ (/= (or (cadr (frame-parameter nil 'alpha)) 100) 100)))
- (defun jao-set-transparency (&optional level)
+ (defun jao-set-transparency (level)
(interactive "nOpacity (0-100): ")
- (set-frame-parameter nil 'alpha (list level level))
- (jao-sway-set-transparency))
+ (let ((level (or level jao-frames-default-alpha)))
+ (setq jao-transparent-p (< level 100))
+ (if jao-sway-enabled-p
+ (jao-sway-set-transparency level)
+ (set-frame-parameter nil 'alpha (list level level)))))
#+end_src
*** Fonts
***** Unicode fonts