From bd29cf1f02d7b1ba71a00d37fafec713bb1dc20b Mon Sep 17 00:00:00 2001 From: Tom Kranz Date: Tue, 21 Jun 2022 15:57:39 +0200 Subject: [PATCH 1/2] Allow setting both wallpapers at once [2/2] --- scripts/termux-wallpaper.in | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/scripts/termux-wallpaper.in b/scripts/termux-wallpaper.in index 247bc72..380810b 100644 --- a/scripts/termux-wallpaper.in +++ b/scripts/termux-wallpaper.in @@ -7,10 +7,10 @@ show_usage () { echo "Change wallpaper on your device" echo echo "Usage: $SCRIPTNAME [options]" - echo "-h show this help" - echo "-f set wallpaper from file" - echo "-u set wallpaper from url resource" - echo "-l set wallpaper for lockscreen (Nougat and later)" + echo "-h show this help" + echo "-f set wallpaper from file" + echo "-u set wallpaper from url resource" + echo "-l [lock|home] set for lockscreen or homescreen only (Nougat and later)" exit 1 } @@ -22,7 +22,26 @@ while getopts :h,:l,f:,u: option do case "$option" in h) show_usage ;; - l) OPT_LS="true" ;; + l) #see https://stackoverflow.com/a/38697692 + lock=${!OPTIND} + case "$lock" in + -*|"") + OPT_LS=true + ;; + lock) + OPTIND=$((OPTIND + 1)) + OPT_LS=true + ;; + home) + OPTIND=$((OPTIND + 1)) + OPT_LS=false + ;; + *) + echo "$SCRIPTNAME: -l argument must be lock or home (if given)" + exit 1 + ;; + esac + ;; f) path="$(realpath "$OPTARG")" if [[ ! -f "$path" ]]; then echo "$SCRIPTNAME: $path is not a file!" From 7731f4f9a1044d1b8a27f14d546ca2d67e5fc93e Mon Sep 17 00:00:00 2001 From: Tom Kranz Date: Sat, 25 Jun 2022 12:18:53 +0200 Subject: [PATCH 2/2] Allow setting visible area of wallpaper [2/2] --- scripts/termux-wallpaper.in | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/termux-wallpaper.in b/scripts/termux-wallpaper.in index 380810b..579ae23 100644 --- a/scripts/termux-wallpaper.in +++ b/scripts/termux-wallpaper.in @@ -7,18 +7,27 @@ show_usage () { echo "Change wallpaper on your device" echo echo "Usage: $SCRIPTNAME [options]" - echo "-h show this help" - echo "-f set wallpaper from file" - echo "-u set wallpaper from url resource" - echo "-l [lock|home] set for lockscreen or homescreen only (Nougat and later)" + echo "-h show this help" + echo "-f set wallpaper from file" + echo "-u set wallpaper from url resource" + echo "-l [lock|home]" + echo " set for lockscreen or homescreen only (Nougat and later)" + echo "-c W{x:}H[+X+Y][%]" + echo " center visible area around rectangle of width W and height H," + echo " X pixels from the top and Y pixels from the left or" + echo " centered if no offset is given," + echo " : (instead of x) makes the size an aspect ratio," + echo " % makes size relative to original image size and" + echo " offsets relative to remaining space" exit 1 } OPT_LS="" +OPT_CROP="" OPT_FILE="" OPT_URL="" -while getopts :h,:l,f:,u: option +while getopts :h,:l,f:,u:,c: option do case "$option" in h) show_usage ;; @@ -49,6 +58,7 @@ do fi OPT_FILE="$path" ;; u) OPT_URL="$OPTARG" ;; + c) OPT_CROP="$OPTARG" ;; ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1 ;; esac done @@ -68,4 +78,5 @@ set -- [ -n "$OPT_LS" ] && set -- "$@" --ez lockscreen "$OPT_LS" [ -n "$OPT_FILE" ] && set -- "$@" --es file "$OPT_FILE" [ -n "$OPT_URL" ] && set -- "$@" --es url "$OPT_URL" +[ -n "$OPT_CROP" ] && set -- "$@" --es crop "$OPT_CROP" @TERMUX_PREFIX@/libexec/termux-api Wallpaper "$@"