恢复在线壁纸
This commit is contained in:
parent
f5a3312827
commit
da6a2422d6
@ -49,6 +49,14 @@ return view.extend({
|
|||||||
s.addremove = false;
|
s.addremove = false;
|
||||||
s.anonymous = true;
|
s.anonymous = true;
|
||||||
|
|
||||||
|
o = s.option(form.ListValue, 'online_wallpaper', _('Wallpaper source'));
|
||||||
|
o.value('none', _('Built-in'));
|
||||||
|
o.value('bing', _('Bing'));
|
||||||
|
o.value('unsplash', _('Unsplash'));
|
||||||
|
o.value('wallhaven', _('Wallhaven'));
|
||||||
|
o.default = 'bing';
|
||||||
|
o.rmempty = false;
|
||||||
|
|
||||||
o = s.option(form.ListValue, 'mode', _('Theme mode'));
|
o = s.option(form.ListValue, 'mode', _('Theme mode'));
|
||||||
o.value('normal', _('Follow system'));
|
o.value('normal', _('Follow system'));
|
||||||
o.value('light', _('Light mode'));
|
o.value('light', _('Light mode'));
|
||||||
|
@ -6,4 +6,5 @@ config global
|
|||||||
option transparency '0.2'
|
option transparency '0.2'
|
||||||
option transparency_dark '0.2'
|
option transparency_dark '0.2'
|
||||||
option mode 'normal'
|
option mode 'normal'
|
||||||
|
option online_wallpaper 'bing'
|
||||||
|
|
||||||
|
14
luci-app-argon-config/root/etc/uci-defaults/luci-argon-config
Executable file
14
luci-app-argon-config/root/etc/uci-defaults/luci-argon-config
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
bing_background="$(uci -q get "argon.@global[0].bing_background")"
|
||||||
|
[ -n "$bing_background" ] || exit 0
|
||||||
|
|
||||||
|
if [ "$bing_background" = "1" ]; then
|
||||||
|
uci -q set "argon.@global[0].online_wallpaper"="bing"
|
||||||
|
else
|
||||||
|
uci -q set "argon.@global[0].online_wallpaper"="none"
|
||||||
|
fi
|
||||||
|
uci -q delete "argon.@global[0].bing_background"
|
||||||
|
uci -q commit "argon"
|
||||||
|
|
||||||
|
exit 0
|
@ -7,6 +7,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
LUCI_TITLE:=Argon Theme
|
LUCI_TITLE:=Argon Theme
|
||||||
|
LUCI_DEPENDS:=+curl +jsonfilter
|
||||||
PKG_VERSION:=2.3.1
|
PKG_VERSION:=2.3.1
|
||||||
PKG_RELEASE:=20230420
|
PKG_RELEASE:=20230420
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
登录页面背景图片目录
|
登录页面背景图片目录
|
||||||
|
|
||||||
支持格式:jpg、png、gif、webp、mp4
|
支持格式:jpg、png、gif、webp、mp4、webm
|
||||||
|
@ -23,12 +23,16 @@
|
|||||||
|
|
||||||
<%+themes/argon/out_header_login%>
|
<%+themes/argon/out_header_login%>
|
||||||
<%
|
<%
|
||||||
local util = require "luci.util"
|
local util = require "luci.util"
|
||||||
local boardinfo = util.ubus("system", "board")
|
local fs = require "nixio.fs"
|
||||||
local fs = require "nixio.fs"
|
local nutil = require "nixio.util"
|
||||||
local nutil = require "nixio.util"
|
local json = require "luci.jsonc"
|
||||||
|
local sys = require "luci.sys"
|
||||||
|
local uci = require 'luci.model.uci'.cursor()
|
||||||
|
|
||||||
function glob(...)
|
-- Fetch Local Background Media
|
||||||
|
|
||||||
|
local function glob(...)
|
||||||
local iter, code, msg = fs.glob(...)
|
local iter, code, msg = fs.glob(...)
|
||||||
if iter then
|
if iter then
|
||||||
return nutil.consume(iter)
|
return nutil.consume(iter)
|
||||||
@ -37,37 +41,70 @@
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function getExtension(str)
|
|
||||||
return str:match(".+%.(%w+)$")
|
|
||||||
end
|
|
||||||
|
|
||||||
local bgcount = 0
|
local imageTypes = " jpg png gif webp "
|
||||||
local currentBg = {}
|
local videoTypes = " mp4 webm "
|
||||||
local bgs,attr = {}
|
local allTypes = imageTypes .. videoTypes
|
||||||
local theme_dir = media .. "/background/"
|
local function fetchMedia(path, themeDir)
|
||||||
for i, f in ipairs(glob("/www" .. theme_dir .. "*")) do
|
local backgroundTable = {}
|
||||||
attr = fs.stat(f)
|
local backgroundCount = 0
|
||||||
if attr then
|
for i, f in ipairs(glob(path)) do
|
||||||
local ext = getExtension(fs.basename(f))
|
attr = fs.stat(f)
|
||||||
if ext == "jpg" or ext == "png" or ext == "webp" or ext == "gif" or ext == "mp4" then
|
if attr then
|
||||||
local bg = {}
|
local ext = fs.basename(f):match(".+%.(%w+)$")
|
||||||
bg.type = ext
|
if ext ~= nil then
|
||||||
bg.url = theme_dir .. fs.basename(f)
|
ext = ext:lower()
|
||||||
table.insert(bgs,bg)
|
end
|
||||||
bgcount = bgcount + 1
|
if ext ~= nil and string.match(allTypes, " "..ext.." ") ~= nil then
|
||||||
|
local bg = {}
|
||||||
|
bg.type = ext
|
||||||
|
bg.url = themeDir .. fs.basename(f)
|
||||||
|
table.insert(backgroundTable, bg)
|
||||||
|
backgroundCount = backgroundCount + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return backgroundTable, backgroundCount
|
||||||
|
end
|
||||||
|
local function selectBackground(themeDir)
|
||||||
|
local bgUrl = media .. "/img/bg.webp"
|
||||||
|
local backgroundType = "Image"
|
||||||
|
local mimeType = ""
|
||||||
|
|
||||||
|
if fs.access("/etc/config/argon") then
|
||||||
|
local online_wallpaper = uci:get_first('argon', 'global', 'online_wallpaper') or (uci:get_first('argon', 'global', 'bing_background') == '1' and 'bing')
|
||||||
|
if (online_wallpaper and online_wallpaper ~= "none") then
|
||||||
|
local picurl = sys.exec("/usr/libexec/argon/online_wallpaper")
|
||||||
|
if (picurl and picurl ~= '') then
|
||||||
|
return picurl, "Image", ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local backgroundTable, backgroundCount = fetchMedia("/www" .. themeDir .. "*", themeDir)
|
||||||
|
if ( backgroundCount > 0 ) then
|
||||||
|
local currentBg = backgroundTable[math.random(1, backgroundCount)]
|
||||||
|
bgUrl = currentBg.url
|
||||||
|
if (string.match(videoTypes, " "..currentBg.type.." ") ~= nil) then
|
||||||
|
backgroundType = "Video"
|
||||||
|
mimeType = "video/" .. currentBg.type
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return bgUrl, backgroundType, mimeType
|
||||||
end
|
end
|
||||||
|
|
||||||
if bgcount > 0 then
|
local boardinfo = util.ubus("system", "board")
|
||||||
currentBg = bgs[math.random(1,bgcount)]
|
local themeDir = media .. "/background/"
|
||||||
end
|
local bgUrl, backgroundType, mimeType = selectBackground(themeDir)
|
||||||
%>
|
%>
|
||||||
|
<!-- Login Page Start -->
|
||||||
<div class="login-page">
|
<div class="login-page">
|
||||||
<% if (bgcount > 0 and currentBg.type == "mp4") then %>
|
<% if ( backgroundType == "Video" ) then %>
|
||||||
|
<!-- Video Player Start -->
|
||||||
<div class="video">
|
<div class="video">
|
||||||
<video autoplay loop muted id="video">
|
<video autoplay loop muted id="video">
|
||||||
<source src="<%=currentBg.url%>" type="video/mp4">
|
<source src="<%=bgUrl%>" type="<%=mimeType%>">
|
||||||
</video>
|
</video>
|
||||||
</div>
|
</div>
|
||||||
<div class="volume-control mute"></div>
|
<div class="volume-control mute"></div>
|
||||||
@ -82,18 +119,21 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<% else
|
<!-- Video Player End -->
|
||||||
local bg_url = media .. "/img/bg.webp"
|
<% else %>
|
||||||
if (bgcount > 0 and currentBg["type"] ~= "mp4") then
|
<!-- Image Background Start -->
|
||||||
bg_url = currentBg.url
|
<div class="main-bg" id="main-bg" style="background-image:url(<%=bgUrl%>)"></div>
|
||||||
end
|
<!-- Image Background End -->
|
||||||
%>
|
|
||||||
<div class="main-bg" id="main-bg" style="background-image:url(<%=bg_url%>)"></div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<!-- Login Container Start -->
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
<div class="login-form">
|
<div class="login-form">
|
||||||
<a class="brand" href="/"><img src="<%=media%>/img/argon.svg" class="icon"><span
|
<!-- Logo Start -->
|
||||||
class="brand-text"><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %></span></a>
|
<a class="brand" href="/"><img src="<%=media%>/img/argon.svg" class="icon">
|
||||||
|
<span class="brand-text"><%=striptags( (boardinfo.hostname or "?") ) %></span>
|
||||||
|
</a>
|
||||||
|
<!-- Logo End -->
|
||||||
|
<!-- Login Form Start -->
|
||||||
<form class="form-login" method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>">
|
<form class="form-login" method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>">
|
||||||
|
|
||||||
<%- if fuser then %>
|
<%- if fuser then %>
|
||||||
@ -114,7 +154,7 @@
|
|||||||
<input type="submit" value="<%:Login%>" class="cbi-button cbi-button-apply" />
|
<input type="submit" value="<%:Login%>" class="cbi-button cbi-button-apply" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<!-- Login Form End -->
|
||||||
<script type="text/javascript">//<![CDATA[
|
<script type="text/javascript">//<![CDATA[
|
||||||
var input = document.getElementsByName('luci_password')[0];
|
var input = document.getElementsByName('luci_password')[0];
|
||||||
if (input)
|
if (input)
|
||||||
|
75
luci-theme-argon/root/usr/libexec/argon/online_wallpaper
Executable file
75
luci-theme-argon/root/usr/libexec/argon/online_wallpaper
Executable file
@ -0,0 +1,75 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# author jjm2473
|
||||||
|
|
||||||
|
# the script will be excuted when `argon.@global[0].bing_background == '1'`
|
||||||
|
# defaults to 'bing' to be compatible with old config
|
||||||
|
WEB_PIC_SRC=$(uci -q get argon.@global[0].online_wallpaper || echo 'bing')
|
||||||
|
CACHE=/var/run/argon_${WEB_PIC_SRC}.url
|
||||||
|
WRLOCK=/var/lock/argon_${WEB_PIC_SRC}.lock
|
||||||
|
|
||||||
|
fetch_pic_url() {
|
||||||
|
case $WEB_PIC_SRC in
|
||||||
|
bing)
|
||||||
|
local picpath=$(curl -fks --max-time 3 \
|
||||||
|
"https://www.bing.com/HPImageArchive.aspx?format=js&n=1" |
|
||||||
|
jsonfilter -qe '@.images[0].url')
|
||||||
|
[ -n "${picpath}" ] && echo "//www.bing.com${picpath}"
|
||||||
|
;;
|
||||||
|
unsplash)
|
||||||
|
curl -fks --max-time 3 \
|
||||||
|
"https://source.unsplash.com/1920x1080/daily?wallpapers" |
|
||||||
|
sed -E 's#^.*href="([^?]+)\?.*$#\1?fm=jpg\&fit=crop\&w=1920\&h=1080#'
|
||||||
|
;;
|
||||||
|
unsplash_*)
|
||||||
|
local collection_id=${WEB_PIC_SRC#unsplash_}
|
||||||
|
curl -fks --max-time 3 \
|
||||||
|
"https://source.unsplash.com/collection/${collection_id}/1920x1080" |
|
||||||
|
sed -E 's#^.*href="([^?]+)\?.*$#\1?fm=jpg\&fit=crop\&w=1920\&h=1080#'
|
||||||
|
;;
|
||||||
|
wallhaven)
|
||||||
|
curl -fks --max-time 3 \
|
||||||
|
"https://wallhaven.cc/api/v1/search?resolutions=1920x1080&sorting=random" |
|
||||||
|
jsonfilter -qe '@.data[0].path'
|
||||||
|
;;
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
get_url() {
|
||||||
|
if [ -f "$CACHE" ]; then
|
||||||
|
local idle_t=$(($(date '+%s') - $(date -r "$CACHE" '+%s' 2>/dev/null || echo '0')))
|
||||||
|
if [ -s "$CACHE" ]; then
|
||||||
|
if [ $idle_t -le 43200 ]; then
|
||||||
|
cat "$CACHE"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ $idle_t -le 120 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
try_update
|
||||||
|
}
|
||||||
|
|
||||||
|
get_url
|
Loading…
x
Reference in New Issue
Block a user