Originally Posted by
mobilediesel
Yes, post the script you use to change wallpaper. It probably wouldn't take much to adjust it to show the name of the wallpaper.
Code:
#!/bin/bash
# Random wallpaper setter
#-------------------------------------------------------------------------------------
# Configuration
# Wallpaper directory
wpDir="/usr/share/backgrounds"
# Wallpaper list path
wpList=$HOME/.wallpaper-list
# Scale images that have a lower resolution than that of the screen (yes or no)
scaleLowerRes="yes"
#scaleLowerRes="no"
# Screen resolution
resWidth=1024
resHeight=768
# Command for tiling the wallpaper
cmdTile="feh --bg-tile"
#cmdTile="nitrogen --set-tiled --save"
# Command for scaling the wallpaper
cmdScale="feh --bg-scale"
#cmdScale="nitrogen --set-scaled --save"
# Command for centering the wallpaper
cmdCenter="feh --bg-center"
#cmdCenter="nitrogen --set-centered --save"
# End of configuration
#-------------------------------------------------------------------------------------
setTiled ()
{
`$cmdTile "$1"`
if [ "$?" = "0" ]; then
echo "Wallpaper tiled."
else
echo "Wallpaper not set!"
exit 1
fi
}
setScaled ()
{
`$cmdScale "$1"`
if [ "$?" = "0" ]; then
echo " "
else
echo ":-O"
exit 1
fi
}
setCentered ()
{
`$cmdCenter "$1"`
if [ "$?" = "0" ]; then
echo " "
else
echo ":-O"
exit 1
fi
}
createList ()
{
# Go to the wallpaper directory
cd "$wpDir"
# Load the list of pictures to a variable
wpDirList=`(find . -regex ".*\([jJ][pP][gG]\|[jJ][pP][eE][gG]\|[gG][iI][fF]\|[pP][nN][gG]\)$" -type f)`
# Save the list to disk
if [[ ( -w "$wpList" ) ]]; then
echo -n "$wpDirList" > "$wpList"
echo " "
else
echo ":-O"
exit 1
fi
}
getImage ()
{
# Count number of pictures in the wallpaper list by counting number of lines.
# Check if the wallpaper list exists, is not empty and we have read persmission on it
if [[ ( -s "$wpList" && -f "$wpList" ) && -r "$wpList" ]]
then
wpListNumber=$(wc -l < "$wpList")
else
echo ":-O";
exit 1
fi
# Counter for bad entries in wallpaper list
badMax=100
while true; do
# Find a random line number in the wallpaper list
# Random number from 1..n.
#r=$((RANDOM % $wpListNumber + 1))
r=$(echo $RANDOM%"$wpListNumber"+1 | bc)
# Print what the line number is
# Print the r'th line.
imgPath=`sed -n "$r{p;q;}" "$wpList"`
# #./ crops that substring but it doesn't matter if it left there
wpPath="${wpDir}${imgPath#./}"
# Check if the chosen file exists
if [ -f "$wpPath" ]; then
break
else
echo -e ":-O"
badMax=$(( $badMax - 1 ))
if [ "$badMax" == "0" ]; then
echo ":-O"
exit 1
fi
continue
fi
done
# Calculate size and aspect for chosen image and print out information
imgHeight=$(identify -format "%h" "$wpPath")
imgWidth=$(identify -format "%w" "$wpPath")
imgAspect=$(echo "scale=1; "$imgWidth"/"$imgHeight"" | bc)
echo -e " "
echo -e " "
echo -e " "
}
setWallpaper ()
{
# Calculate resolution aspect ratio
resAspect=$(echo "scale=1; "$resWidth"/"$resHeight"" | bc)
# If the image is smaller than the resolution and is not a tile then scale it, otherwise look at aspect
if [[ ("$scaleLowerRes" == "yes") && ( "$imgAspect" != "1.0" && ("$imgWidth" -lt "$resWidth" || "$imgHeight" -lt "$resHeight") ) ]]
then
setScaled "$wpPath"
else
case $imgAspect in
1.0)
setTiled "$wpPath"
;;
1.5 | 1.6 | 1.7 | 1.8)
if [[ "$resAspect" < "1.5" ]]; then
setCentered "$wpPath"
else
setScaled "$wpPath"
fi
;;
*)
if [[ "$resAspect" < "1.5" ]]; then
setScaled "$wpPath"
else
setCentered "$wpPath"
fi
;;
esac
fi
}
checkConfig ()
{
# Initial errors
errorsPresent="no"
# Check if all variables are set
if [[ !( ( -n "$wpDir" ) && ( -n "$wpList" ) && ( -n "$resWidth" ) && ( -n "$resHeight" ) && ( -n "$scaleLowerRes" ) && ( -n "$cmdTile" ) && ( -n "$cmdScale" ) && ( -n "$cmdCenter" ) ) ]]
then
echo -e ":-O"
exit 1
fi
# Check if there is a trailing backslash in the wallpaper directory
spDir=`echo -n "$wpDir" | tail -c -1`
if [[ !( "$spDir" == "/" ) ]]
then
wpDir=""$wpDir"/"
fi
# Check if there is read permission on wallpaper directory and if it is a directory
if [[ !( ( -r "$wpDir" ) && ( -d "$wpDir" ) ) ]]
then
echo "Can't read wallpaper directory!"
errorsPresent="yes"
fi
# Check if the specified wallpaper list is a regular file and not a directory
touch "$wpList" &> /dev/null
if [[ ( -d "$wpList" ) ]]
then
echo "Specified wallpaper list is a directory, not a file!"
errorsPresent="yes"
fi
# Check if variables are set correctly
if [[ !( "$scaleLowerRes" == "yes" || "$scaleLowerRes" == "no" ) ]]
then
echo "Specified option for scaling the wallpaper is not valid!"
errorsPresent="yes"
fi
if $(echo ""$resWidth"" | grep [^0-9] &>/dev/null)
then
echo "Specified resolution width is not a number!"
errorsPresent="yes"
fi
if $(echo ""$resHeight"" | grep [^0-9] &>/dev/null)
then
echo "Specified resolution height is not a number!"
errorsPresent="yes"
fi
# Check if any of the tests failed
if [[ "$errorsPresent" == "yes" ]]
then
echo -e "\nOne or more errors found, aborting!"
exit 1
fi
}
printUsage ()
{
echo -e "Invalid command line argument(s), usage:\n"
echo -e "-s | --set\t\tSet a wallpaper without updating the list"
echo -e "-u | --update\tUpdate the list without setting a wallpaper"
echo -e "-su | --set-update\tUpdate the list and set a wallpaper"
}
if [ "$#" == "1" ]; then
case "$1" in
"-s" | "--set")
checkConfig
getImage
setWallpaper
exit 0
;;
"-u" | "--update")
checkConfig
createList
exit 0
;;
"-su" | "--set-update")
checkConfig
createList
getImage
setWallpaper
exit 0
;;
*)
printUsage
exit 1
;;
esac
else
printUsage
exit 1
fi
and to run it
Code:
${execi 30 ~/scripts/auto-wall-paper.sh -su}
i'm usin fluxbox if its any help
Bookmarks