The previous patch contained a typo in one of the messages. Here goes the
fixed version.

norbi
diff -Naur hibernate-1.99/scriptlets.d/claws_mail hibernate-1.99-fixed/scriptlets.d/claws_mail
--- hibernate-1.99/scriptlets.d/claws_mail	1970-01-01 01:00:00.000000000 +0100
+++ hibernate-1.99-fixed/scriptlets.d/claws_mail	2009-04-08 02:47:54.000000000 +0200
@@ -0,0 +1,141 @@
+# -*- sh -*-
+# vim:ft=sh:ts=8:sw=4:noet
+
+# $Id: claws_mail 745 2009-04-08 00:47:30Z mendel $
+
+# These are the possible names of the mailer binary.
+default_clawsmail_executable_names='sylpheed-claws sylpheed-claws-gtk2 claws-mail'
+
+# Tries to find an executable with any of the possible names provided. Returns
+# the name of the first executable found.
+find_first_executable()
+{
+    while [ $# -gt 0 ]; do
+	executable=$(command -v "$1" 2>/dev/null)
+	if [ -n "$executable" ]; then
+	    echo "$executable"
+	    return 0
+	fi
+	shift
+    done
+
+    return 1
+}
+
+CLAWSMAIL_EXECUTABLE_NAMES="$default_clawsmail_executable_names"
+
+AddConfigHandler ClawsMailOptions
+AddConfigHelp "ClawsMailOffline <boolean>" "Changes status of all locally running Claws Mail/Sylpheed Claws to offline before suspending, and (optionally) change it to online after resuming."
+AddConfigHelp "SylpheedClawsOffline <boolean>" "The same as ClawsMailOffline."
+AddConfigHelp "ClawsMailOnline <boolean>" "Changes status of all locally running Claws Mail/Sylpheed Claws to online after resuming."
+AddConfigHelp "SylpheedClawsOnline <boolean>" "The same as ClawsMailOnline."
+AddConfigHelp "ClawsMailExecutableNames '<list of executable names>'" "Possible names of Claws Mail/Sylpheed Claws executables to look for. (default: '$default_clawsmail_executable_names')"
+
+ClawsMailOffline()
+{
+    [ x"$CLAWSMAIL_OFFLINE" != "x1" ] && return 0
+
+    CLAWSMAIL_EXECUTABLE=$(find_first_executable $CLAWSMAIL_EXECUTABLE_NAMES)
+    if [ -z "$CLAWSMAIL_EXECUTABLE" ] || [ ! -x "$CLAWSMAIL_EXECUTABLE" ]; then
+	vecho 0 "Cannot change status of Claws Mail/Sylpheed Claws to offline: no binary found with any of these names: $CLAWSMAIL_EXECUTABLE_NAMES"
+	return 0
+    fi
+
+    local pid i=0
+    for pid in `pidof $CLAWSMAIL_EXECUTABLE_NAMES`; do
+	local user display xauthority home
+
+	user=$(get_env_var_of_process $pid USER)
+	display=$(get_env_var_of_process $pid DISPLAY)
+	xauthority=$(get_env_var_of_process $pid XAUTHORITY)
+
+	if [ -z "$user" ]; then
+	    vecho 0 "Cannot change status of $user's Claws Mail/Sylpheed Claws to offline: cannot read USER envvar for pid $pid"
+	elif [ -z "$display" ]; then
+	    vecho 0 "Cannot change status of $user's Claws Mail/Sylpheed Claws to offline: cannot read DISPLAY envvar for pid $pid"
+	elif [ -z "$xauthority" ]; then
+	    home=$(get_env_var_of_process HOME)
+	    if [ -n "$home" ]; then
+		if [ -e "$home"/.Xauthority ]; then
+		    xauthority="$home"/.Xauthority
+		else
+		    vecho 0 "Cannot change status of $user's Claws Mail/Sylpheed Claws to offline: cannot read XAUTHORITY envvar for pid $pid, and '$home/.Xauthority' does not exist"
+		fi
+	    else
+		vecho 0 "Cannot change status of $user's Claws Mail/Sylpheed Claws to offline: cannot read XAUTHORITY nor HOME envvar for pid $pid"
+	    fi
+	else
+	    # using this eval-crap to be POSIX-compliant (arrays are nonstandard)
+	    eval "CLAWSMAIL_LOGGED_OUT_SESSIONS_USER_$i='$user'"
+	    eval "CLAWSMAIL_LOGGED_OUT_SESSIONS_DISPLAY_$i='$display'"
+	    eval "CLAWSMAIL_LOGGED_OUT_SESSIONS_XAUTHORITY_$i='$xauthority'"
+	    i=`expr $i + 1`
+
+	    vecho 2 "Changing status of $user's Claws Mail/Sylpheed Claws to offline"
+	    DISPLAY="$display" XAUTHORITY="$xauthority" su "$user" -c "$CLAWSMAIL_EXECUTABLE --offline"
+	fi
+    done
+
+    return 0
+}
+
+ClawsMailOnline()
+{
+    [ x"$CLAWSMAIL_OFFLINE" != "x1" ] && return 0
+
+    [ x"$CLAWSMAIL_ONLINE" != "x1" ] && return 0
+
+    CLAWSMAIL_EXECUTABLE=$(find_first_executable $CLAWSMAIL_EXECUTABLE_NAMES)
+    if [ -z "$CLAWSMAIL_EXECUTABLE" ] || [ ! -x "$CLAWSMAIL_EXECUTABLE" ]; then
+	vecho 0 "Cannot change status of Claws Mail/Sylpheed Claws to online: no binary found with any of these names: $CLAWSMAIL_EXECUTABLE_NAMES"
+	return 0
+    fi
+
+    local i=0
+    while :; do
+	local user display xauthority
+
+	user=`eval "echo \\\$CLAWSMAIL_LOGGED_OUT_SESSIONS_USER_$i"`
+	display=`eval "echo \\\$CLAWSMAIL_LOGGED_OUT_SESSIONS_DISPLAY_$i"`
+	xauthority=`eval "echo \\\$CLAWSMAIL_LOGGED_OUT_SESSIONS_XAUTHORITY_$i"`
+	i=`expr $i + 1`
+
+	[ -z "$user" ] && break
+
+	vecho 2 "Changing status of $user's Claws Mail/Sylpheed Claws to online"
+	DISPLAY="$display" XAUTHORITY="$xauthority" su "$user" -c "$CLAWSMAIL_EXECUTABLE --online"
+    done
+
+    return 0
+}
+
+ClawsMailOptions()
+{
+    case "$1" in
+	clawsmailoffline|sylpheedclawsoffline)
+	    if BoolIsOn "$1" "$2"; then
+		CLAWSMAIL_OFFLINE=1
+		if [ -z "$CLAWSMAILOFFLINE_HOOKED" ]; then
+		    AddSuspendHook 19 ClawsMailOffline
+		    AddResumeHook 19 ClawsMailOnline
+		    CLAWSMAILOFFLINE_HOOKED=1
+		fi
+	    else
+		CLAWSMAIL_OFFLINE=0
+	    fi
+	    ;;
+	clawsmailonline|sylpheedclawsonline)
+	    if BoolIsOn "$1" "$2"; then
+		CLAWSMAIL_ONLINE=1
+	    else
+		CLAWSMAIL_ONLINE=0
+	    fi
+	    ;;
+	clawsmailexecutablenames)
+	    CLAWSMAIL_EXECUTABLE_NAMES="$2"
+	    ;;
+	*)
+	    return 1
+	    ;;
+    esac
+}
diff -Naur hibernate-1.99/scriptlets.d/sylpheed_claws hibernate-1.99-fixed/scriptlets.d/sylpheed_claws
--- hibernate-1.99/scriptlets.d/sylpheed_claws	2008-05-01 13:59:58.000000000 +0200
+++ hibernate-1.99-fixed/scriptlets.d/sylpheed_claws	1970-01-01 01:00:00.000000000 +0100
@@ -1,97 +0,0 @@
-# -*- sh -*-
-# vim:ft=sh:ts=8:sw=4:noet
-
-# $Id$
-
-sylpheedclaws=$(command -v sylpheed-claws)
-
-AddConfigHandler SylpheedClawsOptions
-AddConfigHelp "SylpheedClawsOffline <boolean>" "Changes status of all locally running Sylpheed Claws to offline before suspending, and (optionally) change it to online after resuming."
-AddConfigHelp "SylpheedClawsOnline <boolean>" "Changes status of all locally running Sylpheed Claws to online after resuming."
-
-SylpheedClawsOffline()
-{
-    [ x"$SYLPHEEDCLAWS_OFFLINE" != "x1" ] && return 0
-
-    if [ -z "$sylpheedclaws" ] || [ ! -x "$sylpheedclaws" ]; then
-	vecho 0 'Cannot change status of Sylpheed Claws to offline: `sylpheed-claws` not found.'
-	return 0
-    fi
-
-    local pid i=0
-    for pid in `pidof sylpheed-claws`; do
-	local user display xauthority
-
-	user=$(get_env_var_of_process $pid USER)
-	display=$(get_env_var_of_process $pid DISPLAY)
-	xauthority=$(get_env_var_of_process $pid XAUTHORITY)
-
-	# using this eval-crap to be POSIX-compliant (arrays are nonstandard)
-	eval "SYLPHEEDCLAWS_LOGGED_OUT_SESSIONS_USER_$i='$user'"
-	eval "SYLPHEEDCLAWS_LOGGED_OUT_SESSIONS_DISPLAY_$i='$display'"
-	eval "SYLPHEEDCLAWS_LOGGED_OUT_SESSIONS_XAUTHORITY_$i='$xauthority'"
-	i=`expr $i + 1`
-
-	vecho 2 "Changing status $user's Sylpheed Claws to offline"
-	DISPLAY="$display" XAUTHORITY="$xauthority" su "$user" -c "$sylpheedclaws --offline"
-    done
-
-    return 0
-}
-
-SylpheedClawsOnline()
-{
-    [ x"$SYLPHEEDCLAWS_OFFLINE" != "x1" ] && return 0
-
-    [ x"$SYLPHEEDCLAWS_ONLINE" != "x1" ] && return 0
-
-    if [ -z "$sylpheedclaws" ] || [ ! -x "$sylpheedclaws" ]; then
-	vecho 0 'Cannot change status of Sylpheed Claws to online: `sylpheed-claws` not found.'
-	return 0
-    fi
-
-    local i=0
-    while :; do
-	local user display xauthority
-
-	user=`eval "echo \\\$SYLPHEEDCLAWS_LOGGED_OUT_SESSIONS_USER_$i"`
-	display=`eval "echo \\\$SYLPHEEDCLAWS_LOGGED_OUT_SESSIONS_DISPLAY_$i"`
-	xauthority=`eval "echo \\\$SYLPHEEDCLAWS_LOGGED_OUT_SESSIONS_XAUTHORITY_$i"`
-	i=`expr $i + 1`
-
-	[ -z "$user" ] && break
-
-	vecho 2 "Changing status of $user's Sylpheed Claws to online"
-	DISPLAY="$display" XAUTHORITY="$xauthority" su "$user" -c "$sylpheedclaws --online"
-    done
-
-    return 0
-}
-
-SylpheedClawsOptions()
-{
-    case "$1" in
-	sylpheedclawsoffline)
-	    if BoolIsOn "$1" "$2"; then
-		SYLPHEEDCLAWS_OFFLINE=1
-		if [ -z "$SYLPHEEDCLAWSOFFLINE_HOOKED" ]; then
-		    AddSuspendHook 19 SylpheedClawsOffline
-		    AddResumeHook 19 SylpheedClawsOnline
-		    SYLPHEEDCLAWSOFFLINE_HOOKED=1
-		fi
-	    else
-		SYLPHEEDCLAWS_OFFLINE=0
-	    fi
-	    ;;
-	sylpheedclawsonline)
-	    if BoolIsOn "$1" "$2"; then
-		SYLPHEEDCLAWS_ONLINE=1
-	    else
-		SYLPHEEDCLAWS_ONLINE=0
-	    fi
-	    ;;
-	*)
-	    return 1
-	    ;;
-    esac
-}

Reply via email to