hyuri: (Thoughtful)
[personal profile] hyuri
y’know, it’s really too bad I can’t set Windows up with something like this:

(defun my-colors-light (&optional frame)
  "Set colors suitable for working in light environment,
i.e. in daylight or under bright electric lamps."
  (interactive)
  (if frame
      (select-frame frame)
    (setq frame (selected-frame)))
  ;; Color with minimal eye fatigue in light environments
  ;; is "AntiqueWhite3" (RGB: 205 182 176),
  (set-background-color "AntiqueWhite3")
  (set-foreground-color "black")
  (set-cursor-color "DarkSlateGrey")
  (when (facep 'region)
    (set-face-background 'region "DarkGrey" frame))
  (when (facep 'fringe)
    (set-face-background 'fringe (face-background 'default) frame)
    (set-face-foreground 'fringe (face-foreground 'default) frame)))

(define-key global-map [f6 ?c ?s] 'my-colors-light)

(defun my-colors-dark (&optional frame)
  "Set colors suitable for working in the darkness without electricity."
  (interactive)
  (if frame
      (select-frame frame)
    (setq frame (selected-frame)))
  (set-background-color "black")
  (set-foreground-color "DarkGrey")
  (set-cursor-color "DarkSlateGrey")
  (when (facep 'region)
    (set-face-background 'region "DimGrey" frame))
  (when (facep 'fringe)
    (set-face-background 'fringe (face-background 'default) frame)
    (set-face-foreground 'fringe (face-foreground 'default) frame)))

(define-key global-map [f6 ?c ?d] 'my-colors-dark)

;; Automatically switch to dark background after sunset
;; and to light background after sunrise.
;; (Not that 'calendar-latitude' and 'calendar-longitude'
;;  should be set before calling the 'solar-sunrise-sunset')
(defun my-colors-set (&optional frame)
  (interactive)
  (require 'solar)
  (if (and calendar-latitude calendar-longitude calendar-time-zone)
     (let* ((l (solar-sunrise-sunset (calendar-current-date)))
            (sunrise-string (apply 'solar-time-string (car l)))
	    (sunset-string (apply 'solar-time-string (car (cdr l))))
	    (current-time-string (format-time-string "%H:%M")))
       (if (or (string-lessp current-time-string sunrise-string)
	       (string-lessp sunset-string current-time-string))
	   (my-colors-dark frame))
       (if (and (boundp 'my-sunset-timer)  (timerp my-sunset-timer))
	   (cancel-timer my-sunset-timer))
       (if (and (boundp 'my-sunrise-timer) (timerp my-sunrise-timer))
	   (cancel-timer my-sunrise-timer))
       (setq my-sunset-timer  (run-at-time sunset-string  (* 60 60 24) 'my-colors-dark))
       (setq my-sunrise-timer (run-at-time sunrise-string (* 60 60 24) 'my-colors-light)))))

(my-colors-set)
(add-to-list 'after-make-frame-functions 'my-colors-set)
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

hyuri: (Default)
hyuri

November 2014

S M T W T F S
      1
2345678
9101112131415
161718192021 22
23242526272829
30      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 19th, 2025 12:59 am
Powered by Dreamwidth Studios