mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-09 02:15:32 +00:00
When the installation runs from `unattended-upgrade`, `$SUDO_USER` and `$USER` will probably not be set. Fixes #6983
76 lines
2.2 KiB
Bash
76 lines
2.2 KiB
Bash
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
case "$1" in
|
|
|
|
configure)
|
|
# if don't have sudo and ps then don't attempt to restart ibus
|
|
if which sudo > /dev/null && which ps > /dev/null; then
|
|
|
|
# check for gnome-shell as it works differently
|
|
! gspid=`ps -C gnome-shell -o pid=|head -n 1`
|
|
if [ "x$gspid" != "x" ]; then
|
|
# gnome-shell has multiple ibus-daemon processes and needs exit instead of restart
|
|
is_gnome_shell=1
|
|
else
|
|
is_gnome_shell=0
|
|
fi
|
|
|
|
# Restart IBus if it is running
|
|
! ibuspid=`ps -C ibus-daemon -o pid=|head -n 1`
|
|
|
|
if [ "x$ibuspid" != "x" ]; then
|
|
if [ "x$is_gnome_shell" = "x1" ]; then
|
|
ibususers=`ps -C ibus-daemon -o user=|grep -v gdm|uniq`
|
|
for ibususer in $ibususers; do
|
|
sudo -H -u "$ibususer" ibus exit || true
|
|
sleep 1s
|
|
done
|
|
else
|
|
ibususers=`ps -C ibus-daemon -o user=|uniq`
|
|
for ibususer in $ibususers; do
|
|
sudo -H -u "$ibususer" ibus restart || true
|
|
sleep 1s
|
|
done
|
|
fi
|
|
fi
|
|
|
|
# Verify that it's running now
|
|
if [ ! -z $SUDO_USER ]; then
|
|
! ibusdaemon=`ps --user $SUDO_USER -o s= -o cmd | grep --regexp="^[^ZT] ibus-daemon .*--xim.*"`
|
|
if [ "x$ibusdaemon" = "x" ]; then
|
|
# otherwise try to start it for the user installing the package
|
|
if [ "x$is_gnome_shell" = "x1" ]; then
|
|
for session in $(loginctl show-user ${SUDO_USER} -p Sessions --value); do
|
|
case $(loginctl show-session ${session} -p Type --value) in
|
|
wayland) sudo -H -u "${SUDO_USER}" -i WAYLAND_DISPLAY=wayland-0 -- ibus-daemon -d -r --xim --panel disable;;
|
|
x11) sudo -H -u "${SUDO_USER}" -- ibus-daemon -d -r --xim --panel disable;;
|
|
*) ;;
|
|
esac
|
|
done
|
|
else
|
|
sudo -H -u "${SUDO_USER}" -- ibus-daemon -d -r --xim
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
;;
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
exit 0
|
|
;;
|
|
|
|
*)
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
exit 1
|
|
;;
|
|
|
|
esac
|
|
|
|
# dh_installdeb will replace this with shell code automatically
|
|
# generated by other debhelper scripts.
|
|
|
|
#DEBHELPER#
|
|
|
|
exit 0
|