provide 'cce/display-test-functions) (
Calculating the display density is a pain in the ass because it's easier to parse xrandr output than it is to integrate with libXrandr. I guess I could write an elisp wrapper for it, but I would rather not right now. open threads
defun cce/external-display-dpis ()
("Returns a list of integers, the DPI of the connected external Display Port displays. assumes square pixels, sorry."
let (results (xrandr-buffer (get-buffer-create " *xrandr*")))
(
(with-current-buffer xrandr-buffer
(erase-buffer)"xrandr" nil xrandr-buffer)
(call-process-shell-command
(goto-char (point-min))nil)
(setq-local results "^\\([^e][a-zA-Z]+\\(-?[0-9]+\\)+\\)" nil t)
(while (re-search-forward
(when-let* ((eol (save-excursion (end-of-line) (point)))1))
(display-name (match-string "connected \\(primary \\)?\\([0-9]+\\)x\\([0-9]+\\)" eol t))
(is-connected (re-search-forward 3)))
(pixels (string-to-number (match-string "\\([0-9]+\\)mm x \\([0-9]+\\)mm" eol))
(has-physical (re-search-forward 2)))
(physical (string-to-number (match-string if (equal 0 physical)
(dpi (140
floor (* 25.4 (/ (float pixels) physical))))))
('results (cons display-name dpi))))
(add-to-list
results)))
defun cce/external-display-connected ()
("returns t if there are external displayport monitors connected."
let ((dpis (cce/external-display-dpis)))
(> (length dpis) 0)))
(
defun cce/connected-displays ()
("Returns a list of displays currently connceted"
append (list "eDP-1")
(mapcar
(lambda (cons)
(car cons))
(
(cce/external-display-dpis))))
defun cce/exwm-connected-displays ()
("Return a list of displays for [`exwm-randr-workspace-monitor-plist']"
apply #'append
(lambda (elt idx)
(seq-map-indexed (list idx elt))
( (cce/connected-displays))))