Move the monitor function to X module
This commit is contained in:
parent
f1e0d5b052
commit
8d67672291
|
@ -21,11 +21,46 @@
|
||||||
;;
|
;;
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
(require 'seq)
|
||||||
|
|
||||||
|
(defvar fg42/monitors nil
|
||||||
|
"A plist containing monitor resolution profiles.
|
||||||
|
for example:
|
||||||
|
'(:hdmi-only
|
||||||
|
(\"--output HDMI-1 --primary\"
|
||||||
|
\"--output eDP-1 --off\")
|
||||||
|
:hdmi-main
|
||||||
|
(\"--output HDMI-1 --primary\"
|
||||||
|
\"--output eDP-1 --mode 1920x1080 --left-of HDMI-1\")
|
||||||
|
:edp-only
|
||||||
|
(\"--output eDP-1 --mode 1920x1080\"
|
||||||
|
\"--output HDMI-1 --off\"))")
|
||||||
|
|
||||||
|
|
||||||
(defun fg42/get-x11-selection-text ()
|
(defun fg42/get-x11-selection-text ()
|
||||||
"Return the X11 selection paste text."
|
"Return the X11 selection paste text."
|
||||||
(interactive)
|
(interactive)
|
||||||
(x-get-selection 'PRIMARY))
|
(gui-get-selection 'PRIMARY))
|
||||||
|
|
||||||
|
|
||||||
|
(defun monitor-profiles ()
|
||||||
|
"Parse the `fg42/monitors' profiles."
|
||||||
|
(mapcar
|
||||||
|
#'car
|
||||||
|
(seq-partition fg42/monitors 2)))
|
||||||
|
|
||||||
|
(defun monitor (mon)
|
||||||
|
"Switch to the given monitor resolution profile MON."
|
||||||
|
(interactive
|
||||||
|
(list (completing-read
|
||||||
|
"Monitor Profole: "
|
||||||
|
(monitor-profiles))))
|
||||||
|
|
||||||
|
(let ((cmd (mapconcat (lambda (x) (format "xrandr %s" x))
|
||||||
|
(plist-get fg42/monitors (intern (format "%s" mon)))
|
||||||
|
" && ")))
|
||||||
|
(message "Setting monitor profile: %s" cmd)
|
||||||
|
(async-shell-command cmd "*xrandr*")))
|
||||||
|
|
||||||
(provide 'fg42/x)
|
(provide 'fg42/x)
|
||||||
;;; x.el ends here
|
;;; x.el ends here
|
||||||
|
|
Loading…
Reference in New Issue