This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+tools/geolocation/packages.el

90 lines
3 KiB
EmacsLisp
Raw Normal View History

;;; packages.el --- geolocation configuration File for Spacemacs
2015-06-21 14:42:44 +00:00
;;
2018-01-04 07:00:25 +00:00
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
2015-06-21 14:42:44 +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
(setq geolocation-packages
2017-06-13 08:45:05 +00:00
'(
(osx-location :toggle (and geolocation-enable-location-service
(spacemacs/system-is-mac)))
2017-06-13 08:45:05 +00:00
popwin
(rase :toggle (and geolocation-enable-location-service
(spacemacs/system-is-mac)))
2017-06-13 08:45:05 +00:00
(sunshine :toggle geolocation-enable-weather-forecast)
(theme-changer :toggle geolocation-enable-automatic-theme-changer)
))
2015-06-21 14:42:44 +00:00
(defun geolocation/init-osx-location ()
2015-06-21 14:42:44 +00:00
"Initialize osx-location"
(use-package osx-location
:defer t
:init
(progn
(add-hook 'osx-location-changed-hook 'spacemacs//osx-location-changed)
2017-06-13 08:45:05 +00:00
(osx-location-watch))))
(defun geolocation/init-rase ()
(use-package rase
:defer t
2015-06-21 14:42:44 +00:00
:init
(progn
2017-06-13 08:45:05 +00:00
(add-hook 'osx-location-changed-hook 'spacemacs//osx-location-changed-rase)
(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))
2017-06-13 08:45:05 +00:00
(rase-start t))))
2015-06-21 14:42:44 +00:00
(defun geolocation/init-sunshine ()
2015-06-21 14:42:44 +00:00
"Initialize sunshine"
(use-package sunshine
:commands (sunshine-forecast sunshine-quick-forecast)
2015-06-21 14:42:44 +00:00
:init
(progn
(spacemacs/set-leader-keys
2015-06-21 14:42:44 +00:00
"aw" 'sunshine-forecast
"aW" 'sunshine-quick-forecast))
2015-06-21 14:42:44 +00:00
:config
(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,
2017-06-13 08:45:05 +00:00
;; if wasn't set up automatically, will not work with Emacs'
;; default for `calendar-location-name'
(unless (boundp 'sunshine-location)
(setq sunshine-location (format "%s, %s"
calendar-latitude
2017-06-13 08:45:05 +00:00
calendar-longitude))))))
2015-06-21 14:42:44 +00:00
(defun geolocation/init-theme-changer ()
2015-06-21 14:42:44 +00:00
"Initialize theme-changer"
(use-package theme-changer
:init
(progn
2017-06-13 08:45:05 +00:00
(spacemacs/defer-until-after-user-config #'geolocation//activate-theme-changer))))
(defun geolocation/post-init-popwin ()
;; Pin the weather forecast to the bottom window
(push '("*Sunshine*" :dedicated t :position bottom)
popwin:special-display-config))