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
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2020-01-15 23:14:51 +01:00
|
|
|
;; TODO: Debug why something this scales to 4k appropriately and other times it
|
|
|
|
;; doesn't.
|
2019-10-09 13:13:56 +02:00
|
|
|
(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
|
2020-02-02 13:16:27 +01:00
|
|
|
"xrandr --output %s --above %s --primary --auto --size 3840x2160 --rate 30.00 --dpi 144"
|
2020-01-11 21:01:57 +01:00
|
|
|
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-16 02:18:32 +01:00
|
|
|
(defun display/enable-laptop ()
|
|
|
|
"Turn the laptop monitor off.
|
|
|
|
Sometimes this is useful when I'm sharing my screen in a Google Hangout and I
|
|
|
|
only want to present one of my monitors."
|
|
|
|
(interactive)
|
|
|
|
(prelude/start-process
|
|
|
|
:name "display/disable-laptop"
|
|
|
|
:command (string/format "xrandr --output %s --auto"
|
|
|
|
display/laptop-monitor)))
|
|
|
|
|
|
|
|
(defun display/disable-laptop ()
|
|
|
|
"Turn the laptop monitor off.
|
|
|
|
Sometimes this is useful when I'm sharing my screen in a Google Hangout and I
|
|
|
|
only want to present one of my monitors."
|
|
|
|
(interactive)
|
|
|
|
(prelude/start-process
|
|
|
|
:name "display/disable-laptop"
|
|
|
|
:command (string/format "xrandr --output %s --off"
|
|
|
|
display/laptop-monitor)))
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Keybindings
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2020-01-13 11:27:26 +01:00
|
|
|
(when display/install-kbds?
|
2020-01-16 02:18:32 +01:00
|
|
|
(general-define-key
|
|
|
|
:prefix "<SPC>"
|
|
|
|
:states '(normal)
|
|
|
|
"d0" #'display/disable-laptop
|
|
|
|
"d1" #'display/enable-laptop)
|
2020-01-13 11:27:26 +01:00
|
|
|
(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
|