2015-12-02 14:23:39 +00:00
|
|
|
#+TITLE: Geolocation layer
|
2015-10-14 03:35:56 +00:00
|
|
|
|
2019-05-02 21:49:30 +00:00
|
|
|
#+TAGS: layer|tool
|
|
|
|
|
2019-05-07 20:05:06 +00:00
|
|
|
* Table of Contents :TOC_5_gh:noexport:
|
2017-05-22 14:16:12 +00:00
|
|
|
- [[#description][Description]]
|
2017-12-21 17:27:23 +00:00
|
|
|
- [[#features][Features:]]
|
2017-05-22 14:16:12 +00:00
|
|
|
- [[#install][Install]]
|
|
|
|
- [[#configuration][Configuration]]
|
|
|
|
- [[#location][Location]]
|
2019-10-13 05:27:17 +00:00
|
|
|
- [[#macos-location][macOS Location]]
|
2017-12-21 17:27:23 +00:00
|
|
|
- [[#theme-changer][Theme-changer]]
|
|
|
|
- [[#sunshine-weather-forecast][Sunshine (weather forecast)]]
|
2018-12-05 03:03:03 +00:00
|
|
|
- [[#key-bindings][Key bindings]]
|
2017-05-22 14:16:12 +00:00
|
|
|
- [[#weather][Weather]]
|
2015-06-21 14:42:44 +00:00
|
|
|
|
|
|
|
* Description
|
2017-12-21 17:27:23 +00:00
|
|
|
This layer offers location sensitive adjustments to Emacs.
|
2015-06-21 14:42:44 +00:00
|
|
|
|
2017-12-21 17:27:23 +00:00
|
|
|
** Features:
|
|
|
|
- Supports the following adjustments:
|
|
|
|
- Automatic switching between light (day) and dark (night) themes via [[https://github.com/hadronzoo/theme-changer][theme-changer]]
|
|
|
|
- Local weather forecast via [[https://github.com/aaronbieber/sunshine.el/blob/master/sunshine.el][sunshine]]
|
2019-10-13 05:27:17 +00:00
|
|
|
- Integration with macOS's CoreLocation service via [[https://github.com/purcell/osx-location][osx-location]]
|
2017-12-21 17:27:23 +00:00
|
|
|
- Manual location setting via variables in your dotfile
|
2015-06-21 14:42:44 +00:00
|
|
|
|
|
|
|
* Install
|
2016-01-06 05:21:55 +00:00
|
|
|
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
2017-07-29 18:41:15 +00:00
|
|
|
add =geolocation= to the existing =dotspacemacs-configuration-layers= list in
|
|
|
|
this file.
|
2015-06-21 14:42:44 +00:00
|
|
|
|
|
|
|
All services are disable by default. To enable all, or some of them, add instead
|
|
|
|
something like this:
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2015-10-14 03:35:56 +00:00
|
|
|
(geolocation :variables
|
2015-10-19 20:08:56 +00:00
|
|
|
geolocation-enable-automatic-theme-changer t
|
|
|
|
geolocation-enable-location-service t
|
|
|
|
geolocation-enable-weather-forecast t)
|
2015-06-21 14:42:44 +00:00
|
|
|
#+END_SRC
|
|
|
|
|
2015-10-14 03:35:56 +00:00
|
|
|
* Configuration
|
|
|
|
** Location
|
2017-12-21 17:27:23 +00:00
|
|
|
Set location manually by setting the following variables in your dotfile:
|
2015-06-21 14:42:44 +00:00
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(setq calendar-location-name "Barcelona, Spain"
|
|
|
|
calendar-latitude 41.23
|
|
|
|
calendar-longitude 1.80)
|
|
|
|
#+END_SRC
|
|
|
|
|
2019-10-13 05:27:17 +00:00
|
|
|
** macOS Location
|
|
|
|
MacOS users can take advantage of automatic geographical discovery using the OS's
|
2017-07-30 13:00:35 +00:00
|
|
|
CoreLocation system service, implemented as a long running background process.
|
|
|
|
In order to enable it, set =geolocation-enable-location-service= to =t= as
|
|
|
|
explained in installation instructions.
|
|
|
|
|
|
|
|
A helper script will need to be given proper access first time this layer is
|
|
|
|
activated.
|
|
|
|
|
|
|
|
[[file:img/emacs-location-helper.jpg]]
|
2015-06-21 14:42:44 +00:00
|
|
|
|
2017-12-21 17:27:23 +00:00
|
|
|
** Theme-changer
|
2019-05-26 20:58:52 +00:00
|
|
|
This layer implement a simple "theme changer" which, when enabled, will switch
|
2015-10-19 20:08:56 +00:00
|
|
|
between first two themes the user has setup in ~dotspacemacs-themes~. First
|
2018-05-24 02:12:30 +00:00
|
|
|
theme listed will be used as the light variant, while the second as the dark.
|
2015-10-19 20:08:56 +00:00
|
|
|
Other themes will be ignored by this layer, though they are still available for
|
|
|
|
cycling, etc.
|
2015-06-21 14:42:44 +00:00
|
|
|
|
2017-07-30 13:00:35 +00:00
|
|
|
Note that =theme-changer= *requires* location to be set.
|
|
|
|
|
2017-12-21 17:27:23 +00:00
|
|
|
** Sunshine (weather forecast)
|
2015-10-19 20:08:56 +00:00
|
|
|
Sunshine display local weather forecast.
|
|
|
|
|
2017-07-29 18:41:15 +00:00
|
|
|
Setup [[https://home.openweathermap.org/users/sign_in][OpenWeatherMap]] API key. Set ~sunshine-appid~ to some hash string from the
|
|
|
|
openweathermap website. You need to sign up to the website to get a API key.
|
2015-10-19 20:08:56 +00:00
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(setq sunshine-appid "your-apikey")
|
|
|
|
#+END_SRC
|
|
|
|
|
2017-07-29 18:41:15 +00:00
|
|
|
Configure your location by setting the variable sunshine-location. You can
|
2019-05-26 20:58:52 +00:00
|
|
|
provide a string, like "New York, NY" or a ZIP code, like "90210". This variable
|
2017-07-29 18:41:15 +00:00
|
|
|
is available through the Customize facility.
|
|
|
|
|
|
|
|
When specifying a ZIP code, you may receive results from a foreign country. This
|
|
|
|
is due to weird behavior from OpenWeatherMap. To resolve this, append a comma
|
|
|
|
and the country code after the ZIP code. Note the lack of a space in the example
|
|
|
|
below.
|
2015-10-19 20:08:56 +00:00
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2018-09-19 03:54:47 +00:00
|
|
|
(setq sunshine-location "90210,USA")
|
2015-10-19 20:08:56 +00:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
It will use the imperial unit system by default. To switch to metric, add
|
|
|
|
~sunshine-units 'metric~ to the variables list for this layer, or add this.
|
2015-06-21 14:42:44 +00:00
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(setq sunshine-units 'metric)
|
|
|
|
#+END_SRC
|
|
|
|
|
2015-10-19 20:08:56 +00:00
|
|
|
Weather forecast icons are disabled by default, and can be toggled by pressing
|
2019-05-26 20:58:52 +00:00
|
|
|
`i' within this mode's main buffer.
|
2015-10-19 20:08:56 +00:00
|
|
|
|
2019-05-26 20:58:52 +00:00
|
|
|
To display weather forecast icons by default ("pretty mode"), add
|
2015-10-19 20:08:56 +00:00
|
|
|
~sunshine-show-icons t~ to the variables list for this layer, or add this:
|
2015-06-21 14:42:44 +00:00
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(setq sunshine-show-icons t)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
[[file:img/emacs-sunshine.jpg]]
|
|
|
|
|
2018-12-05 03:03:03 +00:00
|
|
|
* Key bindings
|
2015-10-14 03:35:56 +00:00
|
|
|
** Weather
|
2020-06-24 20:50:11 +00:00
|
|
|
|
2020-06-21 22:04:52 +00:00
|
|
|
| Key binding | Description |
|
|
|
|
|---------------+-----------------------------------------------|
|
|
|
|
| ~SPC a t g w~ | Display pretty weather forecast |
|
|
|
|
| ~SPC a t g W~ | Display quick weather forecast in mini buffer |
|