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/funcs.el

56 lines
2.3 KiB
EmacsLisp
Raw Normal View History

;;; funcs.el --- geolocation functions File for Spacemacs
2017-06-13 08:45:05 +00:00
;;
2021-03-22 20:11:29 +00:00
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
2017-06-13 08:45:05 +00:00
;;
;; Author: Eivind Fonn <evfonn@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;; 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/>.
2017-06-13 08:45:05 +00:00
(defun spacemacs//osx-location-changed ()
(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-used-p 'geolocation) location-changed-p)
2017-06-13 08:45:05 +00:00
(message "Location changed %s %s (restarting rase-timer)" calendar-latitude calendar-longitude)
(rase-start t))))
(defun spacemacs//osx-location-changed-rase ()
(setq calendar-latitude osx-location-latitude
calendar-longitude osx-location-longitude)
(unless (bound-and-true-p calendar-location-name)
(setq calendar-location-name
(format "%s, %s"
osx-location-latitude
osx-location-longitude))))
(defun geolocation//activate-theme-changer ()
(unless (bound-and-true-p calendar-longitude)
(user-error "calendar-longitude is not set"))
(unless (bound-and-true-p calendar-latitude)
(user-error "calendar-latitude is not set"))
2017-06-13 08:45:05 +00:00
(when (> (length dotspacemacs-themes) 1)
(change-theme (nth 0 dotspacemacs-themes)
(nth 1 dotspacemacs-themes))))