1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#!/bin/bash
###########################################################################
# #
# Powersave Daemon #
# #
# Copyright (C) 2004,2005 SUSE Linux Products GmbH #
# #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the #
# Free Software Foundation; either version 2 of the License, or (at you #
# option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
# General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., #
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
# #
###########################################################################
# notify users about more or less critical events with a popup. Only called from daemon
# called with one argument, displays the argument.
. "${0%/*}/scripts/helper_functions"
. "${PUB_SCRIPT_DIR}/x_helper_functions"
# this script does not use $SCRIPT_RETURN, so the exit trap is not needed.
trap '' EXIT
# we already log this at DIAG level in helper_functions
DEBUG "process script: do_x_notification" INFO
#######################################################################
# process arguments:
MESSAGE="$1";LEVEL="WARN"
if [ -z "$MESSAGE" ]; then
MESSAGE="A powersave error occurred. For more information, use a graphical frontend like kpowersave."
fi
for x in ${NOTIFY_METHOD:-notify_popup_fallback notify_acoustic}; do
[ -x $ZENITY_BIN ] && ZENITY=true || ZENITY=false
case "$x" in
notify_popup_window|notify_popup_fallback)
get_x_users
DONE=false
i=0
while [ "${X_USERS[$i]}" ]; do
X_USER=${X_USERS[$i]}; DISP=${DISPS[$i]}; KDE_RUNNING=${KDE_RUNNING[$i]:-false};
# open the appropriate popup (x_helper_functions)
choose_popup "$MESSAGE" "$LEVEL"
[ $? -eq 0 ] && DONE=true
let i++
done
if ! $DONE && [ "$x" = "notify_popup_fallback" ]; then
echo "$MESSAGE" | fmt | wall
fi
;;
notify_console) ;;
notify_acoustic) ;;
*)
DEBUG "Wrong value $x in $SYSCONF_DIR common for variable NOTIFY_METHOD" ERROR
;;
esac
done
exit 0
|