diff options
| author | LLoyderino <adrijan.bjedov@gmail.com> | 2025-05-23 18:32:00 +0200 |
|---|---|---|
| committer | LLoyderino <adrijan.bjedov@gmail.com> | 2025-05-24 15:00:41 +0200 |
| commit | 69ba8d13c8bad526e451beff9c5787dbd1f45e4e (patch) | |
| tree | da20ba492fdc5dabc3dfd7d1274505e45f0a0aa8 | |
| parent | 6b796b8a7f3ed5f86951d169512951a61707ab57 (diff) | |
Added catppuccin theme
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | init.el | 4 | ||||
| -rw-r--r-- | theme.el | 36 |
3 files changed, 41 insertions, 0 deletions
@@ -2,3 +2,4 @@ !.gitignore !init.el +!theme.el
\ No newline at end of file @@ -27,3 +27,7 @@ ;; Magit (use-package magit) +;; Catppuccin theme +;; (require 'theme) +(load "~/.emacs.d/theme.el") + diff --git a/theme.el b/theme.el new file mode 100644 index 0000000..514687f --- /dev/null +++ b/theme.el @@ -0,0 +1,36 @@ +;;; theme.el -*- lexical-binding: t; -*- + +;; Utility to set light & dark theme that follows system +;; This has only been tested on Gnome 48 and depends on gsettings + +(use-package catppuccin-theme) + +(defun set-color-scheme () + (set-theme + (string-trim + (shell-command-to-string "gsettings get org.gnome.desktop.interface color-scheme")))) + +(defun set-theme (scheme) + (setq catppuccin-flavor (cond ((string-equal scheme "\'default\'") 'latte) + ((string-equal scheme "\'prefer-light\'") 'latte) + ((string-equal scheme "\'prefer-dark\'") 'mocha))) + (load-theme 'catppuccin :no-confirm)) + +(defun monitor-theme-changes () + "Listen to gnome theme changes and run set the correct flavor" + (let ((process (make-process + :name "gsettings-monitor" + :command '("gsettings" "monitor" "org.gnome.desktop.interface" "color-scheme") + :filter (lambda (_ output) + (when (string-match-p "color-scheme" output) + (set-color-scheme)))))) + ;; Kill on exit without user prompt + (set-process-query-on-exit-flag process nil))) + +;; Initialize settings +(set-color-scheme) +(monitor-theme-changes) + +(provide 'theme) + +;;; theme.el ends here |
