Skip to content

Commit 762ee37

Browse files
committed
Hello World
0 parents  commit 762ee37

File tree

5 files changed

+167
-0
lines changed

5 files changed

+167
-0
lines changed

Logo128x152.bmp

9.62 KB
Binary file not shown.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
To build the package, run
2+
3+
```
4+
mfa.py <build-package.script
5+
```
6+
7+
in Screenfetch directory.

Screenfetch.HC

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#define OS_NAME "$TX+CX,"TempleOS",D="DD_OS_NAME_VERSION"$"
2+
3+
U8 buf[256];
4+
U8* screenfetch_dir = __DIR__;
5+
6+
U0 Line(U8* label=NULL, U8* value=NULL) {
7+
" ";
8+
9+
if (label)
10+
"$FG,3$%s", label;
11+
12+
if (label && value)
13+
"" ": ";
14+
15+
if (value)
16+
"$FG,8$%s", value;
17+
18+
'' '\n';
19+
}
20+
21+
I64 GetNumFilesInDirectory(U8* dir) {
22+
CDirEntry* de;
23+
try {
24+
de = FilesFind(dir);
25+
}
26+
catch {
27+
de = NULL;
28+
}
29+
30+
if (!de)
31+
return -1;
32+
33+
I64 count = 0;
34+
35+
CDirEntry* de2 = de;
36+
while (de2) {
37+
if (!(de2->attr & RS_ATTR_DIR)) {
38+
count++;
39+
}
40+
de2 = de2->next;
41+
}
42+
43+
DirTreeDel(de);
44+
return count;
45+
}
46+
47+
CHashFun* FindFunction(U8* name) {
48+
CHash* result = HashFind(name, Fs->hash_table, HTT_FUN);
49+
50+
if (result && (result->type & HTT_FUN) != 0)
51+
return result(CHashFun *);
52+
else
53+
return NULL;
54+
}
55+
56+
U8* DetectCPU() {
57+
StrPrint(buf, "%d core(s)", mp_cnt);
58+
return buf;
59+
}
60+
61+
U8* DetectFont() {
62+
// FIXME: Actually detect - but how?
63+
// If there was something like a global hash-table,
64+
// we could use it to mark user Fonts & Palettes
65+
return "FontStd.HC";
66+
}
67+
68+
U8* DetectNumPackages() {
69+
I64 num_packages = GetNumFilesInDirectory("::/Misc/Packages");
70+
71+
if (num_packages < 0)
72+
num_packages = 0;
73+
74+
StrPrint(buf, "%d", num_packages);
75+
return buf;
76+
}
77+
78+
U8* DetectRAM() {
79+
I64 ram_used = sys_code_bp->used_u8s;
80+
I64 ram_total = sys_code_bp->alloced_u8s;
81+
if (sys_data_bp) {
82+
ram_used += sys_data_bp->used_u8s;
83+
ram_total += sys_data_bp->alloced_u8s;
84+
}
85+
StrPrint(buf, "%dMiB / %dMiB", ram_used / (1024 * 1024), ram_total / (1024 * 1024));
86+
return buf;
87+
}
88+
89+
U8* DetectPalette() {
90+
// FIXME: Actually detect - but how?
91+
// See comment in DetectFont
92+
return "PalUbuntu.HC";
93+
}
94+
95+
U8* DetectShell() {
96+
if (FindFunction("Lsh"))
97+
return "Lsh";
98+
else if (FindFunction("TempleShell"))
99+
return "TempleShell";
100+
else if (FindFunction("UserCmdLine"))
101+
return "UserCmdLine";
102+
else
103+
return "unknown";
104+
}
105+
106+
U8* DetectUptime() {
107+
F64 uptime = tS;
108+
I64 uptime_min = ToI64(uptime) / 60;
109+
I64 uptime_sec = ToI64(uptime) % 60;
110+
StrPrint(buf, "%dm %ds", uptime_min, uptime_sec);
111+
return buf;
112+
}
113+
114+
U0 Screenfetch() {
115+
Line();
116+
117+
U8* logo_path = MStrPrint("%s/Logo128x152.bmp", screenfetch_dir);
118+
DocBMP(DocPut, logo_path);
119+
Free(logo_path);
120+
121+
Line();
122+
Line();
123+
StrPrint(buf, "singleuser@%s", DirCur);
124+
Line(buf, "");
125+
Line();
126+
Line();
127+
Line("OS", OS_NAME);
128+
Line("Kernel", "TempleOS");
129+
Line("Uptime", DetectUptime());
130+
Line("Packages", DetectNumPackages());
131+
Line("Shell", DetectShell());
132+
Line("Resolution", "640x480");
133+
Line("DE", "Not Present");
134+
Line("WM", "Default");
135+
Line("Palette", DetectPalette());
136+
Line("Font", DetectFont());
137+
Line("CPU", DetectCPU());
138+
Line("RAM", DetectRAM());
139+
Line();
140+
Line();
141+
Line();
142+
}

build-package.script

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# vim: set ft=bash:
2+
3+
# Screenfetch
4+
command DirMk("/Tmp/Screenfetch");
5+
put /Tmp/Screenfetch/Logo128x152.bmp Logo128x152.bmp
6+
put /Tmp/Screenfetch/Screenfetch.HC.Z Screenfetch.HC
7+
put /Tmp/Screenfetch.MF manifest
8+
command PkgMakeFromDir("/Tmp/Screenfetch.MF", "/Tmp/Screenfetch");
9+
list /Tmp/Screenfetch.ISO.C Screenfetch.ISO.C
10+
list /Tmp/Screenfetch.MF Screenfetch.MF
11+
command DelTree("/Tmp/Screenfetch");

manifest

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
website https://github.com/minexew/TempleOS-Screenfetch
2+
pkgmin 10
3+
iso.c ::/Tmp/Screenfetch.ISO.C
4+
osmin 503
5+
version 1.0
6+
release 1
7+
installdir ::/Apps/Screenfetch

0 commit comments

Comments
 (0)