exwm icon indicating copy to clipboard operation
exwm copied to clipboard

exwm-input-global-keys bindings on s- prefix do not work globally

Open holtzermann17 opened this issue 3 years ago • 2 comments

I've configured exwm-input-global-keys through the Configure option.

For example s-s should take a screenshot. These bindings work ONLY when I am in "native" Emacs buffers, however (not, e.g., inside Firefox). Can you help me understand why and fix things so that the global bindings work globally?

I'll note that M-x and C-x C-f binding do work globally!

 '(exwm-input-global-keys
   '(([8388723]
      lambda nil
      (interactive)
      (let
          ((path
            (concat "~/Documents/Screenshot-"
                    (format-time-string "%Y-%m-%d,%H:%M:%S")
                    ".png")))
        (start-process-shell-command "scrot" nil
                                     (concat "scrot -u -f " path))
        (message
         (concat "Screenshot saved to " path))))
     ([8388723]
      lambda nil
      (interactive)
      (let
          ((path
            (concat "~/Documents/Screenshot-"
                    (format-time-string "%Y-%m-%d,%H:%M:%S")
                    ".png")))
        (start-process-shell-command "scrot" nil
                                     (concat "scrot -s -f " path))
        (message
         (concat "Screenshot saved to " path))))
     ([8388722]
      . exwm-reset)
     ([8388724]
      . exwm-workspace-switch-to-last)
     ([8388727]
      . exwm-workspace-switch)
     ([8388646]
      lambda
      (command)
      (interactive
       (list
        (read-shell-command "$ ")))
      (start-process-shell-command command nil command))))

holtzermann17 avatar Mar 06 '21 22:03 holtzermann17

I have found a work-around, though there may still be an issue to look into here.

I was setting my keyboard map inside my Emacs init file:

(shell-command "xkbcomp /home/joe/kinesis.xkb $DISPLAY > /dev/null 2>&1")

When I remove that line and set the bindings interactively after EXWM has loaded, things work fine.

(defun kinesis ()
  (interactive)
  (shell-command "xkbcomp /home/joe/kinesis.xkb $DISPLAY > /dev/null 2>&1"))

Maybe there's a better place to put this command in the initialization cycle so that it will run automatically and still allow EXWM to do its thing?

holtzermann17 avatar Mar 06 '21 23:03 holtzermann17

Have you defined S-s in a global context?

(exwm-input-set-key (kbd "S-s") (lambda () (interactive) (my/do-screenshot)))

Or perhaps create map to a specific key:

    (setq exwm-input-simulation-keys
          '(((kbd "S-s") . (kbd "<print>")))   ;; printscreen

mtekman avatar Mar 08 '21 10:03 mtekman