Skip to content

Commit 2f08341

Browse files
投稿: iPhone真实储存容量 — by Silence
1 parent 439d104 commit 2f08341

2 files changed

Lines changed: 100 additions & 2 deletions

File tree

script_library/index.json

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 1,
3-
"data_version": 66,
4-
"updated": "2026-04-03T15:12:30.481Z",
3+
"data_version": 67,
4+
"updated": "2026-04-03T16:39:56Z",
55
"announcement": null,
66
"categories": [
77
{
@@ -1305,6 +1305,30 @@
13051305
"updated": null,
13061306
"status": "active",
13071307
"lines": 93
1308+
},
1309+
{
1310+
"id": "community_iphone真实储存容量__by_silence",
1311+
"name": "iPhone真实储存容量 — by Silence",
1312+
"name_en": "iPhone真实储存容量 — by Silence",
1313+
"desc": "[投稿] iPhone真实储存容量 — by Silence",
1314+
"desc_en": "[投稿] iPhone真实储存容量 — by Silence",
1315+
"category": "widgets",
1316+
"file": "scripts/widgets/iphone_mnj29d3s.py",
1317+
"thumbnail": null,
1318+
"version": 1,
1319+
"file_type": "py",
1320+
"author": "社区投稿",
1321+
"author_en": "社区投稿",
1322+
"tags": [
1323+
"community",
1324+
"widgets"
1325+
],
1326+
"requires": [],
1327+
"min_app_version": "1.5.0",
1328+
"added": "2026-04-03",
1329+
"updated": null,
1330+
"status": "active",
1331+
"lines": 74
13081332
}
13091333
]
13101334
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# 2026-4-3 Silence
2+
3+
import os
4+
from widget import Widget, family, MEDIUM
5+
6+
def get_storage_info():
7+
statvfs = os.statvfs('/')
8+
block_size = statvfs.f_frsize
9+
total = statvfs.f_blocks * block_size
10+
free = statvfs.f_bavail * block_size
11+
used = total - free
12+
used_percent = (used / total) * 100 if total else 0
13+
14+
total_gb = total / (1024**3)
15+
used_gb = used / (1024**3)
16+
free_gb = free / (1024**3)
17+
return total_gb, used_gb, free_gb, used_percent
18+
19+
def render_widget():
20+
total, used, free, percent = get_storage_info()
21+
22+
bar_width = int(200 * (percent / 100))
23+
bar_width = min(200, max(0, bar_width))
24+
25+
bg_color = ("#F1F5F9", "#0F172A")
26+
w = Widget(background=bg_color, padding=16)
27+
28+
with w.vstack(spacing=12):
29+
30+
with w.hstack():
31+
w.icon("internaldrive", size=18, color="#3B82F6")
32+
w.text("存储空间", size=14, weight="semibold", color=("#0F172A", "#F1F5F9"))
33+
w.spacer()
34+
w.text(f"{percent:.0f}%", size=12, weight="medium", color="#3B82F6")
35+
36+
37+
with w.hstack():
38+
w.spacer()
39+
with w.vstack():
40+
41+
w.text("", size=1)
42+
43+
pass
44+
45+
w.progress(percent / 100, color="#3B82F6", track_color=("#E2E8F0", "#334155"), height=8)
46+
47+
48+
with w.hstack():
49+
with w.vstack(align="leading", spacing=4):
50+
w.text("已用", size=11, color=("#64748B", "#94A3B8"))
51+
w.text(f"{used:.1f} GB", size=15, weight="bold", color=("#0F172A", "#F1F5F9"))
52+
w.spacer()
53+
with w.vstack(align="trailing", spacing=4):
54+
w.text("可用", size=11, color=("#64748B", "#94A3B8"))
55+
w.text(f"{free:.1f} GB", size=15, weight="bold", color=("#10B981", "#34D399"))
56+
w.spacer()
57+
with w.vstack(align="trailing", spacing=4):
58+
w.text("总计", size=11, color=("#64748B", "#94A3B8"))
59+
w.text(f"{total:.1f} GB", size=15, weight="bold", color=("#0F172A", "#F1F5F9"))
60+
61+
62+
if free < 5:
63+
w.text("⚠️剩余不足5G快去删点片吧⚠️", size=10, color="#EF4444", align="center")
64+
65+
w.render()
66+
67+
if family == MEDIUM:
68+
render_widget()
69+
else:
70+
w = Widget(background=("#FFFFFF", "#0B0F1A"), padding=16)
71+
with w.vstack(align="center", spacing=8):
72+
w.icon("internaldrive", size=30, color="#3B82F6")
73+
w.text("请使用中尺寸小组件", size=14, weight="semibold", color=("#111", "#EEE"))
74+
w.render()

0 commit comments

Comments
 (0)