diff options
-rw-r--r-- | exwm-manage.el | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/exwm-manage.el b/exwm-manage.el index c344c4cfb1d7..d1eeaa7c876c 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -234,6 +234,23 @@ Override current hinds if FORCE is non-nil." (elt value 2))) ;MotifWmHints.decorations (setq exwm--mwm-hints-decorations nil)))))))) +(defun exwm-manage--update-default-directory (id) + "Update the `default-directory' of X window ID. +Sets the `default-directory' of the EXWM buffer associated with X window to +match its current working directory. + +This only works when procfs is mounted, which may not be the case on some BSDs." + (with-current-buffer (exwm--id->buffer id) + (if-let* ((response (xcb:+request-unchecked+reply exwm--connection + (make-instance 'xcb:ewmh:get-_NET_WM_PID + :window id))) + (pid (slot-value response 'value)) + (cwd (file-symlink-p (format "/proc/%d/cwd" pid))) + ((file-accessible-directory-p cwd))) + (setq default-directory cwd) + (setq default-directory (expand-file-name "~/"))))) + + (defun exwm-manage--set-client-list () "Set _NET_CLIENT_LIST." (exwm--log) @@ -400,6 +417,7 @@ Override current hinds if FORCE is non-nil." (setq exwm-workspace--switch-history-outdated t) (exwm--update-desktop id) (exwm-manage--update-ewmh-state id) + (exwm-manage--update-default-directory id) (when (or (plist-get exwm--configurations 'fullscreen) (exwm-layout--fullscreen-p)) (setq exwm--ewmh-state (delq xcb:Atom:_NET_WM_STATE_FULLSCREEN |