config: add theme toggling to doom emacs
This commit is contained in:
parent
f6055fd6c3
commit
8c2c5c49ca
|
@ -22,8 +22,19 @@
|
||||||
doom-font (font-spec :family "monospace" :size 24 :weight 'semi-light)
|
doom-font (font-spec :family "monospace" :size 24 :weight 'semi-light)
|
||||||
doom-variable-pitch-font (font-spec :family "sans" :size 24))
|
doom-variable-pitch-font (font-spec :family "sans" :size 24))
|
||||||
|
|
||||||
; TODO how to treat sequencep as string? - theme toggle
|
(defun load-theme-string (theme)
|
||||||
;(s-chop-suffixes '("-light" "-dark") doom-theme)
|
(if (-contains? (custom-available-themes) (intern theme)) (load-theme (intern theme))))
|
||||||
|
(defun toggle-theme (&optional suffix)
|
||||||
|
"Heuristically toggle between light and dark themes."
|
||||||
|
(interactive)
|
||||||
|
(let* ((theme (s-replace-all '(("light" . "dark") ("dark" . "light")
|
||||||
|
("black" . "white") ("white" . "black")
|
||||||
|
("day" . "night") ("night" . "day"))
|
||||||
|
(symbol-name doom-theme)))
|
||||||
|
(theme-base (s-replace-regexp "-[^-]*$" "" theme)))
|
||||||
|
(or (if suffix (or (load-theme-string (concat theme "-" suffix)) (load-theme-string (concat theme-base "-" suffix)))) (load-theme-string (if (and (not suffix) (equal theme (symbol-name doom-theme))) (concat theme "-light") theme)) (load-theme-string theme-base))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
(setq display-line-numbers-type 'relative
|
(setq display-line-numbers-type 'relative
|
||||||
scroll-margin 6
|
scroll-margin 6
|
||||||
|
|
|
@ -40,7 +40,8 @@ test "$XDG_CURRENT_DESKTOP" = "KDE" || return 0
|
||||||
# Fix errors regarding broken mim database
|
# Fix errors regarding broken mim database
|
||||||
alias fixmime='sudo rm /usr/share/mime/packages/kde.xml && sudo update-mime-database /usr/share/mime'
|
alias fixmime='sudo rm /usr/share/mime/packages/kde.xml && sudo update-mime-database /usr/share/mime'
|
||||||
|
|
||||||
# Switch theme across KDE system and taskwarrior
|
# Switch theme across system: KDE, Konsole, taskwarrior, bat
|
||||||
|
# WIP: Emacs, Mozilla, diffr (git pager)
|
||||||
theme_save="$XDG_CACHE_HOME/theme"
|
theme_save="$XDG_CACHE_HOME/theme"
|
||||||
#theme_default="$(d=$(date +%H) && test $d -gt 7 && test $d -lt 19 && echo light || echo dark)"
|
#theme_default="$(d=$(date +%H) && test $d -gt 7 && test $d -lt 19 && echo light || echo dark)"
|
||||||
theme_default="dark"
|
theme_default="dark"
|
||||||
|
@ -50,6 +51,9 @@ theme() {
|
||||||
then kcmshell5 kcm_lookandfeel
|
then kcmshell5 kcm_lookandfeel
|
||||||
elif test "$theme" != "$THEME" -a "$2" != "q"
|
elif test "$theme" != "$THEME" -a "$2" != "q"
|
||||||
then kcmshell5 kcm_lookandfeel &
|
then kcmshell5 kcm_lookandfeel &
|
||||||
|
# TODO theme diffr
|
||||||
|
bak $XDG_CONFIG_HOME/git/diffr
|
||||||
|
emacsclient -e "(toggle-theme \"$theme\")"
|
||||||
fi
|
fi
|
||||||
export THEME="$theme"
|
export THEME="$theme"
|
||||||
echo "$theme">"$theme_save"
|
echo "$theme">"$theme_save"
|
||||||
|
|
Loading…
Reference in New Issue