summaryrefslogtreecommitdiff
path: root/Library/SystemSoftware.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-07-03 14:23:25 +0200
committerMinteck <contact@minteck.org>2022-07-03 14:23:25 +0200
commitd25bdc9f3f3f6547d6c023ed7e192fc5913e9bbc (patch)
treea8e538a8e32b66fece6a10c198fe700866d1e233 /Library/SystemSoftware.js
downloadstrawberry-os-d25bdc9f3f3f6547d6c023ed7e192fc5913e9bbc.tar.gz
strawberry-os-d25bdc9f3f3f6547d6c023ed7e192fc5913e9bbc.tar.bz2
strawberry-os-d25bdc9f3f3f6547d6c023ed7e192fc5913e9bbc.zip
Initial commit
Diffstat (limited to 'Library/SystemSoftware.js')
-rw-r--r--Library/SystemSoftware.js94
1 files changed, 94 insertions, 0 deletions
diff --git a/Library/SystemSoftware.js b/Library/SystemSoftware.js
new file mode 100644
index 0000000..6737410
--- /dev/null
+++ b/Library/SystemSoftware.js
@@ -0,0 +1,94 @@
+// noinspection JSUnresolvedVariable
+
+require('./SDK/Entrypoint'); // This part is supposed to be require-d by the system
+// ----------------------
+
+let initialized = false;
+
+global._STRAWBERRY_SYSTEMSOFTWARE_INIT = () => {
+ Strawberry.App = "System Software";
+ Strawberry.System = true;
+ Strawberry.Menus = [
+ "Power Off",
+ "Restart",
+ "System Info",
+ "Debugger"
+ ]
+
+ Strawberry.StartLoad(initialized);
+ Strawberry.WhenLoaded = () => {
+ load("Strawberry.Audio");
+ load("Strawberry.MenuBar");
+ load("Strawberry.DisplayRaw");
+ load("Strawberry.SystemInfo");
+ load("Strawberry.Dialog");
+ load("Strawberry.AppManager");
+
+ Strawberry.MenuAction[0] = () => {
+ Strawberry.Tick.Events = [];
+ Strawberry.ProcessKeyboard = false;
+
+ console.clear();
+ if (Strawberry.System) {
+ let horizontal = Math.round(process.stdout.columns / 2 - (1 + (Strawberry.App.length / 2)));
+ process.stdout.write(color.bgBlue.white(" ".repeat(horizontal + Strawberry.App.length) + " ".repeat(process.stdout.columns - horizontal - Strawberry.App.length)));
+ } else {
+ let horizontal = Math.round(process.stdout.columns / 2 - (1 + (Strawberry.App.length / 2)));
+ process.stdout.write(color.bgBlue.white(" ".repeat(horizontal) + Strawberry.App + " ".repeat(process.stdout.columns - horizontal - Strawberry.App.length)));
+ }
+
+ setTimeout(() => {
+ console.clear();
+ process.stdout.cursorTo(0, 0);
+
+ setTimeout(() => {
+ Strawberry.Dialog.Basic("It is now safe to turn off your computer.", "red");
+ }, 3000)
+ }, 1000)
+ }
+
+ Strawberry.MenuAction[1] = () => {
+ Strawberry.Tick.Events = [];
+ Strawberry.ProcessKeyboard = false;
+
+ console.clear();
+ if (Strawberry.System) {
+ let horizontal = Math.round(process.stdout.columns / 2 - (1 + (Strawberry.App.length / 2)));
+ process.stdout.write(color.bgBlue.white(" ".repeat(horizontal + Strawberry.App.length) + " ".repeat(process.stdout.columns - horizontal - Strawberry.App.length)));
+ } else {
+ let horizontal = Math.round(process.stdout.columns / 2 - (1 + (Strawberry.App.length / 2)));
+ process.stdout.write(color.bgBlue.white(" ".repeat(horizontal) + Strawberry.App + " ".repeat(process.stdout.columns - horizontal - Strawberry.App.length)));
+ }
+
+ setTimeout(() => {
+ console.clear();
+ process.stdout.cursorTo(0, 0);
+ setTimeout(() => {
+ require('child_process').spawnSync(process.argv[0], process.argv.filter((_, i) => { return i > 0 }), { stdio: "inherit" });
+ }, 3000)
+ }, 1000)
+ }
+
+ Strawberry.DisplayRaw.Write(color.bold.underline("Strawberry OS " + Strawberry.SystemInfo.Version()), 5, 3)
+ Strawberry.DisplayRaw.Write(Math.round(Strawberry.SystemInfo.GetHardwareMemory().Total / 1024) + "K memory", 5, 4)
+ Strawberry.DisplayRaw.Write(Strawberry.SystemInfo.GetProcessors().Count + " processors", 5, 5)
+
+ Strawberry.DisplayRaw.Write(color.bold.underline("Processes:"), 5, 7)
+ let proc = Strawberry.SystemInfo.Processes().filter((i) => {
+ return !i.includes("/node_modules/");
+ }).filter((_, i) => {
+ let line = 8 + i;
+ return line < process.stdout.rows - 2
+ });
+
+ let index = 0;
+ for (let p of proc) {
+ Strawberry.DisplayRaw.Write(p, 5, 8 + index);
+ index++;
+ }
+ }
+
+ initialized = true;
+}
+
+global._STRAWBERRY_SYSTEMSOFTWARE_INIT(); \ No newline at end of file