Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit 7bf040f

Browse files
committed
Themes \o/
1 parent 56faf4f commit 7bf040f

18 files changed

+157
-2168
lines changed

package-lock.json

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/_boot.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,48 @@ const Terminal = require("./classes/terminal.class.js").Terminal;
1515

1616
var win, tty;
1717
const settingsFile = path.join(electron.app.getPath("userData"), "settings.json");
18+
const themesDir = path.join(electron.app.getPath("userData"), "themes");
19+
const inner_themesDir = path.join(__dirname, "assets/themes");
20+
const kblayoutsDir = path.join(electron.app.getPath("userData"), "keyboards");
21+
const inner_kblayoutsDir = path.join(__dirname, "assets/kb_layouts");
1822

23+
// Create default settings file
1924
if (!fs.existsSync(settingsFile)) {
2025
fs.writeFileSync(settingsFile, JSON.stringify({
2126
shell: (process.platform === "win32") ? "powershell.exe" : "bash",
27+
cwd: electron.app.getPath("userData"),
2228
keyboard: "en-US",
23-
cwd: electron.app.getPath("userData")
29+
theme: "tron"
2430
}));
2531
}
2632

27-
app.on('ready', () => {
33+
// Copy default themes & keyboard layouts
34+
try {
35+
fs.mkdirSync(themesDir);
36+
} catch(e) {
37+
// Folder already exists
38+
}
39+
fs.readdirSync(inner_themesDir).forEach((e) => {
40+
fs.writeFileSync(path.join(themesDir, e), fs.readFileSync(path.join(inner_themesDir, e), {encoding:"utf-8"}))
41+
});
42+
try {
43+
fs.mkdirSync(kblayoutsDir);
44+
} catch(e) {
45+
// Folder already exists
46+
}
47+
fs.readdirSync(inner_kblayoutsDir).forEach((e) => {
48+
fs.writeFileSync(path.join(kblayoutsDir, e), fs.readFileSync(path.join(inner_kblayoutsDir, e), {encoding:"utf-8"}))
49+
});
2850

51+
app.on('ready', () => {
2952
let settings = require(settingsFile);
3053

54+
// Initialize terminal server
3155
tty = new Terminal({
3256
role: "server",
3357
shell: settings.shell,
34-
cwd: settings.cwd
58+
cwd: settings.cwd,
59+
port: settings.port || 3000
3560
});
3661
tty.onclosed = (code, signal) => {
3762
console.log("=> Terminal exited - "+code+", "+signal);
@@ -64,7 +89,7 @@ app.on('ready', () => {
6489
// focusable: false,
6590
// skipTaskbar: true,
6691
autoHideMenuBar: true,
67-
frame: true,
92+
frame: false,
6893
backgroundColor: '#000000'
6994
});
7095

src/_renderer.js

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,43 @@
1+
const path = require("path");
2+
const fs = require("fs");
3+
const electron = require("electron");
4+
5+
const themesDir = path.join(electron.remote.app.getPath("userData"), "themes");
6+
const keyboardsDir = path.join(electron.remote.app.getPath("userData"), "keyboards");
7+
const settingsFile = path.join(electron.remote.app.getPath("userData"), "settings.json");
8+
19
// Load config
2-
let settings = require(require('path').join(require('electron').remote.app.getPath("userData"), "settings.json"));
10+
const settings = require(settingsFile);
11+
12+
// Load theme
13+
let theme = require(path.join(themesDir, settings.theme+".json"));
14+
document.querySelector("head").innerHTML += `<style id="theme_${settings.theme}_cssvars">
15+
:root {
16+
--font_main: "${theme.cssvars.font_main}";
17+
--font_main_light: "${theme.cssvars.font_main_light}";
18+
--font_console: "${theme.cssvars.font_console}";
19+
--color_r: ${theme.colors.red};
20+
--color_g: ${theme.colors.green};
21+
--color_b: ${theme.colors.blue};
22+
--color_black: ${theme.colors.black};
23+
--color_light_black: ${theme.colors.light_black};
24+
--color_grey: ${theme.colors.grey};
25+
}
26+
</style>
27+
<style id="theme_${settings.theme}_xtermcss">
28+
${theme.xtermcss}
29+
</style>`;
30+
31+
window.theme = {
32+
r: theme.colors.red,
33+
g: theme.colors.green,
34+
b: theme.colors.blue
35+
};
336

37+
// Startup boot log
438
let resumeInit, initUI, initMods;
539
let bootScreen = document.getElementById("boot_screen");
6-
let log = require('fs').readFileSync(require('path').join(__dirname, 'assets/misc/boot_log.txt')).toString().split('\n');
40+
let log = fs.readFileSync(path.join(__dirname, 'assets/misc/boot_log.txt')).toString().split('\n');
741
let i = 0;
842

943
let displayLine = () => {
@@ -39,14 +73,15 @@ let displayLine = () => {
3973
};
4074
displayLine();
4175

76+
// Show "logo" and background grid
4277
resumeInit = () => {
4378
bootScreen.innerHTML = "";
4479
setTimeout(() => {
45-
document.body.setAttribute("style", "background: linear-gradient(90deg, #090B0A 20px, transparent 1%) center, linear-gradient(#090B0A 20px, transparent 1%) center, #262827;background-size: 22px 22px;");
80+
document.body.setAttribute("class", "");
4681
setTimeout(() => {
47-
document.body.setAttribute("style", "background: #090b0a;");
82+
document.body.setAttribute("class", "solidBackground");
4883
setTimeout(() => {
49-
document.body.setAttribute("style", "background: linear-gradient(90deg, #090B0A 20px, transparent 1%) center, linear-gradient(#090B0A 20px, transparent 1%) center, #262827;background-size: 22px 22px;");
84+
document.body.setAttribute("class", "");
5085
}, 400);
5186
}, 200);
5287

@@ -55,9 +90,9 @@ resumeInit = () => {
5590
let title = document.querySelector("section > h1");
5691

5792
setTimeout(() => {
58-
title.setAttribute("style", "background-color: rgba(190, 230, 193, 1);border-bottom: 5px solid rgba(190, 230, 193, 1);");
93+
title.setAttribute("style", `background-color: rgb(${window.theme.r}, ${window.theme.g}, ${window.theme.b});border-bottom: 5px solid rgb(${window.theme.r}, ${window.theme.g}, ${window.theme.b});`);
5994
setTimeout(() => {
60-
title.setAttribute("style", "border: 5px solid rgba(190, 230, 193, 1);");
95+
title.setAttribute("style", `border: 5px solid rgb(${window.theme.r}, ${window.theme.g}, ${window.theme.b});`);
6196
setTimeout(() => {
6297
document.getElementById("boot_screen").remove();
6398
initUI();
@@ -67,6 +102,7 @@ resumeInit = () => {
67102
}, 400);
68103
};
69104

105+
// Create the UI's html structure and initialize the terminal client and the keyboard
70106
initUI = () => {
71107
document.body.innerHTML += `<section class="mod_column" id="mod_column_left">
72108
<h3 class="title"><p>PANEL</p><p>SYSTEM</p></h3>
@@ -82,7 +118,7 @@ initUI = () => {
82118
</section>`;
83119

84120
window.keyboard = new Keyboard({
85-
layout: require("path").join(__dirname, "assets/kb_layouts/"+settings.keyboard+".json"),
121+
layout: path.join(keyboardsDir, settings.keyboard+".json"),
86122
container: "keyboard"
87123
});
88124
setTimeout(() => {
@@ -114,6 +150,7 @@ initUI = () => {
114150
}, 10);
115151
};
116152

153+
// Create the "mods" in each column
117154
initMods = () => {
118155
window.mods = {};
119156

src/assets/css/boot_screen.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ section#boot_screen h1 {
2525
font-family: var(--font_main);
2626
font-size: 10vh;
2727
text-align: center;
28-
border-bottom: 5px solid #bee6c1;
28+
border-bottom: 5px solid rgb(var(--color_r), var(--color_g), var(--color_b));
2929
padding-top: 2vh;
3030
padding-right: 2vh;
3131
padding-left: 1.5vh;

src/assets/css/fonts.css

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
/* Import Variables */
2-
@import url("variables.css");
3-
4-
/* Import Fonts */
5-
/* Fira Mono */
61
@font-face {
72
font-family: "Fira Mono";
83
src: url("../fonts/fira_mono.woff2") format("woff2");
94
}
10-
/* United Sans Medium */
5+
116
@font-face {
127
font-family: "United Sans Medium";
138
src: url("../fonts/united_sans.woff2") format("woff2");
149
}
15-
/* United Sans Light */
10+
1611
@font-face {
1712
font-family: "United Sans Light";
1813
src: url("../fonts/united_sans_light.woff2") format("woff2");
1914
}
2015

21-
/* Apply Fonts */
2216
body {
2317
font-family: var(--font_main), sans-serif;
2418
}

src/assets/css/keyboard.css

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ div.keyboard_key {
5555
min-width: 53px;
5656
overflow: hidden;
5757
border-radius: 5px;
58-
background-color: rgba(190, 230, 193, 0.0);
59-
border: 2px solid rgba(190, 230, 193, 0.0);
58+
background-color: rgba(var(--color_r), var(--color_g), var(--color_b), 0.0);
59+
border: 2px solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.0);
6060
margin: 0px 5px;
6161
display: flex;
6262
align-items: center;
@@ -65,8 +65,8 @@ div.keyboard_key {
6565
}
6666

6767
div.keyboard_key:active, div.keyboard_key.active {
68-
border: 2px solid rgba(190, 230, 193, 0.0);
69-
background-color: rgba(190, 230, 193, 1);
68+
border: 2px solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.0);
69+
background-color: rgba(var(--color_r), var(--color_g), var(--color_b), 1);
7070
}
7171

7272
div.keyboard_key.blink {
@@ -77,9 +77,9 @@ div.keyboard_key.blink {
7777
}
7878

7979
@keyframes blink {
80-
0% {background-color: rgba(190, 230, 193, 0.0);}
81-
50% {background-color: rgba(190, 230, 193, 1);}
82-
100% {background-color: rgba(190, 230, 193, 0.0);}
80+
0% {background-color: rgba(var(--color_r), var(--color_g), var(--color_b), 0.0);}
81+
50% {background-color: rgba(var(--color_r), var(--color_g), var(--color_b), 1);}
82+
100% {background-color: rgba(var(--color_r), var(--color_g), var(--color_b), 0.0);}
8383
}
8484

8585
div.keyboard_key > * {
@@ -130,7 +130,7 @@ div.keyboard_row:not(:nth-child(4)):not(:last-child) > .keyboard_key:last-child,
130130
}
131131

132132
div.keyboard_key#keyboard_spacebar, div.keyboard_enter {
133-
border: 2px solid rgba(190, 230, 193, 0.5);
133+
border: 2px solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.5);
134134
}
135135

136136
div.keyboard_row#row_1 > div.keyboard_enter {
@@ -147,7 +147,7 @@ div.keyboard_row#row_1 > div.keyboard_enter > h1 {
147147
div.keyboard_row#row_2 > div.keyboard_enter {
148148
border-top-right-radius: 0px;
149149
border-top-left-radius: 0px;
150-
border-top: 2px solid #090b0a;
150+
border-top: 2px solid var(--color_light_black);
151151
width: 84px;
152152
min-width: 84px;
153153
margin-top: 0px;
@@ -157,7 +157,7 @@ div.keyboard_row#row_2 > div.keyboard_enter {
157157
}
158158

159159
div.keyboard_row#row_2 > div.keyboard_enter:active, div.keyboard_row#row_2 > div.keyboard_enter.active {
160-
border-top: 2px solid rgb(190, 230, 193);
160+
border-top: 2px solid rgb(var(--color_r), var(--color_g), var(--color_b));
161161
}
162162

163163
div.keyboard_key#keyboard_spacebar {
@@ -178,8 +178,8 @@ div.keyboard_row:last-child > div.keyboard_key:nth-last-child(-n+3) {
178178
}
179179

180180
section#keyboard[data-is-caps-lck-on="true"] div.keyboard_key[data-cmd="ESCAPED|-- CAPSLCK: ON"] {
181-
background-color: rgb(190, 230, 193);
182-
color: black;
181+
background-color: rgb(var(--color_r), var(--color_g), var(--color_b));
182+
color: var(--color_black);
183183
}
184184

185185
section#keyboard[data-is-shift-on="true"] > div.keyboard_row > div.keyboard_key > h2:not(:empty), section#keyboard[data-is-caps-lck-on="true"] > div.keyboard_row > div.keyboard_key > h2:not(:empty) {
@@ -208,8 +208,8 @@ section#keyboard[data-is-shift-on="true"] > div.keyboard_row:first-child > div.k
208208

209209

210210
section#keyboard[data-is-fn-on="true"] div.keyboard_key[data-cmd="ESCAPED|-- FN: ON"] {
211-
background-color: rgb(190, 230, 193);
212-
color: black;
211+
background-color: rgb(var(--color_r), var(--color_g), var(--color_b));
212+
color: var(--color_black);
213213
}
214214

215215
section#keyboard[data-is-fn-on="true"] > div.keyboard_row > div.keyboard_key > h4:not(:empty) {

src/assets/css/main.css

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,25 @@ body {
99
/*cursor: none !important;*/
1010
user-select: none !important;
1111
padding-top: 20px;
12-
color: #bee6c1;
12+
color: rgb(var(--color_r), var(--color_g), var(--color_b));
1313
display: flex;
1414
flex-direction: row;
1515
align-items: center;
1616
justify-content: center;
1717
flex-wrap: wrap;
18-
background: linear-gradient(90deg, #090B0A 20px, transparent 1%) center, linear-gradient(#090B0A 20px, transparent 1%) center, #262827;
18+
background: linear-gradient(90deg, var(--color_light_black) 20px, transparent 1%) center, linear-gradient(var(--color_light_black) 20px, transparent 1%) center, var(--color_grey);
1919
background-size: 22px 22px;
2020
}
21+
body.solidBackground {
22+
background: var(--color_light_black);
23+
}
2124

2225
h3.title {
2326
position: fixed;
2427
margin: 0px;
2528
padding: 0px 10px;
2629
font-size: 11px;
27-
border-bottom: 1px solid rgba(190, 230, 193, 0.3);
30+
border-bottom: 1px solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.3);
2831
}
2932
h3.title > p {
3033
display: inline-block;
@@ -36,15 +39,15 @@ h3.title > p:last-child {
3639
}
3740
h3.title::before {
3841
content: "";
39-
border-left: 1px solid rgba(190, 230, 193, 0.3);
42+
border-left: 1px solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.3);
4043
position: relative;
4144
left: -10px;
4245
bottom: -6px;
4346
height: 5px;
4447
}
4548
h3.title::after {
4649
content: "";
47-
border-right: 1px solid rgba(190, 230, 193, 0.3);
50+
border-right: 1px solid rgba(var(--color_r), var(--color_g), var(--color_b), 0.3);
4851
position: relative;
4952
right: -10px;
5053
bottom: -6px;

0 commit comments

Comments
 (0)