2013-05-24 12:47:07 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Launch a GNU Emacs
|
|
|
|
#
|
|
|
|
# The environment variable EMACS_TOOLKIT is used to determine
|
|
|
|
# the prefered GUI. Possible values/types of EMACS_TOOLKIT are
|
|
|
|
#
|
2023-09-26 14:41:57 +02:00
|
|
|
# nox -- for pure console based GNU Emacs
|
|
|
|
# gtk -- for full GTK2/3 based GNU Emacs (for real X11)
|
|
|
|
# wayland -- for full GTK2/3 based GNU Emacs (for wayland)
|
|
|
|
# x11 -- for full LUCID based GNU Emacs (used Xaw3d)
|
2013-05-24 12:47:07 +02:00
|
|
|
#
|
|
|
|
# Should work but remember history
|
|
|
|
# bnc#345669 -- Emacs doesn't un-maximize in KDE/KWin
|
|
|
|
# bnc#342385 -- Emacs doesn't keep the iconic information in KDE/KWin
|
|
|
|
#
|
|
|
|
# if test -z "$EMACS_TOOLKIT" ; then
|
|
|
|
# EMACS_TOOLKIT=gtk
|
|
|
|
# KDE_FULL_SESSION=$(xprop -root KDE_FULL_SESSION 2>/dev/null)
|
|
|
|
# case "$KDE_FULL_SESSION" in
|
|
|
|
# *true*) EMACS_TOOLKIT=x11
|
|
|
|
# esac
|
|
|
|
# fi
|
|
|
|
#
|
2023-09-26 14:41:57 +02:00
|
|
|
if test -n "${XDG_SESSION_TYPE}"
|
|
|
|
then
|
|
|
|
if test "${XDG_SESSION_TYPE}" = wayland -a -x ${0}-wayland
|
|
|
|
then
|
|
|
|
: ${EMACS_TOOLKIT:=wayland}
|
|
|
|
else
|
|
|
|
: ${EMACS_TOOLKIT:=gtk}
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
: ${EMACS_TOOLKIT:=gtk}
|
|
|
|
fi
|
2021-05-26 15:33:24 +02:00
|
|
|
#
|
2021-06-11 12:25:31 +02:00
|
|
|
# Enabled again
|
|
|
|
#
|
2023-09-26 14:41:57 +02:00
|
|
|
if test "$EMACS_TOOLKIT" = gtk -o "$EMACS_TOOLKIT" = wayland
|
|
|
|
then
|
2021-06-11 12:25:31 +02:00
|
|
|
# Currently (2013/05/24) the parser of the GNOME libs
|
|
|
|
# are broken that is it is not independent from locale
|
|
|
|
LC_NUMERIC=POSIX
|
|
|
|
GDK_RGBA=0
|
2021-11-15 14:56:14 +01:00
|
|
|
export LC_NUMERIC GDK_RGBA
|
2021-06-11 12:25:31 +02:00
|
|
|
fi
|
2013-05-24 12:47:07 +02:00
|
|
|
arg0=$0
|
|
|
|
argv=("$@")
|
2016-02-26 14:37:45 +01:00
|
|
|
if test -x ${arg0}-${EMACS_TOOLKIT}
|
2013-05-24 12:47:07 +02:00
|
|
|
then
|
|
|
|
set -- ${arg0}-${EMACS_TOOLKIT}
|
2016-02-26 14:37:45 +01:00
|
|
|
elif test -x ${arg0}-x11
|
2013-05-24 12:47:07 +02:00
|
|
|
then
|
|
|
|
set -- ${arg0}-x11
|
2016-02-26 14:37:45 +01:00
|
|
|
elif test -x ${arg0}-nox
|
2013-05-24 12:47:07 +02:00
|
|
|
then
|
|
|
|
set -- ${arg0}-nox
|
|
|
|
else
|
|
|
|
echo "no emacs binary found"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-11-09 14:54:41 +01:00
|
|
|
if [[ "$1" =~ .*-nox ]] ; then
|
|
|
|
exec -a $arg0 ${1+"$@"} "${argv[@]}"
|
|
|
|
fi
|
2013-12-03 12:05:04 +01:00
|
|
|
dbusdaemon=$(type -p dbus-daemon 2>/dev/null)
|
2013-05-24 12:47:07 +02:00
|
|
|
#
|
|
|
|
# Now check for valid dbus, e.g. after su/sudo/slogin
|
|
|
|
#
|
2013-12-03 12:05:04 +01:00
|
|
|
if test -n "$dbusdaemon" ; then
|
2022-11-09 14:54:41 +01:00
|
|
|
#
|
|
|
|
# Workaround for boo#1205109
|
|
|
|
#
|
|
|
|
if test "$EUID" = 0 -a "$XDG_RUNTIME_DIR" != /run/user/0; then
|
|
|
|
unset XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DESKTOP_DIR XDG_RUNTIME_DIR XDG_DATA_DIRS
|
|
|
|
# unset DBUS_SESSION_BUS_ADDRESS
|
|
|
|
if test ! -d /run/user/0; then
|
|
|
|
systemctl start user@0 >/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
if test -S /run/user/0/bus; then
|
|
|
|
DBUS_SESSION_BUS_ADDRESS=unix:/run/user/0/bus
|
|
|
|
fi
|
|
|
|
fi
|
2021-11-19 15:18:25 +01:00
|
|
|
|
|
|
|
# Standard on modern systems
|
2022-11-09 14:54:41 +01:00
|
|
|
: ${XDG_RUNTIME_DIR:=/run/user/${EUID}}
|
2021-11-19 15:18:25 +01:00
|
|
|
export XDG_RUNTIME_DIR
|
|
|
|
|
2013-05-24 12:47:07 +02:00
|
|
|
# Oops ... no dbus-daemon then launch a new session
|
|
|
|
if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
|
2016-02-26 14:37:45 +01:00
|
|
|
dbuslaunch=$(type -p dbus-launch 2>/dev/null)
|
|
|
|
dbusession=$(type -p dbus-run-session 2>/dev/null)
|
2013-12-03 12:05:04 +01:00
|
|
|
if test -z "$dbusession" -a -n "$dbuslaunch" ; then
|
|
|
|
set -- $dbuslaunch --sh-syntax --close-stderr --exit-with-session ${1+"$@"}
|
|
|
|
arg0=$dbuslaunch
|
|
|
|
elif test -n "$dbusession" ; then
|
|
|
|
set -- $dbusession -- ${1+"$@"}
|
|
|
|
arg0=$dbusession
|
|
|
|
else
|
|
|
|
arg0=emacs
|
|
|
|
fi
|
2017-04-26 09:34:32 +02:00
|
|
|
elif test -S "${XDG_RUNTIME_DIR}/bus" ; then
|
|
|
|
dbusupdate=$(type -p dbus-update-activation-environment 2>/dev/null)
|
|
|
|
dbusstatus=$(systemctl --user is-active dbus.service 2>/dev/null)
|
|
|
|
if test -n "$dbusupdate" -a "$dbusstatus" != active ; then
|
2022-11-10 14:50:00 +01:00
|
|
|
export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"
|
|
|
|
$dbusupdate --systemd "DBUS_SESSION_BUS_ADDRESS"
|
2017-04-26 09:34:32 +02:00
|
|
|
fi
|
2013-05-24 12:47:07 +02:00
|
|
|
fi
|
|
|
|
unset dbuslaunch dbusdaemon
|
|
|
|
fi
|
2016-02-26 14:37:45 +01:00
|
|
|
#
|
|
|
|
# Disable AT bridge if not accessible
|
|
|
|
#
|
2021-11-19 11:55:22 +01:00
|
|
|
if test -z "$NO_AT_BRIDGE" ; then
|
2016-02-26 14:37:45 +01:00
|
|
|
gsettings=$(gsettings get org.gnome.desktop.interface toolkit-accessibility 2>/dev/null)
|
|
|
|
if test -z "$gsettings" -o "$gsettings" = false ; then
|
|
|
|
NO_AT_BRIDGE=1
|
|
|
|
export NO_AT_BRIDGE
|
|
|
|
fi
|
|
|
|
unset gsettings
|
|
|
|
fi
|
2021-09-08 11:09:17 +02:00
|
|
|
#
|
|
|
|
# Check input method for working ibus setup
|
|
|
|
#
|
|
|
|
case "$XMODIFIERS" in
|
|
|
|
@im=ibus*)
|
|
|
|
_arch=$(getconf LONG_BIT)
|
|
|
|
if test "$_arch" != 64
|
|
|
|
then
|
|
|
|
unset _arch
|
|
|
|
else
|
|
|
|
_arch=-64
|
|
|
|
fi
|
|
|
|
if type -p gtk-query-immodules-3.0${_arch} &> /dev/null
|
|
|
|
then
|
|
|
|
_ibus=$(gtk-query-immodules-3.0${_arch} | grep im-ibus)
|
|
|
|
else
|
|
|
|
unset _ibus
|
|
|
|
fi
|
|
|
|
if test -n "$_ibus"
|
|
|
|
then
|
|
|
|
if test -z "$GTK_IM_MODULE" -o "$GTK_IM_MODULE" != ibus
|
|
|
|
then
|
|
|
|
export GTK_IM_MODULE=ibus
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
unset XMODIFIERS
|
|
|
|
fi
|
|
|
|
unset _ibus _arch
|
|
|
|
if ! ibus list-engine &> /dev/null
|
|
|
|
then
|
|
|
|
unset GTK_IM_MODULE XMODIFIERS
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
esac
|
2016-02-26 14:37:45 +01:00
|
|
|
unset G_MESSAGES_DEBUG G_DEBUG G_MESSAGES_PREFIXED
|
2013-05-24 12:47:07 +02:00
|
|
|
exec -a $arg0 ${1+"$@"} "${argv[@]}"
|