-
Notifications
You must be signed in to change notification settings - Fork 13
/
emacsclient
executable file
·52 lines (45 loc) · 1.73 KB
/
emacsclient
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Launch emacsclient with the most appropriate toolkit (currently gtk (for real
# x11) or wayland)
# The environment variable EMACS_TOOLKIT can be used to specify the preferred toolkit.
# The value should be one of: gtk or wayland
# If the environment variable is not set, the script will try to detect the
# toolkit to use by checking if the XDG_SESSION_TYPE environment variable is
# set to wayland or x11.
# FIXME - remove the following once the various issues like
# https://github.com/alexmurray/emacs-snap/issues/78 and
# https://github.com/alexmurray/emacs-snap/issues/79 are resolved
: "${EMACS_TOOLKIT:=gtk}"
if [ -n "${XDG_SESSION_TYPE}" ]; then
if [ "${XDG_SESSION_TYPE}" = "wayland" ]; then
: "${EMACS_TOOLKIT:=wayland}"
else
: "${EMACS_TOOLKIT:=gtk}"
fi
else
: "${EMACS_TOOLKIT:=gtk}"
fi
case "${EMACS_TOOLKIT}" in
gtk|wayland)
;;
*)
echo "Invalid value for EMACS_TOOLKIT: ${EMACS_TOOLKIT} - must be either gtk or wayland"
exit 1
;;
esac
EMACSCLIENT="emacsclient-${EMACS_TOOLKIT}"
# add logic from the upstream emacsclient.desktop script which supports
# spawning a new frame when launched with no arguments but only do this
# when we are launched from the desktop file which we can detect via the
# GIO_LAUNCHED_DESKTOP_FILE environment variable and associated
# GIO_LAUNCHED_DESKTOP_FILE_PID
if [ -n "$GIO_LAUNCHED_DESKTOP_FILE" ] && [ "$$" -eq "$GIO_LAUNCHED_DESKTOP_FILE_PID" ]; then
# the following is the logic from the upstream emacsclient.desktop file
if [ -n "$*" ]; then
exec "$SNAP/usr/bin/$EMACSCLIENT" --alternate-editor= --display="$DISPLAY" "$@"
else
exec "$SNAP/usr/bin/$EMACSCLIENT" --alternate-editor= --create-frame
fi
else
exec "$SNAP/usr/bin/$EMACSCLIENT" "$@"
fi