Move location layer to geolocation layer
Rename layer variables to be more explicit Always use the first two themes of dotspacemacs-themes
This commit is contained in:
parent
8c8778bbd7
commit
234cb960b5
|
@ -1,14 +0,0 @@
|
|||
(defvar enable-osx-location-service-support nil
|
||||
"")
|
||||
|
||||
(defvar enable-weather-forecast nil
|
||||
"")
|
||||
|
||||
(defvar enable-automatic-theme-managment nil
|
||||
"")
|
||||
|
||||
(defvar spacemacs/day-theme 'spacemacs-light
|
||||
"")
|
||||
|
||||
(defvar spacemacs/night-theme 'spacemacs-dark
|
||||
"")
|
|
@ -1,31 +0,0 @@
|
|||
;;; extensions.el --- location Layer extensions File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2014 Sylvain Benner
|
||||
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(setq location-pre-extensions
|
||||
'(
|
||||
;; pre extension names go here
|
||||
))
|
||||
|
||||
(setq location-post-extensions
|
||||
'(
|
||||
;; post extension names go here
|
||||
))
|
||||
|
||||
;; For each extension, define a function location/init-<extension-name>
|
||||
;;
|
||||
;; (defun location/init-my-extension ()
|
||||
;; "Initialize my extension"
|
||||
;; )
|
||||
;;
|
||||
;; Often the body of an initialize function uses `use-package'
|
||||
;; For more info on `use-package', see readme:
|
||||
;; https://github.com/jwiegley/use-package
|
|
@ -1,21 +1,29 @@
|
|||
#+TITLE: Location contribution layer for Spacemacs
|
||||
#+TITLE: Geolocation contribution layer for Spacemacs
|
||||
|
||||
* Table of Contents :TOC@4:
|
||||
- [[#description][Description]]
|
||||
- [[#supported-packages-in-this-layer][Supported packages in this layer]]
|
||||
- [[#install][Install]]
|
||||
- [[#configuration][Configuration]]
|
||||
- [[#location][Location]]
|
||||
- [[#theme-changer][theme-changer]]
|
||||
- [[#sunshine-weather-forecast][sunshine (weather forecast)]]
|
||||
- [[#osx-location][osx-location]]
|
||||
- [[#key-bindings][Key Bindings]]
|
||||
- [[#weather][Weather]]
|
||||
|
||||
* Table of Contents
|
||||
|
||||
* Description
|
||||
This layer offers few location sensetive adjustment to Emacs, such as
|
||||
automaticly switching between light (day) and dark (night) themes, weather
|
||||
This layer offers few location sensitive adjustment to Emacs, such as
|
||||
automatically switching between light (day) and dark (night) themes, weather
|
||||
forecast and on OS X, also automatic tracking of location, using OS X's
|
||||
CoreLocation services.
|
||||
|
||||
** Supported packages in this layer
|
||||
|
||||
- [[https://github.com/hadronzoo/theme-changer][theme-changer]]
|
||||
- [[https://github.com/aaronbieber/sunshine.el/blob/master/sunshine.el][sunshine]]
|
||||
- [[https://github.com/purcell/osx-location][osx-location]]
|
||||
|
||||
* Install
|
||||
|
||||
To enable this contribution layer, add it to your =~/.spacemacs=~ like this:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
|
@ -26,12 +34,14 @@ All services are disable by default. To enable all, or some of them, add instead
|
|||
something like this:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(location :variables
|
||||
enable-osx-location-service-support t
|
||||
enable-weather-forecast t
|
||||
enable-automatic-theme-managment t)
|
||||
(geolocation :variables
|
||||
geolocation-enable-osx-location-service-support t
|
||||
geolocation-enable-weather-forecast t
|
||||
geolocation-enable-automatic-theme-changer t)
|
||||
#+END_SRC
|
||||
|
||||
* Configuration
|
||||
** Location
|
||||
To set location manually, add something like this inside the ~dotspacemacs/config
|
||||
defun~.
|
||||
|
||||
|
@ -42,25 +52,12 @@ defun~.
|
|||
#+END_SRC
|
||||
|
||||
On OS X, all of these variables get setup automatically by the ~osx-location~
|
||||
service, when enabled. If ~calendar-location-name~ was ommitted, it'll be
|
||||
service, when enabled. If ~calendar-location-name~ was omitted, it'll be
|
||||
stringed-up like so: "41.23, 1.80".
|
||||
|
||||
* Key Bindings
|
||||
New keybindings for this layer are for using ~sunshine~.
|
||||
|
||||
| Evil | Holy | Command |
|
||||
|-----------+------+-----------------------------------------------|
|
||||
| ~SPC a w~ | | Display pretty weather forecast |
|
||||
| ~SPC a W~ | | Display quick weather forecast in mini buffer |
|
||||
|
||||
* Customize it!
|
||||
** theme-changer
|
||||
Theme changer will switch between two given themes, depending on time at
|
||||
geographical location. By default, it will use first two themes the user has setup in
|
||||
~dotemacs-themes~.
|
||||
|
||||
If the list is empty, for whatever reason, it'll swap ~spacemacs-light~ and
|
||||
~spacemacs-dark~ by default.
|
||||
Theme changer will switch between the first two themes the user has setup in
|
||||
~dotspacemacs-themes~, depending on time at geographical location.
|
||||
|
||||
** sunshine (weather forecast)
|
||||
Sunshine uses the imperial unit system by default. To switch to metric, do this:
|
||||
|
@ -86,3 +83,10 @@ helper script will need to be given proper access first time this layer is
|
|||
activated.
|
||||
|
||||
[[file:img/emacs-location-helper.jpg]]
|
||||
|
||||
* Key Bindings
|
||||
** Weather
|
||||
| Evil | Holy | Command |
|
||||
|-----------+------+-----------------------------------------------|
|
||||
| ~SPC a w~ | | Display pretty weather forecast |
|
||||
| ~SPC a W~ | | Display quick weather forecast in mini buffer |
|
|
@ -0,0 +1,20 @@
|
|||
;;; config.el --- geolocation configuration File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2014 Sylvain Benner
|
||||
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
||||
;;
|
||||
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
||||
;; URL: https://github.com/syl20bnr/spacemacs
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(defvar geolocation-enable-osx-location-service-support nil
|
||||
"If non nil enable the OS X location service support.")
|
||||
|
||||
(defvar geolocation-enable-weather-forecast nil
|
||||
"If non nil enable the weather forecast service.")
|
||||
|
||||
(defvar geolocation-enable-automatic-theme-changer nil
|
||||
"If non nil enable the automatic change of theme based on the current time.")
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
@ -1,4 +1,4 @@
|
|||
;;; packages.el --- location Layer packages File for Spacemacs
|
||||
;;; packages.el --- Geolocation Layer packages File for Spacemacs
|
||||
;;
|
||||
;; Copyright (c) 2012-2014 Sylvain Benner
|
||||
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
||||
|
@ -10,20 +10,17 @@
|
|||
;;
|
||||
;;; License: GPLv3
|
||||
|
||||
(setq location-packages
|
||||
(setq geolocation-packages
|
||||
'(
|
||||
osx-location
|
||||
sunshine
|
||||
theme-changer
|
||||
))
|
||||
|
||||
(require 'solar)
|
||||
|
||||
(defun location/init-osx-location ()
|
||||
(defun geolocation/init-osx-location ()
|
||||
"Initialize osx-location"
|
||||
(use-package osx-location
|
||||
:if enable-osx-location-service-support
|
||||
:defer t
|
||||
:if geolocation-enable-osx-location-service-support
|
||||
:init
|
||||
(progn
|
||||
(add-hook 'osx-location-changed-hook
|
||||
|
@ -32,13 +29,15 @@
|
|||
calendar-longitude osx-location-longitude)
|
||||
(unless calendar-location-name
|
||||
(setq calendar-location-name
|
||||
(format "%s, %s" osx-location-latitude osx-location-longitude)))))
|
||||
(format "%s, %s"
|
||||
osx-location-latitude
|
||||
osx-location-longitude)))))
|
||||
(osx-location-watch))))
|
||||
|
||||
(defun location/init-sunshine ()
|
||||
(defun geolocation/init-sunshine ()
|
||||
"Initialize sunshine"
|
||||
(use-package sunshine
|
||||
:if enable-weather-forecast
|
||||
:if geolocation-enable-weather-forecast
|
||||
:defer t
|
||||
:init
|
||||
(progn
|
||||
|
@ -50,20 +49,20 @@
|
|||
(kbd "q") 'quit-window
|
||||
(kbd "i") 'sunshine-toggle-icons))
|
||||
:config
|
||||
;; just in case location was not set by user, or on OS X, if wasn't set up
|
||||
;; automatically, will not work with Emac's default for `calendar-location-name'
|
||||
;; just in case location was not set by user, or on OS X,
|
||||
;; if wasn't set up automatically, will not work with Emac's
|
||||
;; default for ;; `calendar-location-name'
|
||||
(when (not (boundp 'sunshine-location))
|
||||
(setq sunshine-location (format "%s, %s" calendar-latitude calendar-longitude)))))
|
||||
(setq sunshine-location (format "%s, %s"
|
||||
calendar-latitude
|
||||
calendar-longitude)))))
|
||||
|
||||
(defun location/init-theme-changer ()
|
||||
(defun geolocation/init-theme-changer ()
|
||||
"Initialize theme-changer"
|
||||
(use-package theme-changer
|
||||
:if enable-automatic-theme-managment
|
||||
:defer t
|
||||
:init
|
||||
(when (car dotspacemacs-themes) ;; at least one theme defined in user's `dotspacemacs-themes'
|
||||
(setq spacemacs/day-theme (nth 0 dotspacemacs-themes))
|
||||
(setq spacemacs/night-theme (nth 1 dotspacemacs-themes)))
|
||||
:if geolocation-enable-automatic-theme-changer
|
||||
:config
|
||||
(change-theme spacemacs/day-theme spacemacs/night-theme) ;; otherwise use defaults fron config.el
|
||||
))
|
||||
(progn
|
||||
(when (> (length dotspacemacs-themes) 1)
|
||||
(change-theme (nth 0 dotspacemacs-themes)
|
||||
(nth 1 dotspacemacs-themes))))))
|
Loading…
Reference in New Issue