spiegel-keyman/linux/ibus-keyman/debian/postinst
Eberhard Beilharz b6b9b5de46
fix(linux): Improve robustness when installing ibus-keyman
If for whatever reason ibus wasn't running for the current user
the installation failed previously, leaving the user in a broken
state until he reboots and tries the installation again. This change
detects this situation and skips restarting ibus.
2020-08-28 11:00:39 +02:00

45 lines
1,021 B
Bash

#!/bin/sh
set -e
case "$1" in
configure)
# Restart IBus if it is running
! ibuspid=`ps -C ibus-daemon -o pid=|head -n 1`
if [ "x$ibuspid" != "x" ]; 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
ibususer=`ps -C ibus-daemon -o user=|grep -v gdm|uniq`
if [ "x$ibususer" != "x" ]; then
sudo -H -u "$ibususer" ibus exit
fi
else
ibususer=`ps -C ibus-daemon -o user=|uniq`
if [ "x$ibususer" != "x" ]; then
sudo -H -u "$ibususer" ibus restart
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