2015-10-19 20:08:56 +00:00
|
|
|
;;; packages.el --- geolocation configuration File for Spacemacs
|
2015-06-21 14:42:44 +00:00
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-06-21 14:42:44 +00:00
|
|
|
;;
|
2015-10-19 20:08:56 +00:00
|
|
|
;; Author: Uri Sharf <uri.sharf@me.com>
|
|
|
|
;; URL: https://github.com/usharf/spacemacs
|
2015-06-21 14:42:44 +00:00
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-10-14 03:35:56 +00:00
|
|
|
(setq geolocation-packages
|
2015-06-21 14:42:44 +00:00
|
|
|
'(
|
|
|
|
osx-location
|
2015-10-19 20:08:56 +00:00
|
|
|
popwin
|
|
|
|
rase
|
2015-06-21 14:42:44 +00:00
|
|
|
sunshine
|
|
|
|
theme-changer
|
|
|
|
))
|
|
|
|
|
2015-10-14 03:35:56 +00:00
|
|
|
(defun geolocation/init-osx-location ()
|
2015-06-21 14:42:44 +00:00
|
|
|
"Initialize osx-location"
|
|
|
|
(use-package osx-location
|
2015-10-19 20:08:56 +00:00
|
|
|
:if geolocation-enable-location-service
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(when (spacemacs/system-is-mac)
|
|
|
|
(add-hook 'osx-location-changed-hook
|
|
|
|
(lambda ()
|
|
|
|
(let ((location-changed-p nil)
|
|
|
|
(_longitude (/ (truncate (* osx-location-longitude 10)) 10.0)) ; one decimal point, no rounding
|
|
|
|
(_latitdue (/ (truncate (* osx-location-latitude 10)) 10.0)))
|
|
|
|
(unless (equal (bound-and-true-p calendar-longitude) _longitude)
|
|
|
|
(setq calendar-longitude _longitude
|
|
|
|
location-changed-p t))
|
|
|
|
(unless (equal (bound-and-true-p calendar-latitude) _latitdue)
|
|
|
|
(setq calendar-latitude _latitdue
|
|
|
|
location-changed-p t))
|
|
|
|
(when (and (configuration-layer/layer-usedp 'geolocation) location-changed-p)
|
|
|
|
(message "Location changed %s %s (restarting rase-timer)" calendar-latitude calendar-longitude)
|
|
|
|
(rase-start t)
|
|
|
|
))))
|
|
|
|
(osx-location-watch)))))
|
|
|
|
|
|
|
|
(defun geolocation/init-rase ()
|
|
|
|
(use-package rase
|
|
|
|
:defer t
|
2015-06-21 14:42:44 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(add-hook 'osx-location-changed-hook
|
|
|
|
(lambda ()
|
|
|
|
(setq calendar-latitude osx-location-latitude
|
|
|
|
calendar-longitude osx-location-longitude)
|
2015-10-14 08:47:15 +00:00
|
|
|
(unless (bound-and-true-p calendar-location-name)
|
2015-06-21 14:42:44 +00:00
|
|
|
(setq calendar-location-name
|
2015-10-14 03:35:56 +00:00
|
|
|
(format "%s, %s"
|
|
|
|
osx-location-latitude
|
|
|
|
osx-location-longitude)))))
|
2015-10-19 20:08:56 +00:00
|
|
|
(osx-location-watch)
|
|
|
|
(defadvice rase-start (around test-calendar activate)
|
|
|
|
"Don't call `raise-start' if `calendar-latitude' or
|
|
|
|
`calendar-longitude' are not bound yet, or still nil.
|
|
|
|
|
|
|
|
This is setup this way because `rase.el' does not test these
|
|
|
|
values, and will fail under such conditions, when calling
|
|
|
|
`solar.el' functions.
|
|
|
|
|
|
|
|
Also, it allows users who enabled service such as `osx-location'
|
|
|
|
to not have to set these variables manually when enabling this layer."
|
|
|
|
(if (and (bound-and-true-p calendar-longitude)
|
|
|
|
(bound-and-true-p calendar-latitude))
|
|
|
|
ad-do-it))
|
|
|
|
(rase-start t)
|
|
|
|
)))
|
2015-06-21 14:42:44 +00:00
|
|
|
|
2015-10-14 03:35:56 +00:00
|
|
|
(defun geolocation/init-sunshine ()
|
2015-06-21 14:42:44 +00:00
|
|
|
"Initialize sunshine"
|
|
|
|
(use-package sunshine
|
2015-10-14 03:35:56 +00:00
|
|
|
:if geolocation-enable-weather-forecast
|
2015-10-19 20:08:56 +00:00
|
|
|
:commands (sunshine-forecast sunshine-quick-forecast)
|
2015-06-21 14:42:44 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys
|
2015-06-21 14:42:44 +00:00
|
|
|
"aw" 'sunshine-forecast
|
2015-10-19 20:08:56 +00:00
|
|
|
"aW" 'sunshine-quick-forecast))
|
2015-06-21 14:42:44 +00:00
|
|
|
:config
|
2015-10-19 20:08:56 +00:00
|
|
|
(progn
|
|
|
|
(evilified-state-evilify-map sunshine-mode-map
|
|
|
|
:mode sunshine-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "q") 'quit-window
|
|
|
|
(kbd "i") 'sunshine-toggle-icons)
|
|
|
|
|
|
|
|
;; 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)))
|
|
|
|
)))
|
2015-06-21 14:42:44 +00:00
|
|
|
|
2015-10-14 03:35:56 +00:00
|
|
|
(defun geolocation/init-theme-changer ()
|
2015-06-21 14:42:44 +00:00
|
|
|
"Initialize theme-changer"
|
|
|
|
(use-package theme-changer
|
2015-10-14 03:35:56 +00:00
|
|
|
:if geolocation-enable-automatic-theme-changer
|
2015-06-21 14:42:44 +00:00
|
|
|
:config
|
2015-10-14 03:35:56 +00:00
|
|
|
(progn
|
|
|
|
(when (> (length dotspacemacs-themes) 1)
|
|
|
|
(change-theme (nth 0 dotspacemacs-themes)
|
|
|
|
(nth 1 dotspacemacs-themes))))))
|
2015-10-14 09:13:01 +00:00
|
|
|
|
|
|
|
(defun geolocation/post-init-popwin ()
|
|
|
|
;; Pin the weather forecast to the bottom window
|
|
|
|
(push '("*Sunshine*" :dedicated t :position bottom)
|
|
|
|
popwin:special-display-config))
|