# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-# This is the equivalent of sux[1] but simpler and using sudo,
-# since I don't have su installed on some of my systems.
-#
+# This is the equivalent of sux[1] but simpler and using sudo.
 # [1] http://fgouget.free.fr/sux/
 
 set -e
 
 usage() {
-  echo "usage: $(basename $0) [OPTION]... <sudo_options>";
+  echo "usage: $(basename $0) [OPTION]... <sudo_options>"
   echo "Execute a command as another user, with access to the X display"
   echo
   echo "List of OPTIONs:"
 
 [ "x$@" != "x" ] || { usage 1>&2; exit 1; }
 
-# Authorize the user
-xauth extract - $DISPLAY | sudo -u "$USERNAME" xauth merge -
+# Authorize the user.
+# Use "sudo -H" to cover the case when env_keep+="HOME" is set in /etc/sudoers
+xauth extract - $DISPLAY | sudo -H -u "$USERNAME" xauth merge -
 
 # Execute the command.
-# NOTE: -i or -s have to be passed in order to open a shell
+# NOTE: -i or -s can be passed in order to open a shell
 sudo DISPLAY="$DISPLAY" -u "$USERNAME" "$@"