Add windows + linux settings
This commit is contained in:
parent
b8520bd3cf
commit
f9b5c35951
57
.emacs
57
.emacs
@ -36,17 +36,53 @@
|
||||
(use-package zenburn-theme
|
||||
:ensure t)
|
||||
|
||||
;; Function to detect macOS system appearance (light or dark)
|
||||
(defun my/mac-get-system-appearance ()
|
||||
"Return 'light or 'dark based on macOS system appearance."
|
||||
(defun my/get-system-appearance ()
|
||||
(cond
|
||||
;; ---------------------------
|
||||
;; macOS
|
||||
;; ---------------------------
|
||||
((eq system-type 'darwin)
|
||||
(if (string= (shell-command-to-string "defaults read -g AppleInterfaceStyle 2>/dev/null") "Dark\n")
|
||||
'dark
|
||||
'light))
|
||||
|
||||
;; Function to set theme based on system appearance
|
||||
;; ---------------------------
|
||||
;; Windows
|
||||
;; ---------------------------
|
||||
((eq system-type 'windows-nt)
|
||||
;; NOTE: For Windows 10/11, “AppsUseLightTheme” is under:
|
||||
;; HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize
|
||||
;; Value of 1 => Light, 0 => Dark
|
||||
(let ((output (shell-command-to-string
|
||||
"reg query \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\" /v AppsUseLightTheme 2>nul")))
|
||||
(cond
|
||||
((string-match "0x1" output) 'light)
|
||||
((string-match "0x0" output) 'dark)
|
||||
(t nil))))
|
||||
|
||||
;; ---------------------------
|
||||
;; GNOME-based Linux
|
||||
;; ---------------------------
|
||||
((eq system-type 'gnu/linux)
|
||||
;; If you're on GNOME 42+, `color-scheme` often shows 'prefer-dark' or 'prefer-light'.
|
||||
;; If the user is using an older system or a different DE, this may fail or return an empty string.
|
||||
(let ((gsettings-output (string-trim
|
||||
(shell-command-to-string
|
||||
"gsettings get org.gnome.desktop.interface color-scheme 2>/dev/null"))))
|
||||
(cond
|
||||
((string-match "dark" gsettings-output) 'dark)
|
||||
((string-match "light" gsettings-output) 'light)
|
||||
(t nil))))
|
||||
|
||||
;; ---------------------------
|
||||
;; Otherwise, undetermined
|
||||
;; ---------------------------
|
||||
|
||||
(t nil)))
|
||||
|
||||
(defun my/set-theme-based-on-appearance ()
|
||||
"Set Emacs theme based on macOS system appearance."
|
||||
(let ((appearance (my/mac-get-system-appearance)))
|
||||
"Set Emacs theme based on system appearance if possible, otherwise fallback."
|
||||
(let ((appearance (my/get-system-appearance)))
|
||||
;; Disable all currently enabled themes to prevent conflicts
|
||||
(mapc #'disable-theme custom-enabled-themes)
|
||||
(pcase appearance
|
||||
@ -55,11 +91,13 @@
|
||||
('light
|
||||
(load-theme light-theme t))
|
||||
(_
|
||||
(load-theme light-theme t))))) ;; Default to light if undetermined
|
||||
;; If we cannot detect the theme, default to light
|
||||
(load-theme light-theme t)))))
|
||||
|
||||
;; Apply theme at startup
|
||||
(my/set-theme-based-on-appearance)
|
||||
|
||||
|
||||
;; ===========================
|
||||
;; UI Customizations
|
||||
;; ===========================
|
||||
@ -77,7 +115,7 @@
|
||||
(global-visual-line-mode 1)
|
||||
|
||||
;; Set Default Font to Iosevka 18pt
|
||||
(set-face-attribute 'default nil :family "Iosevka" :height 180)
|
||||
(set-face-attribute 'default nil :family "Iosevka" :height 150)
|
||||
|
||||
;; Backup files -> ~/.emacs.d/backups/
|
||||
(setq backup-directory-alist `(("." . "~/.emacs.d/backups"))
|
||||
@ -162,11 +200,12 @@
|
||||
:hook ((python-mode . lsp)
|
||||
(kotlin-mode . lsp)
|
||||
(c++-mode . lsp)
|
||||
(c-mode . lsp)
|
||||
(rust-mode . lsp))
|
||||
:commands lsp
|
||||
:config
|
||||
(setq lsp-prefer-flymake nil) ;; Use lsp-ui and flycheck instead of flymake
|
||||
(setq lsp-enable-snippet nil) ;; Disable snippet support if not needed
|
||||
(setq lsp-enable-snippet t) ;; Disable snippet support if not needed
|
||||
(setq lsp-headerline-breadcrumb-enable nil)) ;; Disable breadcrumb for performance
|
||||
|
||||
(use-package lsp-ui
|
||||
|
Loading…
x
Reference in New Issue
Block a user