I'm trying to make a script to determine whether
emacsclient should be ran with
-t. The script is like this:
#!/bin/sh if [ -z "$DISPLAY" ]; then IS_GRAPHICAL=true else IS_GRAPHICAL=$(emacs --batch -Q --eval='(if (fboundp '"'"'tool-bar-mode) (message "true") (message "false"))' 2>&1) fi if $IS_GRAPHICAL; then emacsclient -a "" -nc "$@" else emacsclient -a "" -t "$@" fi
emacs --batch -Q ... line takes as much time as using a bare
emacs instance. If I comment out this line, however, I get nothing instead of a clean of screen when this is executed under a tty. Is it possible to make the detection faster?
EDIT: I have already started emacs daemon by a systemd user unit. I want
emacsclient to be a window(X11) when launched via
gmrun, but in terminal while launched in terminal (from shell or
EDIT2: I have not expressed myself clearly. I want the script behave like this:
- stay in the terminal (that is, do not open a GUI window) if called with a file (e.g. called by
git-commit) or when graphical environment isn't present (e.g. called while in tty) and don't return until exit (
- open a GUI window when called without a file (behave like bare
emacscall; when I do this with
emacsclientit tells me that input file is required) and return immediately.