about summary refs log tree commit diff
path: root/exwm-randr.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2015-11-01T02·54+0800
committerChris Feng <chris.w.feng@gmail.com>2015-11-01T03·06+0800
commit9ee1c9bb175b164c7146cdf51ab91642d08a3ed9 (patch)
tree2508490bb4a6bd62d5c44765f660960634ea179c /exwm-randr.el
parent45c24eac7a1f9eab5e4a5244e2d14f9f35aa69fa (diff)
Add hook run when screen changes
* exwm-randr.el (exwm-randr-screen-change-hook): New hook.
  (exwm-randr--init): Run the new hook in the event handler of
  ScreenChangeNotify.
Diffstat (limited to 'exwm-randr.el')
-rw-r--r--exwm-randr.el20
1 files changed, 15 insertions, 5 deletions
diff --git a/exwm-randr.el b/exwm-randr.el
index 26d15dcb7d99..1ac8f29e1e1b 100644
--- a/exwm-randr.el
+++ b/exwm-randr.el
@@ -25,15 +25,21 @@
 ;; tools such as xrandr(1) to properly configure RandR first. This dependency
 ;; may be removed in the future, but more work is needed before that.
 
-;; To use this module, first load/enable it and properly configure the variable
-;; `exwm-randr-workspace-output-plist':
+;; To use this module, load, enable it and configure
+;; `exwm-randr-workspace-output-plist' and `exwm-randr-screen-change-hook'
+;; as follows:
+;;
 ;;   (require 'exwm-randr)
 ;;   (setq exwm-randr-workspace-output-plist '(0 "VGA1"))
+;;   (add-hook 'exwm-randr-screen-change-hook
+;;             (lambda ()
+;;               (start-process-shell-command
+;;                "xrandr" nil "xrandr --output VGA1 --left-of LVDS1 --auto")))
 ;;   (exwm-randr-enable)
-;; Then configure RandR with 'xrandr':
-;;   $ xrandr --output VGA1 --left-of LVDS1 --auto
+;;
 ;; With above lines, workspace 0 should be assigned to the output named "VGA1",
-;; staying at the left of other workspaces on the output "LVDS1".
+;; staying at the left of other workspaces on the output "LVDS1".  Please refer
+;; to xrandr(1) for the configuration of RandR.
 
 ;; References:
 ;; + RandR (http://www.x.org/archive/X11R7.7/doc/randrproto/randrproto.txt)
@@ -109,6 +115,9 @@
                        :data (vconcat viewports)))
     (xcb:flush exwm--connection)))
 
+(defvar exwm-randr-screen-change-hook nil
+  "Normal hook run when screen changes.")
+
 (defun exwm-randr--init ()
   "Initialize RandR extension and EXWM RandR module."
   (if (= 0 (slot-value (xcb:get-extension-data exwm--connection 'xcb:randr)
@@ -125,6 +134,7 @@
         (xcb:+event exwm--connection 'xcb:randr:ScreenChangeNotify
                     (lambda (_data _synthetic)
                       (exwm--log "(RandR) ScreenChangeNotify")
+                      (run-hooks 'exwm-randr-screen-change-hook)
                       (exwm-randr--refresh)))
         ;; (xcb:+event exwm--connection 'xcb:randr:Notify
         ;;             (lambda (_data _synthetic)