#!/bin/bash # Exit on errors - Debian policy 10.4 set -e case "$1" in configure) # (Re-)Start IBus # 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 [ "$gspid" != "" ]; 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 [ "$ibuspid" != "" ]; then if [ "$is_gnome_shell" = "1" ]; 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 [ -n "$SUDO_USER" ] && id "$SUDO_USER" > /dev/null 2>/dev/null; then ! ibusdaemon=$(ps --user "$SUDO_USER" -o s= -o cmd | grep --regexp="^[^ZT] \(/usr/bin/\)\?ibus-daemon .*--xim.*") if [ "$ibusdaemon" = "" ]; then # otherwise try to start it for the user installing the package if [ "$is_gnome_shell" = "1" ]; 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 -- /usr/bin/ibus-daemon -d -r --xim --panel disable;; x11) sudo -H -u "${SUDO_USER}" -- /usr/bin/ibus-daemon -d -r --xim --panel disable;; *) ;; esac done else sudo -H -u "${SUDO_USER}" -- /usr/bin/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