2019-10-09 13:13:56 +02:00
|
|
|
;;; display.el --- Working with single or multiple displays -*- lexical-binding: t -*-
|
|
|
|
;; Author: William Carroll <wpcarro@gmail.com>
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;; Mostly wrappers around xrandr.
|
|
|
|
;;
|
|
|
|
;; TODO: Look into autorandr to see if it could be useful.
|
|
|
|
;;
|
|
|
|
;; Troubleshooting:
|
|
|
|
;; The following commands help me when I (infrequently) interact with xrandr.
|
|
|
|
;; - xrandr --listmonitors
|
|
|
|
;; - xrandr --query
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2019-12-23 18:31:42 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Dependencies
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(require 'prelude)
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Constants
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2020-01-13 11:27:26 +01:00
|
|
|
(defconst display/install-kbds? t
|
|
|
|
"When t, install the keybindings defined in this module.")
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;; TODO: Consider if this logic should be conditioned by `device/work-laptop?'.
|
2020-01-11 21:01:57 +01:00
|
|
|
(defconst display/laptop-monitor "eDP1"
|
2019-10-09 13:13:56 +02:00
|
|
|
"The xrandr identifier for my primary screen (on work laptop).")
|
|
|
|
|
2020-01-11 21:01:57 +01:00
|
|
|
;; TODO: Why is HDMI-1, eDP-1 sometimes and HDMI1, eDP1 other times.
|
|
|
|
(defconst display/4k-monitor "HDMI1"
|
2019-10-09 13:13:56 +02:00
|
|
|
"The xrandr identifer for my 4K monitor.")
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Library
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
(defun display/enable-4k ()
|
|
|
|
"Attempt to connect to my 4K monitor."
|
|
|
|
(interactive)
|
2019-12-23 18:31:42 +01:00
|
|
|
(prelude/start-process
|
2020-01-11 21:01:57 +01:00
|
|
|
:name "display/enable-4k"
|
|
|
|
:command (string/format
|
|
|
|
"xrandr --output %s --above %s --primary --auto --dpi 144"
|
|
|
|
display/4k-monitor
|
|
|
|
display/laptop-monitor)))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
(defun display/disable-4k ()
|
|
|
|
"Disconnect from the 4K monitor."
|
|
|
|
(interactive)
|
2019-12-23 18:31:42 +01:00
|
|
|
(prelude/start-process
|
|
|
|
:name "display/disable-4k"
|
2020-01-11 21:01:57 +01:00
|
|
|
:command (string/format "xrandr --output %s --off"
|
|
|
|
display/4k-monitor)))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-01-13 11:27:26 +01:00
|
|
|
(when display/install-kbds?
|
|
|
|
(general-define-key
|
|
|
|
:prefix "<SPC>"
|
|
|
|
:states '(normal)
|
|
|
|
"D0" #'display/disable-4k
|
|
|
|
"D1" #'display/enable-4k))
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
(provide 'display)
|
|
|
|
;;; display.el ends here
|