这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions scripts/termux-wallpaper.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,55 @@ show_usage () {
echo "-h show this help"
echo "-f <file> set wallpaper from file"
echo "-u <url> set wallpaper from url resource"
echo "-l set wallpaper for lockscreen (Nougat and later)"
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 ;;
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!"
exit 1
fi
OPT_FILE="$path" ;;
u) OPT_URL="$OPTARG" ;;
c) OPT_CROP="$OPTARG" ;;
?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1 ;;
esac
done
Expand All @@ -49,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 "$@"