Skip to content

exwm can't handle unplugging monitor? #133

@xpusostomos

Description

@xpusostomos

So I thought I'd finally come to understand more or less how exwm sets up monitors, but I'm still running into issues. Specifically, I've got my laptop and an external monitor, and I've got it setup so the monitor is the primary device. Often when I unplug the laptop and plug in again, or if the monitor turns off, and I turn it on again, everything is flipped, everything that was on the laptop is on the monitor and vice versa.

So what I've found is if I manually run my config functions and then manually run exwm-randr-refresh, then it corrects itself, but surely that shouldn't be necessary?

I've got a screen setup function, that mostly relies on autorandr..., except that it figures out from xrandr which is the primary to setup the workspaces... whichever screen is primary is workspace 0, and the other one is 1 ...

(defun cc/exwm-randr-screen-change ()
  (setq cc/primary (process-lines "sh" "-c" "xrandr | sed -n  's:\\([^ ]\\) connected primary.*:\\1:p'"))
  (setq cc/secondary (process-lines "sh" "-c" "xrandr | grep -v 'connected primary' | sed -n  's:\\([^ ]\\) connected .*:\\1:p'"))
  (setq cc/screen-list (append cc/primary cc/secondary))
  (setq exwm-randr-workspace-monitor-alist (cc/build-workspaces cc/screen-list 0))
  (setq exwm-randr-workspace-monitor-plist (list-utils-flatten exwm-randr-workspace-monitor-alist))
  (start-process-shell-command "autorandr" nil "autorandr --change" ) 
  (exwm-randr-refresh))

I add that as my screen change hook:

(add-hook 'exwm-randr-screen-change-hook #'cc/exwm-randr-screen-change)

Then I unplug my monitor and plug it in, and everything is flipped between my monitors. But if I manually run
M-x eval-expression (cc/exwm-randr-screen-change)

then everything is corrected. Shouldn't the fact this is a hook mean I don't have to run it manually?

BTW, am I supposed to call exwm-randr-refresh in my screen change hook, or does exwm do that for me usually?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions