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)

Date: 2004-10-22 04:32 pm (UTC)
From: [identity profile] djinubito.livejournal.com
Interesting.

Date: 2004-10-22 06:13 pm (UTC)
From: [identity profile] hyuri.livejournal.com
Do I detect a hint of sarcasm?

Date: 2004-10-22 06:39 pm (UTC)

Date: 2004-10-22 07:16 pm (UTC)
From: [identity profile] science-vixen.livejournal.com
nifty.

I presume that this does work in other OSes like linux?

Date: 2004-10-22 07:41 pm (UTC)
From: [identity profile] hyuri.livejournal.com
Actually, that’s just in my .emacs (http://hyuri.org/other/.emacs). So I guess in a way it does work in Windows...

ANEURISM!!!

Date: 2004-10-22 08:03 pm (UTC)
From: [identity profile] drgnmstralex.livejournal.com
*goes blind*

....wtf was that? #_#

Re: ANEURISM!!!

Date: 2004-10-22 08:09 pm (UTC)
From: [identity profile] hyuri.livejournal.com
That, my friend, is Emacs-Lisp. A vile yet somehow nifty little language. ^_^

Re: ANEURISM!!!

Date: 2004-10-22 08:25 pm (UTC)
From: [identity profile] jedifreeman.livejournal.com
and I must add that it is much more read-able than true Lisp, which is a wierd-freaky language (although very useful for different things). :-P

Date: 2004-10-22 10:13 pm (UTC)
From: [identity profile] kelston.livejournal.com
Man, that would cost me like 2 fps in games. I can't handle that!

Date: 2004-10-23 01:22 am (UTC)
From: [identity profile] hyuri.livejournal.com
Eh, what’s a couple of frames? You only need 30!

Date: 2004-10-23 08:47 am (UTC)
From: [identity profile] kelston.livejournal.com
I blame John Carmack for making an engine that requires things like exactly 120 frames to do a specific rocket jump in Quake 3 and other things. Dang! You should teach him, har har.

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 Jan. 23rd, 2026 09:10 am
Powered by Dreamwidth Studios