mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-29 21:35:13 +08:00
💋 Sync 2026-10-04 04:16:09
This commit is contained in:
1 parent
f6b2df73ec
commit
f62992fd80
745 files changed
+212416
-1173
No files matched your search
@@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Register NoobWrt as a LuCI theme (skip on upgrade)
|
||||
if [ "$PKG_UPGRADE" != 1 ]; then
|
||||
uci get luci.themes.NoobWrt >/dev/null 2>&1 || \
|
||||
uci batch <<-EOF
|
||||
set luci.themes.NoobWrt=/luci-static/noobwrt
|
||||
set luci.main.mediaurlbase=/luci-static/noobwrt
|
||||
commit luci
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Ensure the config file exists
|
||||
touch /etc/config/noobwrt
|
||||
|
||||
# Initialise global section type (only if section absent)
|
||||
uci get noobwrt.global >/dev/null 2>&1 || uci set noobwrt.global=global
|
||||
|
||||
# Set each global option only if not already present
|
||||
uci get noobwrt.global.mode >/dev/null 2>&1 || uci set noobwrt.global.mode=normal
|
||||
uci get noobwrt.global.primary >/dev/null 2>&1 || uci set noobwrt.global.primary='#7689f4'
|
||||
uci get noobwrt.global.dark_primary >/dev/null 2>&1 || uci set noobwrt.global.dark_primary='#7c8ff5'
|
||||
uci get noobwrt.global.blur >/dev/null 2>&1 || uci set noobwrt.global.blur=10
|
||||
uci get noobwrt.global.blur_dark >/dev/null 2>&1 || uci set noobwrt.global.blur_dark=10
|
||||
uci get noobwrt.global.transparency >/dev/null 2>&1 || uci set noobwrt.global.transparency=0.8
|
||||
uci get noobwrt.global.transparency_dark >/dev/null 2>&1 || uci set noobwrt.global.transparency_dark=0.8
|
||||
uci get noobwrt.global.online_wallpaper >/dev/null 2>&1 || uci set noobwrt.global.online_wallpaper=none
|
||||
uci get noobwrt.global.use_exact_resolution >/dev/null 2>&1 || uci set noobwrt.global.use_exact_resolution=1
|
||||
uci get noobwrt.global.auto_dark_mode >/dev/null 2>&1 || uci set noobwrt.global.auto_dark_mode=0
|
||||
|
||||
uci commit noobwrt
|
||||
|
||||
# Helper: seed a toolbar_item section and its fields if missing
|
||||
seed_toolbar() {
|
||||
local name="$1" title="$2" url="$3" icon="$4" enabled="$5" order="$6"
|
||||
uci get noobwrt."$name" >/dev/null 2>&1 || uci set noobwrt."$name"=toolbar_item
|
||||
uci get noobwrt."$name".title >/dev/null 2>&1 || uci set noobwrt."$name".title="$title"
|
||||
uci get noobwrt."$name".url >/dev/null 2>&1 || uci set noobwrt."$name".url="$url"
|
||||
uci get noobwrt."$name".icon >/dev/null 2>&1 || uci set noobwrt."$name".icon="$icon"
|
||||
uci get noobwrt."$name".enabled >/dev/null 2>&1 || uci set noobwrt."$name".enabled="$enabled"
|
||||
uci get noobwrt."$name".order >/dev/null 2>&1 || uci set noobwrt."$name".order="$order"
|
||||
}
|
||||
|
||||
seed_toolbar toolbar_home 'Home' '/cgi-bin/luci/admin/status/overview' home.png 1 1
|
||||
seed_toolbar toolbar_status 'Status' '/cgi-bin/luci/admin/modem/modemdata' signal.png 1 2
|
||||
seed_toolbar toolbar_modem 'Modem' '/cgi-bin/luci/admin/modem/qmodem' cell.png 0 3
|
||||
seed_toolbar toolbar_sms 'SMS' '/cgi-bin/luci/admin/modem/luci-app-sms-tool-js' sms.png 1 4
|
||||
seed_toolbar toolbar_data 'Data Usage' '/cgi-bin/luci/admin/tools/netstat' network.png 1 5
|
||||
seed_toolbar toolbar_nas 'NAS' '/cgi-bin/luci/admin/services/samba4' nas.png 0 6
|
||||
seed_toolbar toolbar_wireless 'Wireless' '/cgi-bin/luci/admin/network/wireless' wifi.png 1 7
|
||||
seed_toolbar toolbar_firewall 'Firewall' '/cgi-bin/luci/admin/network/firewall' firewall.png 0 8
|
||||
seed_toolbar toolbar_log 'System Log' '/cgi-bin/luci/admin/status/logs' info.png 0 9
|
||||
seed_toolbar toolbar_terminal 'Terminal' '/cgi-bin/luci/admin/system/ttyd' terminal.png 1 10
|
||||
seed_toolbar toolbar_vpn 'VPN' '/cgi-bin/luci/admin/services/passwall' vpn.png 0 11
|
||||
seed_toolbar toolbar_files 'Files' '/cgi-bin/luci/admin/nas/tinyfilemanager' files.png 1 12
|
||||
seed_toolbar toolbar_system 'Settings' '/cgi-bin/luci/admin/system/noobwrt' settings.png 1 13
|
||||
|
||||
uci commit noobwrt
|
||||
|
||||
# Ensure the rpcd wallpaper script is executable so ubus registers it
|
||||
chmod +x /usr/libexec/rpcd/luci.noobwrt_wallpaper 2>/dev/null
|
||||
|
||||
# Reload rpcd so luci.noobwrt_wallpaper is registered on first install
|
||||
# (only needed when rpcd is already running; harmless if it isn't yet)
|
||||
/etc/init.d/rpcd reload 2>/dev/null
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,136 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
CUSTOM_BG="/www/luci-static/noobwrt/background/custom.jpg"
|
||||
UPLOAD_TMP="/tmp/noobwrt_wallpaper.tmp"
|
||||
|
||||
# Online wallpaper source (bing/picsum/wikimedia or none) — no API key required
|
||||
WEB_PIC_SRC="$(uci -q get noobwrt.@global[0].online_wallpaper || echo 'bing')"
|
||||
|
||||
# Normalise legacy / unknown values to 'bing' so the case always matches
|
||||
case "$WEB_PIC_SRC" in
|
||||
bing|picsum|wikimedia|none) ;;
|
||||
*) WEB_PIC_SRC="bing" ;;
|
||||
esac
|
||||
|
||||
CACHE="/var/run/noobwrt_${WEB_PIC_SRC}.url"
|
||||
WRLOCK="/var/lock/noobwrt_${WEB_PIC_SRC}.lock"
|
||||
|
||||
fetch_pic_url() {
|
||||
case "$WEB_PIC_SRC" in
|
||||
bing)
|
||||
local picpath="$(wget -T5 -qO- \
|
||||
"https://www.bing.com/HPImageArchive.aspx?format=js&n=1" |
|
||||
jsonfilter -qe '@.images[0].url' |
|
||||
sed 's/1920x1080/UHD/g')"
|
||||
[ -n "${picpath}" ] && echo "https://www.bing.com${picpath}"
|
||||
;;
|
||||
picsum)
|
||||
# Lorem Picsum — free random photo, no API key needed
|
||||
# Follow the 302 redirect and cache the direct CDN image URL
|
||||
local seed="$(($(date '+%s') % 1000))"
|
||||
local cdnurl="$(wget -T5 -S -O /dev/null \
|
||||
"https://picsum.photos/seed/${seed}/1920/1080" 2>&1 |
|
||||
grep -i 'location:' | head -n1 |
|
||||
sed 's/.*[Ll]ocation: *//' | tr -d '\r\n')"
|
||||
if [ -n "$cdnurl" ]; then
|
||||
echo "$cdnurl"
|
||||
else
|
||||
echo "https://picsum.photos/seed/${seed}/1920/1080"
|
||||
fi
|
||||
;;
|
||||
wikimedia)
|
||||
# Wikimedia Commons Picture of the Day — free, no API key needed
|
||||
# Fetch the featured image URL from the Wikimedia REST API
|
||||
local today="$(date '+%Y/%m/%d')"
|
||||
wget -T5 -qO- \
|
||||
"https://api.wikimedia.org/feed/v1/wikipedia/en/featured/${today}" |
|
||||
jsonfilter -qe '@.image.image.source' 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
try_update() {
|
||||
local lock="$WRLOCK"
|
||||
exec 200>"$lock"
|
||||
|
||||
if flock -n 200 >/dev/null 2>&1; then
|
||||
local picurl="$(fetch_pic_url)"
|
||||
if [ -n "$picurl" ]; then
|
||||
echo "$picurl" | tee "$CACHE"
|
||||
else
|
||||
if [ -s "$CACHE" ]; then
|
||||
cat "$CACHE"
|
||||
else
|
||||
touch "$CACHE"
|
||||
fi
|
||||
fi
|
||||
flock -u 200 >/dev/null 2>&1
|
||||
elif [ -s "$CACHE" ]; then
|
||||
cat "$CACHE"
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"list")
|
||||
json_init
|
||||
json_add_object "get_url"
|
||||
json_close_object
|
||||
json_add_object "set_custom"
|
||||
json_close_object
|
||||
json_add_object "remove_custom"
|
||||
json_close_object
|
||||
json_dump
|
||||
json_cleanup
|
||||
;;
|
||||
"call")
|
||||
case "$2" in
|
||||
"set_custom")
|
||||
if [ -f "$UPLOAD_TMP" ]; then
|
||||
mv "$UPLOAD_TMP" "$CUSTOM_BG" && chmod 0644 "$CUSTOM_BG"
|
||||
echo '{ "result": 0 }'
|
||||
else
|
||||
echo '{ "result": 1, "error": "tmp file not found" }'
|
||||
fi
|
||||
;;
|
||||
"remove_custom")
|
||||
rm -f "$CUSTOM_BG"
|
||||
echo '{ "result": 0 }'
|
||||
;;
|
||||
"get_url")
|
||||
read -r input
|
||||
if [ "$WEB_PIC_SRC" = "none" ]; then
|
||||
echo '{ "url": "" }'
|
||||
exit 0
|
||||
fi
|
||||
if [ -f "$CACHE" ]; then
|
||||
idle_t="$(($(date '+%s') - $(date -r "$CACHE" '+%s' 2>/dev/null || echo '0')))"
|
||||
if [ -s "$CACHE" ]; then
|
||||
if [ "$idle_t" -le 43200 ]; then
|
||||
json_init
|
||||
json_add_string "url" "$(cat "$CACHE")"
|
||||
json_dump
|
||||
json_cleanup
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
# Empty cache file means a fetch is in progress or recently
|
||||
# failed — suppress retry for 120 s to avoid hammering the API
|
||||
if [ "$idle_t" -le 120 ]; then
|
||||
echo '{ "url": "" }'
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
json_init
|
||||
json_add_string "url" "$(try_update)"
|
||||
json_dump
|
||||
json_cleanup
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"admin/system/noobwrt": {
|
||||
"title": "NoobWrt Theme",
|
||||
"order": 80,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "noobwrt/settings"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"luci-theme-noobwrt": {
|
||||
"description": "Grant UCI read/write access and wallpaper upload for luci-theme-noobwrt",
|
||||
"read": {
|
||||
"uci": [ "noobwrt" ],
|
||||
"file": {
|
||||
"/www/luci-static/noobwrt/background/*": [ "read" ]
|
||||
}
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "noobwrt" ],
|
||||
"cgi-io": [ "upload" ],
|
||||
"file": {
|
||||
"/tmp/noobwrt_wallpaper.tmp": [ "write" ]
|
||||
},
|
||||
"ubus": {
|
||||
"luci.noobwrt_wallpaper": [ "set_custom", "remove_custom" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user