🐶 Sync 2025-11-02 14:26:26
This commit is contained in:
13
luci-theme-kucat/root/etc/uci-defaults/30_luci-kuacat
Normal file
13
luci-theme-kucat/root/etc/uci-defaults/30_luci-kuacat
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
if [ "$PKG_UPGRADE" != 1 ]; then
|
||||
uci get luci.themes.KuCat >/dev/null 2>&1 || \
|
||||
uci batch <<-EOF
|
||||
set luci.themes.KuCat=/luci-static/kucat
|
||||
set luci.main.mediaurlbase=/luci-static/kucat
|
||||
commit luci
|
||||
EOF
|
||||
fi
|
||||
chmod +x /usr/libexec/kucat/kucat*
|
||||
|
||||
rm -rf /tmp/luci-*
|
||||
exit 0
|
||||
99
luci-theme-kucat/root/usr/libexec/kucat/kucat_wallpaper
Normal file
99
luci-theme-kucat/root/usr/libexec/kucat/kucat_wallpaper
Normal file
@@ -0,0 +1,99 @@
|
||||
#!/bin/sh
|
||||
|
||||
# luci-theme-kucat
|
||||
# Copyright (C) 2019-2025 The Sirpdboy Team <herboy2008@gmail.com>
|
||||
#
|
||||
# Have a bug? Please create an issue here on GitHub!
|
||||
# https://github.com/sirpdboy/luci-theme-kucat/issues
|
||||
#
|
||||
# Licensed to the public under the Apache License 2.0
|
||||
|
||||
# author github@sirpdboy
|
||||
|
||||
kucat='kucat'
|
||||
[ -s "/etc/config/advancedplus" ] &&kucat='advancedplus'
|
||||
background="$(uci -q get $kucat.@basic[0].background || echo '0')"
|
||||
KUCATTMP="/var/kucat_date_${background}.tmp"
|
||||
BGURL="/www/luci-static/kucat/img/down${background}.jpg"
|
||||
REBGURL="/luci-static/kucat/img/down${background}.jpg"
|
||||
DFBGURL="/luci-static/kucat/img/bg1.jpg"
|
||||
WRLOCK="/var/lock/kucat_lock_${background}.lock"
|
||||
|
||||
test_url() {
|
||||
url=$1
|
||||
local status=$(/usr/bin/curl -I -o /dev/null -skL --connect-timeout 1 --retry 1 -w %{http_code} "$url")
|
||||
case "$status" in
|
||||
204|\
|
||||
200)
|
||||
echo '1'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
curl_bgurl() {
|
||||
case "$background" in
|
||||
1)
|
||||
local ppath=`curl -s 'https://open.iciba.com/dsapi/' | jsonfilter -qe '@.picture4'`
|
||||
[ -n "${ppath}" ] && echo "$ppath"
|
||||
;;
|
||||
2)
|
||||
curl -fks --max-time 3 \
|
||||
--header "Authorization: Client-ID kmFIroj2ELqXJPtC0XUoyww-Tr_lDU8Ho8uxjptIrCo" \
|
||||
"https://api.unsplash.com/photos/random?count=1&orientation=landscape" |
|
||||
jsonfilter -e "@[0]['urls']['regular']"
|
||||
;;
|
||||
3)
|
||||
local ppath=`curl -s "https://www.bing.com/HPImageArchive.aspx?format=js&n=1" |jsonfilter -qe '@.images[0].url'`
|
||||
[ -n "${ppath}" ] && echo "https://www.bing.com${ppath}"
|
||||
;;
|
||||
4)
|
||||
local i=`awk 'BEGIN{srand();print int(rand()*8)}'`
|
||||
local j=`awk 'BEGIN{srand();print int(rand()*200)}'`
|
||||
local ppath=`curl -s "http://wp.birdpaper.com.cn/intf/search?content=4k&pageno=$j&count=9" | awk -F '\"count\":9' '{print $2}' | awk -F ',\"processTime\"' '{print $1}' | sed 's#,#{#' | jsonfilter -e "@.list[$i].url"`
|
||||
[ -n "${ppath}" ] && echo "$ppath"
|
||||
;;
|
||||
5)
|
||||
curl -fks --max-time 3 \
|
||||
"https://wallhaven.cc/api/v1/search?resolutions=1920x1080&sorting=random" |
|
||||
jsonfilter -qe '@.data[0].path'
|
||||
;;
|
||||
|
||||
esac
|
||||
}
|
||||
|
||||
bgurl_down() {
|
||||
local lock="$WRLOCK"
|
||||
exec 200>$lock
|
||||
if flock -n 200 >/dev/null 2>&1; then
|
||||
local bgurl="$(curl_bgurl)"
|
||||
if [ -n "$bgurl" ]; then
|
||||
rm -rf $BGURL
|
||||
curl -kLfsm 3 $bgurl -o $BGURL
|
||||
date +%Y%m%d > $KUCATTMP
|
||||
fi
|
||||
|
||||
flock -u 200 >/dev/null 2>&1
|
||||
fi
|
||||
[ -s "$BGURL" ] && echo -ne $REBGURL || echo -ne $DFBGURL
|
||||
}
|
||||
|
||||
check_url() {
|
||||
if [ -s $KUCATTMP ]; then
|
||||
localtime=`cat $KUCATTMP | grep $(date +%Y%m%d) `
|
||||
if [ $localtime ]; then
|
||||
if [ -s $BGURL ] ; then
|
||||
echo -ne $REBGURL
|
||||
return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# local checknet=$(test_url "https://www.baidu.com")
|
||||
checknet=`ping -c 1 -W 1 223.5.5.5 > /dev/null 2>&1 &&echo 1 || echo 2`
|
||||
if [ "x$checknet" == "x1" ]; then
|
||||
bgurl_down
|
||||
else
|
||||
[ -s "$DFBGURL" ] && echo -ne $DFBGURL
|
||||
fi
|
||||
}
|
||||
|
||||
check_url
|
||||
96
luci-theme-kucat/root/usr/libexec/kucat/kucat_word
Normal file
96
luci-theme-kucat/root/usr/libexec/kucat/kucat_word
Normal file
@@ -0,0 +1,96 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
# luci-theme-kucat
|
||||
# Copyright (C) 2019-2024 The Sirpdboy Team <herboy2008@gmail.com>
|
||||
#
|
||||
# Have a bug? Please create an issue here on GitHub!
|
||||
# https://github.com/sirpdboy/luci-theme-kucat/issues
|
||||
#
|
||||
# Licensed to the public under the Apache License 2.0
|
||||
LANG=`uci get luci.main.lang`
|
||||
WORDDATETMP="/var/dayword_kucatword_date.tmp"
|
||||
LOCK="/var/lock/dayword_kucatword.lock"
|
||||
WORDTMP="/var/dayword_kucatword_$LANG.tmp"
|
||||
test_url() {
|
||||
url=$1
|
||||
status="$(/usr/bin/curl -I -o /dev/null -skL --connect-timeout 1 --retry 1 -w %{http_code} "$url")"
|
||||
case "$status" in
|
||||
204|\
|
||||
200)
|
||||
echo '1'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
get_word() {
|
||||
kucat='kucat'
|
||||
[ -s "/etc/config/advancedplus" ] &&kucat='advancedplus'
|
||||
dayword="$(uci -q get $kucat.@basic[0].dayword || echo '0')"
|
||||
case "$dayword" in
|
||||
1)
|
||||
[ "X$LANG" == "Xen" ] && gwordjson=`curl -s 'https://open.iciba.com/dsapi/' | jsonfilter -qe '@.content'` || gwordjson=`curl -s 'https://open.iciba.com/dsapi/' | jsonfilter -qe '@.note'`
|
||||
[ -n "${gwordjson}" ] && echo "$gwordjson"
|
||||
;;
|
||||
2)
|
||||
# form iciba : https://api.vvhan.com/api/en
|
||||
[ "X$LANG" == "Xen" ] && gwordjson=`curl -s 'https://api.vvhan.com/api/en?type=sj'| jsonfilter -qe '@.data.zh'` || gwordjson=`curl -s 'https://api.vvhan.com/api/en?type=sj'| jsonfilter -qe '@.data.en'`
|
||||
[ -n "${gwordjson}" ] && echo "$gwordjson"
|
||||
;;
|
||||
3)
|
||||
local gwordjson=`curl -s 'https://api.yixiangzhilv.com/yiyan/sentence/get/'`
|
||||
local gword=`echo $gwordjson | jsonfilter -qe '@.content'`
|
||||
local gfrom=`echo $gwordjson | jsonfilter -qe '@.author'`
|
||||
[ -n "${gfrom}" ] && gfrom=$(echo " ---- $gfrom")|| gfrom=''
|
||||
[ -n "${gword}" ] && echo "$gword $gfrom"
|
||||
;;
|
||||
4)
|
||||
local gwordjson=`curl -s 'https://yijuzhan.com/api/word.php?m=json'`
|
||||
local gword=`echo $gwordjson | jsonfilter -qe '@.content'`
|
||||
local gfrom=`echo $gwordjson | jsonfilter -qe '@.source'`
|
||||
[ -n "${gfrom}" ] && gfrom=$(echo " ---- $gfrom")|| gfrom=''
|
||||
[ -n "${gword}" ] && echo "$gword $gfrom"
|
||||
;;
|
||||
5)
|
||||
local gword=`curl -s https://v.api.aa1.cn/api/api-wenan-dujitang/index.php?aa1=json | sed 's/\[//g' | sed 's/\]//g'| jsonfilter -qe '@.dujitang'`
|
||||
[ -n "${gword}" ] && echo "$gword"
|
||||
;;
|
||||
|
||||
*)
|
||||
local gwordjson=`curl -s 'https://v1.hitokoto.cn'`
|
||||
local gword=`echo $gwordjson | jsonfilter -qe '@.hitokoto'`
|
||||
local gfrom=`echo $gwordjson | jsonfilter -qe '@.from_who'`
|
||||
[ -n "${gfrom}" ] && gfrom=$(echo " ---- $gfrom")|| gfrom=''
|
||||
[ -n "${gword}" ] && echo "$gword $gfrom"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
kucatword() {
|
||||
lock="$LOCK"
|
||||
exec 200>"$lock"
|
||||
if flock -n 200 >"/dev/null" 2>&1; then
|
||||
local localword="$(get_word)"
|
||||
if [ -n "$localword" ]; then
|
||||
echo "$localword" >$WORDTMP
|
||||
date +%Y%m%d > $WORDDATETMP
|
||||
fi
|
||||
flock -u 200 >"/dev/null" 2>&1
|
||||
fi
|
||||
[ -s "$WORDTMP" ] && cat $WORDTMP || echo -ne "Acquisition failed ,Please Issues:github@sirpdboy"
|
||||
}
|
||||
check_url() {
|
||||
if [ -f "$WORDDATETMP" ]; then
|
||||
localtime=`cat $WORDDATETMP | grep $(date +%Y%m%d) `
|
||||
if [ $localtime ]; then
|
||||
[ -s "$WORDTMP" ] && cat $WORDTMP && return
|
||||
fi
|
||||
fi
|
||||
local checknet=`ping -c 1 -W 1 223.5.5.5 > /dev/null 2>&1 &&echo 1 || echo 2`
|
||||
if [ "x$checknet" == "x1" ]; then
|
||||
kucatword
|
||||
else
|
||||
echo -ne "No internet connection, no information."
|
||||
fi
|
||||
}
|
||||
check_url
|
||||
Reference in New Issue
Block a user