update from Han

This commit is contained in:
fluxgen 2003-09-18 12:15:17 +00:00
parent f99e1c6091
commit d539b5257e

View file

@ -23,7 +23,7 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# #
# $Id: fbsetbg,v 1.17 2003/09/03 11:55:29 fluxgen Exp $ # $Id: fbsetbg,v 1.18 2003/09/18 12:15:17 fluxgen Exp $
# Portability notes: # Portability notes:
# To guarantee this script works on all platforms that support fluxbox # To guarantee this script works on all platforms that support fluxbox
@ -45,7 +45,7 @@
# The wallpapersetter is selected in this order # The wallpapersetter is selected in this order
wpsetters='chbg Esetroot wmsetbg display qiv xv xsri xli xsetbg' # broken icewmbg' wpsetters='feh Esetroot wmsetbg chbg display qiv xv xsri xli xsetbg' # broken icewmbg'
lastwallpaper=${HOME}/.fluxbox/lastwallpaper lastwallpaper=${HOME}/.fluxbox/lastwallpaper
@ -83,8 +83,9 @@ Options:
-p Tips -p Tips
Files: Files:
In this file the wallpaper you set will be stored, for the -l option:
~/.fluxbox/lastwallpaper ~/.fluxbox/lastwallpaper In this file the wallpaper you set
will be stored, for the -l option:
EOF EOF
} }
@ -92,7 +93,8 @@ EOF
display_tips() { display_tips() {
cat << EOF cat << EOF
1) To replace all occurrences of bsetbg in a file use this command: 1) To replace all occurrences of bsetbg with fbsetbg in a file use this
command:
perl -pi -e 's,([^f]|^)bsetbg,fbsetbg,' filename perl -pi -e 's,([^f]|^)bsetbg,fbsetbg,' filename
@ -130,7 +132,6 @@ case `uname` in
;; ;;
esac esac
message() { message() {
xmessage -center "$@" xmessage -center "$@"
} }
@ -169,13 +170,79 @@ or Esetroot (from Eterm)"
standardok=\ standardok=\
"$WPSETTER is a nice wallpapersetter. You won't have any problems." "$WPSETTER is a nice wallpapersetter. You won't have any problems."
unset debug
#Get options.
getopts ":a:f:c:t:A:F:C:T:pdlh-" COMMAND_LINE_ARGUMENT
case "${COMMAND_LINE_ARGUMENT}" in
d) debug=true
;;
a) option='$aspect'
wallpaper=$OPTARG
;;
f) option='$full'
wallpaper=$OPTARG
;;
c) option='$center'
wallpaper=$OPTARG
;;
t) option='$tile'
wallpaper=$OPTARG
;;
A) option='$aspect'
wallpaper=$OPTARG
remember=false
;;
F) option='$full'
wallpaper=$OPTARG
remember=false
;;
C) option='$center'
wallpaper=$OPTARG
remember=false
;;
T) option='$tile'
wallpaper=$OPTARG
remember=false
;;
l)
if [ -r $lastwallpaper ]; then
option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1`
wallpaper=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f2`
else
message "No previous wallpaper recorded for display ${DISPLAY}"
exit 1
fi
remember=false
;;
h) display_help ; exit 0 ;;
p) display_tips ; exit 0 ;;
-) echo "fbsetbg doesn't recognize -- gnu-longopts."
echo 'Use fbsetbg -h for a help message.'
display_usage
exit 1
;;
*) if [ ! -r "$1" ]; then
echo "$1 isn't an existing wallpaper or a valid option." >&2
display_usage
exit 1
fi
if [ -z "$1" ]; then
message 'No wallpaper to set' >&2
display_usage
exit 1
fi
;;
esac
case $WPSETTER in case $WPSETTER in
chbg) chbg)
full='-once -mode maximize' full='-once -mode maximize'
tile='-once -mode tile' tile='-once -mode tile'
center='-once -mode center' center='-once -mode center'
aspect='-once -mode smart -max_grow 100 -max_size 100' aspect='-once -mode smart -max_grow 100 -max_size 100'
debugstory=$standardok debugstory="chbg supports all features but it doesn't report errors. I reported this bug to the chbg developers."
;; ;;
xsri) xsri)
full='--center-x --center-y --scale-width=100 --scale-height=100' full='--center-x --center-y --scale-width=100 --scale-height=100'
@ -217,7 +284,7 @@ case $WPSETTER in
center='-center -onroot -quiet -border black' center='-center -onroot -quiet -border black'
aspect='-fullscreen -onroot -quiet -border black' aspect='-fullscreen -onroot -quiet -border black'
full=$aspect #broken full=$aspect #broken
debugstory='The fillscreen option (-f) is broken, defaults to (-a). $standardrant' debugstory="The fillscreen option (-f) is broken, defaults to (-a). $standardrant"
;; ;;
qiv) qiv)
full='--root_s' full='--root_s'
@ -233,6 +300,13 @@ case $WPSETTER in
aspect='-maxpect -smooth -root -quit' aspect='-maxpect -smooth -root -quit'
debugstory=$standardrant debugstory=$standardrant
;; ;;
feh)
full='--bg-scale'
tile='--bg-tile'
center='--bg-center'
aspect=$full
debugstory=$standardok
;;
icewmbg) icewmbg)
tile='-s' tile='-s'
full=$tile full=$tile
@ -251,82 +325,26 @@ recommend you install the package provided by your distro."
;; ;;
esac esac
#Get options. if [ "$debug" = true ];then
getopts ":a:f:c:t:A:F:C:T:pdlh-" COMMAND_LINE_ARGUMENT debugfbsetbg
case "${COMMAND_LINE_ARGUMENT}" in
d) debugfbsetbg
exit 0 exit 0
;; fi
a) option=$aspect
wallpaper=$OPTARG
;;
f) option=$full
wallpaper=$OPTARG
;;
c) option=$center
wallpaper=$OPTARG
;;
t) option=$tile
wallpaper=$OPTARG
;;
A) option=$aspect
wallpaper=$OPTARG
remember=false
;;
F) option=$full
wallpaper=$OPTARG
remember=false
;;
C) option=$center
wallpaper=$OPTARG
remember=false
;;
T) option=$tile
wallpaper=$OPTARG
remember=false
;;
l) option=${option:='$full'}
if [ -r $lastwallpaper ]; then
option=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f1`
wallpaper=`grep "|${DISPLAY}$" $lastwallpaper|cut -d'|' -f2`
else
message 'No previous wallpaper recorded. You have never used fbsetbg before.'
exit 1
fi
remember=false
;;
h) display_help ; exit 0 ;;
p) display_tips ; exit 0 ;;
-) echo "fbsetbg doesn't recognize -- gnu-longopts."
echo 'Use fbsetbg -h for a long help message.'
display_usage
exit 1
;;
*) if [ ! -r "$1" ]; then
echo "$1 isn't an existing wallpaper or a valid option." >&2
display_usage
exit 1
fi
if [ -z "$1" ]; then
message 'No wallpaper to set' >&2
display_usage
exit 1
fi
;;
esac
option=${option:=$full}
wallpaper=${wallpaper:=$1} wallpaper=${wallpaper:=$1}
if [ ! -r "$wallpaper" ]; then if [ ! -r "$wallpaper" ]; then
message "Can't find wallpaper $wallpaper" message "Can't find wallpaper $wallpaper"
exit 1 exit 1
fi fi
$WPSETTER $option "$wallpaper" || message "Something went wrong while setting the wallpaper eval $WPSETTER $option "$wallpaper"
if [ $? -ne 0 ]; then
message "Something went wrong while setting the wallpaper.
Run '$WPSETTER $option "$wallpaper"' from an xterm to find out what." Run '$WPSETTER $option "$wallpaper"' from an xterm to find out what."
exit 1
fi
#remember previous wallpaper #remember previous wallpaper
[ ! "$remember" = false ] && remembercommand [ ! "$remember" = false ] && remembercommand
# Off course this returns 1 most of the time. # Off course this returns 1 most of the time.