2

I am using Sway/wlroots and I decided to switch to using terminal emacs for the forseeable future as there is no transparency in the xwayland version of emacs.

I previously bound emacs to run as a client to connect to my emacs daemon like so emacsclient -c -n -e '(switch-to-buffer nil)' so that upon a sway keystroke it will open a new emacsframe/window.

Basically, how do I do this with emacsclient -nw? my terminal of choice is termite and so i tried to replace the above with this termite -e 'emacsclient -nw' but emacs gets into a locked up state or doesnt launch at all.

Here's the error I get from invoking the previous command from another terminal:

me@laptop ~ % termite -e 'emacsclient -nw'
invalid color string: #

(termite:30425): GLib-WARNING **: 12:46:32.770: GChildWatchSource: Exit status of a child process was requested but ECHILD was received by waitpid(). See the documentation of g_child_watch_source_new() for possible causes.

I thought it may be something to do with the client/server config since launching a new emacs like this: termite -e 'emacs -nw' works as expected, although still spits out the same error above.

  • You can try adding a & at the end of the command to launch it asynchronously, and you might want to redirect stdout and stderr somewhere else to keep the terminal clean. – DoMiNeLa10 Apr 2 at 17:46
  • If I understand you correctly, your command termite -e 'emacsclient -nw' works fine when run from a terminal, but fails when you bind it to a key in your Sway config? This works fine for me with i3 and gnome-terminal, so I suspect the problem is with termite or Sway, not Emacs. Can you try using other terminals - gnome-terminal or xterm etc? – Tyler Apr 2 at 21:50
  • @Tyler termite -e 'emacsclient -nw' did not work, termite -e 'emacs -nw' did. the former launched in a terminal or in sway/i3 produce the same result, a window is created but quickly disappears, with that warning. – tgunnoe Apr 3 at 2:05
  • @DoMiNeLa10 thank you, launching it async seems to work, – tgunnoe Apr 3 at 2:07
  • @DoMiNeLa10 Sorry I thought i finished my post before but i left off with a comma. I got something to work with you original advice, first tried termite -e 'emacsclient -nw &' but it only worked once and opened the buffer named &. looking back at the emacsclient args, it thinks & is a file. so i added a . like termite -e 'emacsclient -nw . &' and it seems to work as intended, except after opening several more emacsclient panes it says File no longer exists: /home/revive/&, write buffer to file? So it must not be launching asynchronously like so either. – tgunnoe Apr 3 at 19:16
0

You can run a command from a shell asynchronously by adding an & at the end of it, which in your case would mean running a command like termite -e 'emacsclient -nw' &.

You might also try binding the command (without the &) to some key in your window manager, or run it from some run utility. You'll want to keep the invocation of the terminal emulator in place, as Emacs won't figure that part on its own.

  • This doesn't seem to work as expected either. At first glance, it appears to open as many panes with emacsclient as needed, but if I attempt to kill a sway/i3 window with one of them by using the macro such as Mod+Shift+Q instead of closing the emacsclient the emacs way C - x C - c, all other emacsclients freeze and I am forced to kill the emacs daemon. Both ways close the window immediately, but only the emacs way exits gracefully. Also, it puts my emacsdaemon's CPU usage at 100% – tgunnoe Apr 3 at 19:27
  • Also when using this method after mucking around with opening and closing new windows, upon trying any key macros I get the emacs message Wrong type argument: terminal-live-p, #<Frame F5 0x456ed50> – tgunnoe Apr 3 at 19:35
  • Maybe there's a problem with your init file. Have you tried running Emacs without it? – DoMiNeLa10 Apr 3 at 19:35
  • Well I that seems to solve it. Thats a shame, because the GUI emacs works fine. And my .emacs.el file is some 2000 lines =( – tgunnoe Apr 3 at 19:58
  • You can use binary search to find the culprit. – DoMiNeLa10 Apr 3 at 20:10

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.