Giter Club home page Giter Club logo

theme-changer's Introduction

Sunrise/Sunset Theme Changer for Emacs

Given a location and day/night color themes, this file provides a change-theme function that selects the appropriate theme based on whether it is day or night. It will continue to change themes at sunrise and sunset. To install:

Set the location:

(setq calendar-location-name "Dallas, TX") 
(setq calendar-latitude 32.85)
(setq calendar-longitude -96.85)

Specify the day and night themes:

(require 'theme-changer)
(change-theme 'solarized-light 'solarized-dark)

You can also pass nil as either of parameters to change-theme, with the effect of not using a theme (or using the default Emacs theme) during that period of the day. For example:

(change-theme nil 'solarized-dark)

will result in setting the default Emacs theme during the day, and solarized-dark during the night.

Note: you may need to add the repository path to your loadpath. For example:

(add-to-list 'load-path "~/.emacs.d/elisp/theme-changer")

If you want to use the color-theme package instead of the Emacs 24 color theme facility:

(setq theme-changer-mode "color-theme")
(change-theme 'color-theme-solarized-light 'color-theme-solarized-dark)

theme-changer's People

Contributors

cadadr avatar cnsunyour avatar hadronzoo avatar jsnikeris avatar kisp avatar mplscorwin avatar swflint avatar tareefdev avatar tarsius avatar tokenrove avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

theme-changer's Issues

Package Does Not Automatically Load With ELPA

After installing via ELPA, I can add the following code to my .emacs.

(eval-after-load "theme-changer" '(change-theme 'solarized-light 'solarized-dark))

But the code is not run on start-up; I have to manually load the file theme-changer.el or theme-changer.elc, and then the code will be run. Therefore, the package is not automatically loaded when installed via ELPA, which is a problem.

Wrong type argument: number-or-marker-p on startup, but not always when eval'ed interactively

I'm getting this error on startup (from solar.el it seems):

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  solar-exact-local-noon((10 29 2013))
  solar-sunrise-sunset((10 29 2013))
  sunrise-sunset-times((10 29 2013))
  change-theme(solarized-light zenburn)
  eval-buffer(#<buffer  *load*-516236> nil "/Volumes/Data/uri/.emacs.d/config/_appearance.el" nil t)  ; Reading at buffer position 156
  load-with-code-conversion("/Volumes/Data/uri/.emacs.d/config/_appearance.el" "/Volumes/Data/uri/.emacs.d/config/_appearance.el" nil t)
  require(_appearance)
  eval-buffer(#<buffer  *load*> nil "/Volumes/Data/uri/.emacs.d/init.el" nil t)  ; Reading at buffer position 273
  load-with-code-conversion("/Volumes/Data/uri/.emacs.d/init.el" "/Volumes/Data/uri/.emacs.d/init.el" t t)
  load("/Volumes/Data/uri/.emacs.d/init" t t)
  #[0 "^H\205\262^@     \306=\203^Q^@\307^H\310Q\202;^@ \311=\204^^^@\307^H\312Q\202;^@\313\307\314\315#\203*^@\316\202;^@\313\307\314\317#\203:^@\320\nB^R\321\202;^@\316\322^S\323$
  command-line()
  normal-top-level()

I've managed though to eval it once or twice from a buffer, w/o a problem, and it worked fine, so not sure where the problem is.

I've got is setup like this:

(setq calendar-location-name "Geneva, Switzerland")
(setq calendar-latitude 46.12)
(setq calendar-longitude 6.9)
...
(require 'theme-changer)
(change-theme 'solarized-light 'zenburn)

Though I've tried different combos of themes and locations...

Does not work properly on emacs 27

I really like this package. I have been using theme-changer on emacs 26 to switch themes automatically.

But after upgrading to emacs 27, the theme cannot be switched automatically, and the theme can be set correctly only at startup.

Does it even work with Emacs 24?

% emacs --version
GNU Emacs 24.3.1

I'm an Emacs newbie and I'm having problems with your plugin. I installed it via ELPA, then added this to my init.el:

(setq calendar-location-name "Dallas, TX") 
(setq calendar-latitude 32.85)
(setq calendar-longitude -96.85)

(change-theme 'adwaita 'wombat)

And when I launch Emacs, I get this.

Warning (initialization): An error occurred while loading `/home/curacao/.emacs.d/init.el':

Symbol's function definition is void: change-theme

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

This is the backtrace from Emacs launch with --debug-init flag.

Debugger entered--Lisp error: (void-function change-theme)
  (change-theme (quote adwaita) (quote wombat))
  eval-buffer(#<buffer  *load*> nil "/home/curacao/.emacs.d/init.el" nil t)  ; Reading at buffer position 719
  load-with-code-conversion("/home/curacao/.emacs.d/init.el" "/home/curacao/.emacs.d/init.el" t t)
  load("/home/curacao/.emacs.d/init" t t)

Both M-x load-theme <RET> wombat and M-x load-theme <RET> adwaita work fine.

Allow setting a time offset?

First of all thank you for writing and maintaining this project. I use it everyday.

Not sure how useful this will be generally but I would like the theme to change at one hour before sunset rather than exactly at sunset because it starts to get pretty dark at that point. I would appreciate allowing to set an offset for this.

If this is something worth pursuing, I can try implementing this if you can give me some pointers on how to get started. I have never worked on emacs plugins before but I am willing to try.

Thank you again.

Theme is not changed on startup

I have the following code in my .emacs:

    ;; use a light theme during the day and a dark one for the night
    (progn
      (setq calendar-location-name "Belo Horizonte, Brazil"
            calendar-latitude -19.919
            calendar-longitude -43.938)
      (require 'theme-changer)
      (change-theme 'solarized-light 'solarized-dark))

But when I start Emacs, for example at night, it do not change to the dark theme. If I evaluate manually works.

Broken after the 0414.2308 update

Debugger entered--Lisp error: (void-function first)
first((4 18 2023))
theme-changer-hour-fraction-to-time((4 18 2023) 6.1333333337679505)
theme-changer-sunrise-sunset-times((4 18 2023))
change-theme(leuven leuven-dark)
load-with-code-conversion("c:/.emacs.d/generalX1.el" "c:/.emacs.d/generalX1.el" nil t)
require(generalX1 "/.emacs.d/generalX1.el")
load-with-code-conversion("c:/Users/Admin/.emacs.d/init.el" "c:/Users/Admin/.emacs.d/init.el" t t)
load("c:/Users/Admin/.emacs.d/init" noerror nomessage)
startup--load-user-init-file(#f(compiled-function () #<bytecode 0x270a9e9b83ab4e8>) #f(compiled-function () #<bytecode -0x1f3c686ddc0da035>) t)
command-line()
normal-top-level()

wrong-type-argument number-or-marker-p nil

After run the following code, I got wrong-type-argument number-or-marker-p nil

(setq calendar-location-name "Dallas, TX") 
(setq calendar-latitude 32.85)
(setq calendar-longitude -96.85)
(require 'theme-changer)
(change-theme 'solarized-light 'solarized-dark)

backtrace:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  cl-truncate(nil)
  (let* ((now (decode-time (current-time))) (month (first date)) (day (car (cdr date))) (year (car (cdr (cdr date)))) (zone (ninth now)) (frac-hour (cl-truncate hour-fraction)) (hour (first frac-hour)) (frac-minutes (cl-truncate (* (car (cdr frac-hour)) 60))) (minute (first frac-minutes)) (frac-seconds (cl-truncate (* (car (cdr frac-minutes)) 60))) (sec (first frac-seconds))) (encode-time sec minute hour day month year zone))
  theme-changer-hour-fraction-to-time((2 3 2020) nil)
  (let* ((l (solar-sunrise-sunset date)) (sunrise-time (theme-changer-hour-fraction-to-time date (car (car l)))) (sunset-time (theme-changer-hour-fraction-to-time date (car (car (cdr l)))))) (list sunrise-time sunset-time))
  theme-changer-sunrise-sunset-times((2 3 2020))
  (first (theme-changer-sunrise-sunset-times (theme-changer-tomorrow)))
  (let* ((now (current-time)) (sunrise-tomorrow (first (theme-changer-sunrise-sunset-times (theme-changer-tomorrow))))) (let* ((--cl-rest-- (theme-changer-sunrise-sunset-times (theme-changer-today))) (sunrise-today (if (= (length --cl-rest--) 2) (car-safe (prog1 --cl-rest-- (setq --cl-rest-- ...))) (signal (quote wrong-number-of-arguments) (list nil (length --cl-rest--))))) (sunset-today (car --cl-rest--))) (let* ((theme (cond ((time-less-p now sunrise-today) (cons sunrise-today night-theme)) ((time-less-p now sunset-today) (cons sunset-today day-theme)) (t (cons sunrise-tomorrow night-theme)))) (next-change (if theme (car-safe (prog1 theme ...)) (signal (quote wrong-number-of-arguments) (list nil ...))))) (let ((old-theme (theme-changer-switch-theme old-theme theme))) (run-at-time (theme-changer-add-second next-change) nil (quote change-theme) day-theme night-theme old-theme)))))
  change-theme(solarized-light solarized-dark)
  eval((change-theme (quote solarized-light) (quote solarized-dark)) nil)

System Info ๐Ÿ’ป

  • OS: darwin
  • Emacs: 26.3
  • Spacemacs: 0.300.0
  • Spacemacs branch: develop (rev. f4f95d28f)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: hybrid
  • Completion: ivy
  • Layers:
(spacemacs-cfg config lang misc my-org)
  • System configuration features: NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS THREADS

Offer to Maintain

You've mentioned that you're looking for a maintainer. I find this package to be immensely useful, and would like to see it continued to be worked on and updated. I'm willing to take on the task if you're still looking for someone.

Could you please add the `after-theme-change` hook?

Hi, guys. This emacs plugin is very good. But I'm wondering that is there any kind of things like a hook can be run after the theme changed? The thing is I want to change the font weight after theme changed. If there is not, can anybody help me to modify the code? I've tried to add hook after load-theme, but it doesn't work. Thanks!

It broke suddenly after updating few packages

Can you help to fix this ?

_Debugger entered--Lisp error: (error "Too many arguments") (defvar theme-changer-post-change-hook nil ("c:/Users/abc/AppData/Roaming/.emacs.d/elpa/th..." . 1171) :type 'hook :group 'theme-changer) require(theme-changer) load-with-code-conversion("c:/Users/abc/AppData/Roaming/.emacs.d/init.el" "c:/Users/abc/AppData/Roaming/.emacs.d/init.el" t t) load("c:/Users/abc/AppData/Roaming/.emacs.d/init" noerror nomessage) startup--load-user-init-file(#f(compiled-function () #<bytecode 0xbd4630b4395cf5c>) #f(compiled-function () #<bytecode -0x1f3c686ddc0da035>) t) command-line() normal-top-level()_

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.