Package: hibernate Version: 1.99-1 Severity: wishlist Tags: patch Here are some improvements/updates to the sylpheed_claws scriptlet.
Changes: * Changed name of the mailer from 'Sylpheed-Claws' to 'Claws Mail/Sylpheed Claws'. * Added 'claws-mail' to the possible process names of the mailer. * Tries to find the executable name out of a few alternatives. * Added SylpheedClawsExecutableNames config option. * Better error reporting when reading the envvar fails. * Fallback to use $HOME/.Xauthority if $XAUTHORITY is empty. (fixes #446811) * Renamed sylpheed_claws to claws_mail. * Renamed config options (keeping backcompat). PS: Probably you won't remember me, I wrote the sylpheed_claws and gaim scriptlets a few years ago. norbi -- System Information: Debian Release: 5.0 APT prefers stable APT policy: (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.26 (PREEMPT) Locale: LANG=C, LC_CTYPE=hu_HU (charmap=ISO-8859-2) Shell: /bin/sh linked to /bin/bash Versions of packages hibernate depends on: ii console-tools 1:0.2.3dbs-65.1 Linux console and font utilities Versions of packages hibernate recommends: ii dash 0.5.4-12 POSIX-compliant shell ii hdparm 8.9-3 tune hard disk parameters for high ii uswsusp 0.7-1.2 tools to use userspace software su ii vbetool 1.0-3 run real-mode video BIOS code to a Versions of packages hibernate suggests: pn 915resolution <none> (no description available) ii vlock 2.2.2-3 Virtual Console locking program ii xscreensaver 5.05-3 Automatic screensaver for X -- no debconf information
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:30:08.000000000 +0200 @@ -0,0 +1,141 @@ +# -*- sh -*- +# vim:ft=sh:ts=8:sw=4:noet + +# $Id: claws_mail 742 2009-04-08 00:29:04Z 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 offline: 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 -}