0

Instead running sudo su joe -s prime-run firefox in the shell I'd rather bind it to a key.

Yet, nothing happens on pressing M-n (while M-i works).

What am I doing wrong?

(setq exwm-input-global-keys
      `(
        ;; Working >> Run firefox
        ([?\M-i] . (lambda ()
                     (interactive)
                     (start-process "" nil "/usr/bin/firefox")))

        ;; Not working >> Run firefox on the GPU
        ([?\M-n] . (lambda ()
                     (interactive)
                     (start-process "" nil "/usr/bin/sudo su joe -s /usr/bin/prime-run /usr/bin/firefox")))
        )
      )
1
  • 1
    Check the docs for start-process: in yr GPU case, the third arg should be "/usr/bin/sudo" and the arguments for sudo provided as additional args to start-process. Feb 17, 2021 at 12:55

1 Answer 1

3

C-h f start-process

start-process is a compiled Lisp function in `subr.el'.

(start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS)

  Probably introduced at or before Emacs version 17.

Start a program in a subprocess.  Return the process object for it.
NAME is name for process.  It is modified if necessary to make it unique.
BUFFER is the buffer (or buffer name) to associate with the process.

Process output (both standard output and standard error streams)
goes at end of BUFFER, unless you specify a filter function to
handle the output.  BUFFER may also be nil, meaning that this
process is not associated with any buffer.

PROGRAM is the program file name.  It is searched for in `exec-path'
(which see).  If nil, just associate a pty with the buffer.  Remaining
arguments PROGRAM-ARGS are strings to give program as arguments.

So PROGRAM has to be the name of your executable, and then you pass its arguments as individual strings:

(start-process "" nil "/usr/bin/sudo" "su" "joe" "-s" "/usr/bin/prime-run" "/usr/bin/firefox")

In this case you might be better off using shell-command, that allows you to just pass in a commmand+args as a single string.

2
  • Calling make-process directly also allows specifying the command in a single go. It is also more flexible and makes it harder to forget about things like :connection-type.
    – Basil
    Feb 17, 2021 at 15:30
  • True. Emacs is not lacking in commands for doing things with subprocesses :-)
    – rpluim
    Feb 17, 2021 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.