2019-10-09 13:13:56 +02:00
|
|
|
;;; device.el --- Physical device information -*- lexical-binding: t -*-
|
2020-09-01 11:17:43 +02:00
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;; Author: William Carroll <wpcarro@gmail.com>
|
2020-09-01 11:17:43 +02:00
|
|
|
;; Version: 0.0.1
|
|
|
|
;; URL: https://git.wpcarro.dev/wpcarro/briefcase
|
2020-09-01 14:44:18 +02:00
|
|
|
;; Package-Requires: ((emacs "25.1"))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;; Functions for querying device information.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2020-09-01 14:44:18 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Dependencies
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
(require 'dash)
|
2020-09-02 15:00:43 +02:00
|
|
|
(require 'al)
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Library
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defconst device-hostname->device
|
2020-01-29 13:38:19 +01:00
|
|
|
'(("zeno.lon.corp.google.com" . work-desktop)
|
|
|
|
("seneca" . work-laptop))
|
2019-10-09 13:13:56 +02:00
|
|
|
"Mapping hostname to a device symbol.")
|
|
|
|
|
|
|
|
;; TODO: Should I generate these predicates?
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun device-classify ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Return the device symbol for the current host or nil if not supported."
|
2020-09-02 15:00:43 +02:00
|
|
|
(al-get system-name device-hostname->device))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun device-work-laptop? ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Return t if current device is work laptop."
|
|
|
|
(equal 'work-laptop
|
2020-09-01 11:17:43 +02:00
|
|
|
(device-classify)))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun device-work-desktop? ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Return t if current device is work desktop."
|
|
|
|
(equal 'work-desktop
|
2020-09-01 11:17:43 +02:00
|
|
|
(device-classify)))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun device-corporate? ()
|
2020-04-02 15:50:18 +02:00
|
|
|
"Return t if the current device is owned by my company."
|
2020-09-01 11:17:43 +02:00
|
|
|
(or (device-work-laptop?) (device-work-desktop?)))
|
2020-04-02 15:50:18 +02:00
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
(provide 'device)
|
|
|
|
;;; device.el ends here
|