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
|
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
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2021-12-17 18:05:18 +01:00
|
|
|
;; TODO(wpcarro): Consider integrating this with Nix and depot instead of
|
|
|
|
;; denormalizing the state.
|
2020-09-01 11:17:43 +02:00
|
|
|
(defconst device-hostname->device
|
2021-10-24 01:46:01 +02:00
|
|
|
'(("zeno.lon.corp.google.com" . work-desktop-lon)
|
|
|
|
("wpcarro.svl.corp.google.com" . work-desktop-svl)
|
2021-12-17 18:05:18 +01:00
|
|
|
("seneca" . work-laptop)
|
|
|
|
("marcus" . personal-laptop)
|
|
|
|
("diogenes" . personal-vm))
|
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."
|
2021-10-24 01:46:01 +02:00
|
|
|
(-contains? '(work-desktop-lon
|
|
|
|
work-desktop-svl)
|
|
|
|
(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."
|
2021-10-24 01:46:01 +02:00
|
|
|
(-contains? '(work-desktop-lon
|
|
|
|
work-desktop-svl
|
|
|
|
work-laptop)
|
|
|
|
(device-classify)))
|
2020-04-02 15:50:18 +02:00
|
|
|
|
2021-12-17 18:05:18 +01:00
|
|
|
(defun device-laptop? ()
|
|
|
|
"Return t if the current device is a laptop."
|
|
|
|
(-contains? '(work-laptop personal-laptop) (device-classify)))
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
(provide 'device)
|
|
|
|
;;; device.el ends here
|