add image support
This commit is contained in:
parent
bfc9cd017b
commit
cc646e1c01
|
@ -21,6 +21,8 @@ SWAL_DEFAULT_CONFIG()
|
||||||
SWAL_IMAGE_VIEWER="nsxiv -ato" # Image viewer to use (<char>)
|
SWAL_IMAGE_VIEWER="nsxiv -ato" # Image viewer to use (<char>)
|
||||||
SWAL_USE_WAL=true # Whether or not to use Pywal if possible (true/false)
|
SWAL_USE_WAL=true # Whether or not to use Pywal if possible (true/false)
|
||||||
SWAL_RANDOMIZE=false # Select a random wallpaper on login
|
SWAL_RANDOMIZE=false # Select a random wallpaper on login
|
||||||
|
SWAL_USE_IMAGE=false # Have image support
|
||||||
|
SWAL_IMAGE_SIZE="200" # Image size
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create the configuration
|
# Create the configuration
|
||||||
|
@ -78,6 +80,8 @@ SWAL_MKCONFIG() {
|
||||||
printf "\nSWAL_IMAGE_VIEWER='$SWAL_IMAGE_VIEWER'" >> $SWAL_EXPORTDIR/swalrc
|
printf "\nSWAL_IMAGE_VIEWER='$SWAL_IMAGE_VIEWER'" >> $SWAL_EXPORTDIR/swalrc
|
||||||
printf "\nSWAL_USE_WAL=$SWAL_USE_WAL_NEW" >> $SWAL_EXPORTDIR/swalrc
|
printf "\nSWAL_USE_WAL=$SWAL_USE_WAL_NEW" >> $SWAL_EXPORTDIR/swalrc
|
||||||
printf "\nSWAL_RANDOMIZE=$SWAL_RANDOMIZE" >> $SWAL_EXPORTDIR/swalrc
|
printf "\nSWAL_RANDOMIZE=$SWAL_RANDOMIZE" >> $SWAL_EXPORTDIR/swalrc
|
||||||
|
printf "\nSWAL_USE_IMAGE=$SWAL_USE_IMAGE" >> $SWAL_EXPORTDIR/swalrc
|
||||||
|
printf "\nSWAL_IMAGE_SIZE=$SWAL_IMAGE_SIZE" >> $SWAL_EXPORTDIR/swalrc
|
||||||
}
|
}
|
||||||
|
|
||||||
# Binary directory
|
# Binary directory
|
||||||
|
@ -125,8 +129,28 @@ SWAL_USAGE() {
|
||||||
# Select wallpaper
|
# Select wallpaper
|
||||||
SWAL_SELWALLPAPER()
|
SWAL_SELWALLPAPER()
|
||||||
{
|
{
|
||||||
|
LIST_IMG() {
|
||||||
|
for i in $(seq "$(ls "$SWAL_WALLPAPERDIR" | wc -l)"); do
|
||||||
|
CUR_IMAGE="$(ls "$SWAL_WALLPAPERDIR" | sed -n ${i},${i}p)"
|
||||||
|
CUR_IMAGE_PATH="$SWAL_WALLPAPERDIR/$CUR_IMAGE"
|
||||||
|
|
||||||
|
if [ "$SWAL_USE_IMAGE" = "true" ]; then
|
||||||
|
printf "IMG:$CUR_IMAGE_PATH\t$CUR_IMAGE\n"
|
||||||
|
else
|
||||||
|
printf "$CUR_IMAGE\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$SWAL_USE_IMAGE" = "true" ]; then
|
||||||
|
IMG_ARG="-is"
|
||||||
|
else
|
||||||
|
SWAL_IMAGE_SIZE=""
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$ARG1" = "" ]; then
|
if [ "$ARG1" = "" ]; then
|
||||||
SWAL_SELWALLPAPER="$(printf "$(ls "$SWAL_WALLPAPERDIR")\n------\n..\nPreview\nPrevious\nRandom\nFavorites\nAdd used wallpaper to favorites\nOptions\nHelp\nExit" | $RUNLAUNCHER -g 1 -l 100 -p "What wallpaper would you like to set?")"
|
SWAL_SELWALLPAPER="$(printf "$(LIST_IMG)\n------\n..\nPreview\nPrevious\nRandom\nFavorites\nAdd used wallpaper to favorites\nOptions\nHelp\nExit" | $RUNLAUNCHER -g 1 -l 100 -p "What wallpaper would you like to set?" $IMG_ARG $SWAL_IMAGE_SIZE)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +205,7 @@ SWAL_SETTYPE()
|
||||||
|
|
||||||
# Fail if the wallpaper is not a proper wallpaper.
|
# Fail if the wallpaper is not a proper wallpaper.
|
||||||
FAIL_NOT_REAL() {
|
FAIL_NOT_REAL() {
|
||||||
command -v notify-send > /dev/null && notify-send "The selected wallpaper is not valid/does not exist."
|
#command -v notify-send > /dev/null && notify-send "The selected wallpaper is not valid/does not exist."
|
||||||
$0 ; exit 1
|
$0 ; exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +214,7 @@ SWAL_SETTYPE()
|
||||||
# don't set type if using argument
|
# don't set type if using argument
|
||||||
if [ "$SWAL_ASK_TYPE" != "false" ]; then
|
if [ "$SWAL_ASK_TYPE" != "false" ]; then
|
||||||
if [ "$ARG1" = "" ]; then
|
if [ "$ARG1" = "" ]; then
|
||||||
|
[ -z "$SWAL_SELWALLPAPER" ] && exit 0
|
||||||
SWAL_TYPE=$(printf "Center\nTile\nZoom\nStretch\n------\nExit" | $RUNLAUNCHER -p "How do you want to set the wallpaper?" -g 1 -l 7)
|
SWAL_TYPE=$(printf "Center\nTile\nZoom\nStretch\n------\nExit" | $RUNLAUNCHER -p "How do you want to set the wallpaper?" -g 1 -l 7)
|
||||||
else
|
else
|
||||||
SWAL_TYPE="Stretch"
|
SWAL_TYPE="Stretch"
|
||||||
|
|
Loading…
Reference in a new issue