summaryrefslogtreecommitdiff
path: root/Library/Launcher.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/Launcher.js
downloadstrawberry-os-d25bdc9f3f3f6547d6c023ed7e192fc5913e9bbc.tar.gz
strawberry-os-d25bdc9f3f3f6547d6c023ed7e192fc5913e9bbc.tar.bz2
strawberry-os-d25bdc9f3f3f6547d6c023ed7e192fc5913e9bbc.zip
Initial commit
Diffstat (limited to 'Library/Launcher.js')
-rw-r--r--Library/Launcher.js119
1 files changed, 119 insertions, 0 deletions
diff --git a/Library/Launcher.js b/Library/Launcher.js
new file mode 100644
index 0000000..5040580
--- /dev/null
+++ b/Library/Launcher.js
@@ -0,0 +1,119 @@
+// noinspection JSUnresolvedVariable
+
+let Selected = 0;
+let Applications = [];
+
+let self = {
+ GetAppsList: () => {
+ let Applications1 = require('fs').readdirSync(global._STRAWBERRY_APPLICATIONS_ROOT).filter((i) => {
+ return i.endsWith(".app") && require('fs').lstatSync(global._STRAWBERRY_APPLICATIONS_ROOT + "/" + i).isDirectory();
+ });
+ let Applications2 = require('fs').readdirSync(global._STRAWBERRY_SYSTEMAPPS_ROOT).filter((i) => {
+ return i.endsWith(".app") && require('fs').lstatSync(global._STRAWBERRY_SYSTEMAPPS_ROOT + "/" + i).isDirectory();
+ });
+ Applications = [...Applications1, ...Applications2].sort((a, b) => a.localeCompare(b));
+ },
+
+ Init: () => {
+ Selected = 0;
+ self.GetAppsList();
+ },
+
+ Spawn: () => {
+ load("Strawberry.DisplayRaw");
+ Strawberry.DisplayRaw.Write(color.bgWhite.black("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"), 1, 1)
+
+ let line = 1;
+ let appIndex = 0;
+
+ for (let application of Applications) {
+ line++;
+ let appName = application.substring(0, 48);
+ appName = appName.substring(0, appName.length - 4);
+
+ if (appIndex === Selected) {
+ Strawberry.DisplayRaw.Write(color.bgWhite.black("┃ " + color.bgBlue.white(" " + appName + " ".repeat(48 - appName.length) + " ") + " ┃"), 1, line);
+ } else {
+ Strawberry.DisplayRaw.Write(color.bgWhite.black("┃ " + appName + " ".repeat(48 - appName.length) + " ┃"), 1, line);
+ }
+
+ appIndex++;
+ }
+
+ Strawberry.DisplayRaw.Write(color.bgWhite.black("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫"), 1, line + 1)
+ Strawberry.DisplayRaw.Write(color.bgWhite.black("┃ Strawberry OS " + Strawberry.SystemInfo.Version() + " ".repeat(34 - Strawberry.SystemInfo.Version().length) + " ┃"), 1, line + 2)
+ Strawberry.DisplayRaw.Write(color.bgWhite.black("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"), 1, line + 3)
+ },
+
+ GoUp: () => {
+ Strawberry.Audio.SystemSound("Strawberry.Menu.Select")
+
+ if (Selected > 0) {
+ Selected--;
+ } else {
+ Selected = Applications.length - 1;
+ }
+
+ self.Spawn();
+ },
+
+ GoDown: () => {
+ Strawberry.Audio.SystemSound("Strawberry.Menu.Select")
+
+ if (Selected < Applications.length - 1) {
+ Selected++;
+ } else {
+ Selected = 0;
+ }
+
+ self.Spawn();
+ },
+
+ Open: () => {
+ Strawberry.Audio.SystemSound("Strawberry.Menu.Click")
+
+ let line = 2 + Selected;
+ let appName = Applications[Selected].substring(0, 48);
+ appName = appName.substring(0, appName.length - 4);
+
+ setTimeout(() => {
+ self._OpenActive(appName, line);
+ setTimeout(() => {
+ self._OpenInactive(appName, line);
+ setTimeout(() => {
+ self._OpenActive(appName, line);
+ setTimeout(() => {
+ self._OpenInactive(appName, line);
+ setTimeout(() => {
+ self._OpenActive(appName, line);
+ setTimeout(() => {
+ self._OpenInactive(appName, line);
+ setTimeout(() => {
+ global._STRAWBERRY_APPMENU_OPEN = false;
+ console.clear();
+ Strawberry.WhenLoaded();
+ Strawberry.MenuBar.Reset();
+ if (fs.existsSync(global._STRAWBERRY_APPLICATIONS_ROOT + "/" + appName + ".app")) {
+ Strawberry.AppManager.Start(global._STRAWBERRY_APPLICATIONS_ROOT + "/" + appName + ".app");
+ } else {
+ Strawberry.AppManager.Start(global._STRAWBERRY_SYSTEMAPPS_ROOT + "/" + appName + ".app");
+ }
+ }, 30);
+ }, 30);
+ }, 30);
+ }, 30);
+ }, 30);
+ }, 30);
+ }, 30);
+ },
+
+ _OpenActive: (appName, line) => {
+ Strawberry.DisplayRaw.Write(color.bgWhite.black("┃ " + color.bgCyan.white(" " + appName + " ".repeat(48 - appName.length) + " ") + " ┃"), 1, line);
+ },
+
+ _OpenInactive: (appName, line) => {
+ Strawberry.DisplayRaw.Write(color.bgWhite.black("┃ " + appName + " ".repeat(48 - appName.length) + " ┃"), 1, line);
+ }
+}
+
+module.exports = self; \ No newline at end of file