2015-10-19 20:08:56 +00:00
|
|
|
;;; packages.el --- geolocation configuration File for Spacemacs
|
2015-06-21 14:42:44 +00:00
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 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.
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2015-06-21 14:42:44 +00:00
|
|
|
|
2015-10-14 03:35:56 +00:00
|
|
|
(setq geolocation-packages
|
2017-06-13 08:45:05 +00:00
|
|
|
'(
|
2017-07-29 18:53:13 +00:00
|
|
|
(osx-location :toggle (and geolocation-enable-location-service
|
|
|
|
(spacemacs/system-is-mac)))
|
2017-06-13 08:45:05 +00:00
|
|
|
popwin
|
2017-07-29 18:53:13 +00:00
|
|
|
(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
|
|
|
|
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
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-10-19 20:08:56 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2017-07-29 18:53:13 +00:00
|
|
|
(add-hook 'osx-location-changed-hook 'spacemacs//osx-location-changed)
|
2017-06-13 08:45:05 +00:00
|
|
|
(osx-location-watch))))
|
2015-10-19 20:08:56 +00:00
|
|
|
|
|
|
|
(defun geolocation/init-rase ()
|
|
|
|
(use-package rase
|
2018-03-04 04:37:53 +00:00
|
|
|
: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)
|
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))
|
2017-06-13 08:45:05 +00:00
|
|
|
(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-19 20:08:56 +00:00
|
|
|
:commands (sunshine-forecast sunshine-quick-forecast)
|
2015-06-21 14:42:44 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2020-06-21 22:04:52 +00:00
|
|
|
(spacemacs/declare-prefix "atg" "geolocation")
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys
|
2020-06-21 22:04:52 +00:00
|
|
|
"atgw" 'sunshine-forecast
|
|
|
|
"atgW" '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)
|
|
|
|
|
2019-10-13 05:27:17 +00:00
|
|
|
;; just in case location was not set by user, or on macOS,
|
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)
|
2015-10-19 20:08:56 +00:00
|
|
|
(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
|
|
|
|
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
|
2017-06-12 13:23:48 +00:00
|
|
|
:init
|
2015-10-14 03:35:56 +00:00
|
|
|
(progn
|
2017-06-13 08:45:05 +00:00
|
|
|
(spacemacs/defer-until-after-user-config #'geolocation//activate-theme-changer))))
|
2015-10-14 09:13:01 +00:00
|
|
|
|
2020-07-03 19:44:51 +00:00
|
|
|
(defun geolocation/pre-init-popwin ()
|
|
|
|
"Pin the weather forecast to the bottom window"
|
|
|
|
(spacemacs|use-package-add-hook popwin
|
|
|
|
:post-config
|
|
|
|
(push '("*Sunshine*" :dedicated t :position bottom)
|
|
|
|
popwin:special-display-config)))
|