diff options
author | RaindropsSys <contact@minteck.org> | 2023-06-19 10:53:24 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-06-19 10:53:24 +0200 |
commit | d837341ee359afbe40ee0732584704e488de2900 (patch) | |
tree | f77c337beec9a5a6d7ff13e18b35cb780d99ba7c | |
parent | 4480e889a967e571e89eb312b7ead883b827ed28 (diff) | |
download | kirinos-d837341ee359afbe40ee0732584704e488de2900.tar.gz kirinos-d837341ee359afbe40ee0732584704e488de2900.tar.bz2 kirinos-d837341ee359afbe40ee0732584704e488de2900.zip |
Updated 7 files and added 4 files (automated)
-rw-r--r-- | core/login/index.html | 51 | ||||
-rw-r--r-- | core/startup/index.html | 49 | ||||
-rw-r--r-- | lib/libmangoaudio/index.js | 232 | ||||
-rw-r--r-- | lib/libmangoaudio/package.json | 11 | ||||
-rw-r--r-- | main.js | 2 | ||||
-rw-r--r-- | setup.sh | 45 | ||||
-rw-r--r-- | setup/moaudio.service | 11 | ||||
-rw-r--r-- | setup/xinitrc | 2 | ||||
-rw-r--r-- | startup.sh | 32 | ||||
-rw-r--r-- | wallpaper.jpg | bin | 0 -> 2761904 bytes | |||
-rw-r--r-- | x11.sh | 32 |
11 files changed, 393 insertions, 74 deletions
diff --git a/core/login/index.html b/core/login/index.html index 3d647d1..912464a 100644 --- a/core/login/index.html +++ b/core/login/index.html @@ -12,11 +12,21 @@ } html, body { - background-color: cornflowerblue; + background-color: #ed9464; color: black; margin: 0; } + #bg { + position: fixed; + inset: 0; + z-index: -1; + background-color: #ed9464; + background-image: url("../../wallpaper.jpg"); + background-size: cover; + background-position: center; + } + ::-webkit-scrollbar { width: 7px; } @@ -105,11 +115,29 @@ border-radius: 999px; background: rgba(0, 0, 0, .025); } + + #login-card-password.shake { + animation-name: shake; + animation-iteration-count: 6; + animation-timing-function: linear; + animation-duration: .1s; + animation-fill-mode: both; + } + + @keyframes shake { + 33% { + margin-left: -10px; + } + 66% { + margin-right: -10px; + } + } </style> </head> -<body style="opacity: 0; pointer-events: none;"> - <div style="display: flex; align-items: center; justify-content: center; position: fixed; inset: 0;"> - <div style="background: rgba(255, 255, 255, .75); backdrop-filter: blur(10px); padding: 50px; width: 512px; height: 256px; border-radius: 10px;"> +<body> + <div id="bg"></div> + <div id="content" style="display: flex; align-items: center; justify-content: center; position: fixed; inset: 0;"> + <div style="background: rgba(255, 255, 255, .75); backdrop-filter: blur(20px); padding: 50px; width: 512px; height: 256px; border-radius: 10px;"> <div style="background: rgba(0, 0, 0, .1); margin: -50px -50px 0; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom: 1px solid rgba(0, 0, 0, .1); height: 80px;"> <div style="display: inline-flex; align-items: center;margin: 0 10px; height: 100%; width: max-content;"> <img src="../../logo.svg" style="width: 64px;"> @@ -119,6 +147,13 @@ hour: 'numeric', minute: '2-digit' })).format(new Date()); + + setInterval(() => { + document.getElementById("clock").innerText = (new Intl.DateTimeFormat('en-IE', { + hour: 'numeric', + minute: '2-digit' + })).format(new Date()); + }, 1000); </script> </div> <div style="float: right; display: flex; align-items: center; height: 100%; margin: 0 25px;" id="power-actions"> @@ -184,8 +219,8 @@ } window.onload = () => { - document.body.style.opacity = ""; - document.body.style.pointerEvents = ""; + document.getElementById("content").style.opacity = ""; + document.getElementById("content").style.pointerEvents = ""; } window.currentUser = null; @@ -209,6 +244,7 @@ } function confirmLogin() { + document.getElementById("login-card-password").classList.remove("shake"); document.getElementById("login-back").style.opacity = "0"; document.getElementById("login-back").style.pointerEvents = "none"; document.getElementById("login-card-password").style.display = "none"; @@ -246,12 +282,15 @@ document.getElementById("power-actions").style.opacity = "1"; document.getElementById("power-actions").style.pointerEvents = ""; document.getElementById("login-card-password").focus(); + document.getElementById("login-card-password").classList.add("shake"); + document.body.style.cursor = ""; } }) } function cancelLogin() { window.currentUser = null; + document.getElementById("login-card-password").classList.remove("shake"); document.getElementById("users").style.display = ""; document.getElementById("login").style.display = "none"; } diff --git a/core/startup/index.html b/core/startup/index.html index 50f65ac..eb5a346 100644 --- a/core/startup/index.html +++ b/core/startup/index.html @@ -13,16 +13,26 @@ outline: none; } + #bg { + position: fixed; + inset: 0; + z-index: -1; + background-color: #ed9464; + background-size: cover; + background-position: center; + } + html, body { - background-color: cornflowerblue; + background-color: #ed9464; color: black; margin: 0; } </style> </head> <body> + <div id="bg"></div> <div style="display: flex; align-items: center; justify-content: center; position: fixed; inset: 0;"> - <div style="background: rgba(255, 255, 255, .75); backdrop-filter: blur(10px); padding: 50px; width: 512px; height: 256px; border-radius: 10px;"> + <div style="background: rgba(255, 255, 255, .75); backdrop-filter: blur(20px); padding: 50px; width: 512px; height: 256px; border-radius: 10px;"> <div style="height: calc(100% - 48px + 50px); display: flex; align-items: center; justify-content: center;"> <div> <img src="../../logo.svg" style="width: 96px; display: block; margin-left: auto; margin-right: auto;"> @@ -85,6 +95,10 @@ command: "systemctl start polkit.service" }, { + title: "Starting audio subsystem...", + command: "systemctl start moaudio.service" + }, + { title: "Configuring encryption...", command: "modprobe ecryptfs && /mango/core/startup/encryption.sh" } @@ -112,23 +126,28 @@ }); } - setTimeout(async () => { - for (let step of steps) { - document.getElementById("loading-message").innerText = step.title; - await sleep(100); + setTimeout(() => { + document.getElementById("loading-message").innerText = "Setting wallpaper..."; + document.getElementById("bg").style.backgroundImage = 'url("../../wallpaper.jpg")'; - try { - await exec(step.command); + setTimeout(async () => { + for (let step of steps) { + document.getElementById("loading-message").innerText = step.title; await sleep(100); - } catch (e) { - console.error(e); + + try { + await exec(step.command); + await sleep(100); + } catch (e) { + console.error(e); + } } - } - document.getElementById("loading-message").innerText = "Initialising login screen..."; - document.body.style.opacity = "0"; - document.body.style.pointerEvents = "none"; - location.href = "../login/index.html"; + document.getElementById("loading-message").innerText = "Initialising login screen..."; + document.body.style.opacity = "0"; + document.body.style.pointerEvents = "none"; + location.href = "../login/index.html"; + }, 1000) }, 3000); </script> </body> diff --git a/lib/libmangoaudio/index.js b/lib/libmangoaudio/index.js new file mode 100644 index 0000000..9ec4f68 --- /dev/null +++ b/lib/libmangoaudio/index.js @@ -0,0 +1,232 @@ +const child_process = require("child_process"); + +class LibmangoaudioError extends Error { + constructor(message, options) { + super(message); + + for (let key of Object.keys(options)) { + this[key] = options[key]; + } + } +} + +function cmd(name, args) { + return new Promise((res, rej) => { + let output = ""; + let proc = child_process.execFile(name, args, { stdio: "pipe" }); + + proc.stdout.on('data', (data) => { + output += data.toString(); + }); + + proc.stderr.on('data', (data) => { + output += data.toString(); + }); + + proc.on('close', (code, signal) => { + if (!code || code === 0) { + res({ + code, + signal, + output + }); + } else { + rej(new LibmangoaudioError(name + " command failed", { + code, + signal, + output + })); + } + }) + }); +} + +function pacmd(...args) { + return cmd("pacmd", args); +} + +function pactl(...args) { + return cmd("pactl", args); +} + +function amixer(...args) { + return cmd("amixer", args); +} + +function parseFormat(format) { + try { + return { + depth: parseInt(format[0].replace(/s(\d+)(.*)/gm, "$1")), + endianness: format[0].replace(/s\d+(.*)/gm, "$1").trim() === "le" ? "LITTLE" : (format[0].replace(/s\d+(.*)/gm, "$1").trim() === "be" ? "BIG" : ""), + channels: parseInt(format[1].split("ch")[0]), + rate: parseInt(format[2].split("Hz")[0]) + } + } catch (e) { + return format; + } +} + +async function parseListing(listing, showMonitors) { + let raw = (await pacmd("list-" + listing)).output; + let sinks = {}; + let currentSink = null; + let last = null; + + for (let line of raw.trim().split("\n")) { + if (line.includes("index: ")) { + last = null; + currentSink = line.split("index: ")[1].trim(); + sinks[currentSink] = { + default: line.includes(" * "), + monitor: false, + name: { + card: null, + internal: null, + driver: null, + display: null + }, + volume: { + level: null, + muted: null, + balance: null + }, + channels: { + map: null, + name: null + } + }; + } else if (line.match(/^\t[a-z-_ .]*: (.*)$/gm)) { + let parts = line.replace(/^\t([a-z- .]*): (.*)$/gm, "$1||$2").split("||"); + + if (parts[0].startsWith("\tmonitor_of: ")) { + sinks[currentSink]["monitor"] = true; + continue; + } + + switch (parts[0]) { + case "name": + sinks[currentSink]["name"]["internal"] = parts[1].replace(/<(.*)>/gm, "$1"); + break; + + case "driver": + sinks[currentSink]["name"]["driver"] = parts[1].replace(/<(.*)>/gm, "$1"); + break; + + case "flags": + sinks[currentSink]["flags"] = parts[1].trim().split(" "); + break; + + case "priority": + sinks[currentSink]["priority"] = parseInt(parts[1]); + break; + + case "state": + sinks[currentSink]["state"] = parts[1].trim(); + break; + + case "channel map": + sinks[currentSink]["channels"]["map"] = parts[1].split(","); + break; + + case "muted": + sinks[currentSink]["volume"]["muted"] = parts[1].trim() === "yes"; + break; + + case "fixed latency": + if (parts[1].endsWith(" ms")) { + sinks[currentSink]["latency"] = parseFloat(parts[1].split(" ")[0]); + } + break; + + case "volume": + let channels = parts[1].split(",").map(i => parseFloat(i.trim().split(":")[1].trim().split("/")[1].trim().split("%")[0])); + let average = channels.reduce((a, b) => a + b) / channels.length; + + sinks[currentSink]["volume"]["level"] = average; + + break; + + case "sample spec": + sinks[currentSink]["format"] = parseFormat(parts[1].trim().split(" ")); + break; + } + + last = parts[0]; + } else if (currentSink && last === "volume" && line.startsWith("\t balance ")) { + sinks[currentSink]["volume"]["balance"] = parseFloat(line.split(" balance ")[1].trim()); + } else if (currentSink && last === "channel map" && line.startsWith("\t ")) { + sinks[currentSink]["channels"]["name"] = line.trim(); + } else if (currentSink && line.startsWith("\t\t")) { + let parts = line.replace(/^\t\t([a-z_\-.]*) = "(.*)"$/gm, "$1||$2").split("||").map(i => i.trim().split("\n")[0]); + + switch (parts[0]) { + case "device.description": + sinks[currentSink]["name"]["display"] = parts[1]; + break; + + case "alsa.card_name": + sinks[currentSink]["name"]["card"] = parts[1]; + break; + } + } + } + + if (!showMonitors) { + for (let id of Object.keys(sinks)) { + if (sinks[id]["monitor"]) { + delete sinks[id]; + } + } + } + + return sinks; +} + +const self = { + getOutputs: async (showMonitors) => { + return await parseListing("sinks", showMonitors ?? false); + }, + getInputs: async (showMonitors) => { + return await parseListing("sources", showMonitors ?? false); + }, + getDefaultOutput: async () => { + let list = await parseListing("sinks", false); + return Object.values(list)[0]; + }, + getDefaultInput: async () => { + let list = await parseListing("sources", false); + return Object.values(list)[0]; + }, + setInputVolume: async (volume, input) => { + if (typeof volume !== "number") return false; + if (input && typeof input !== "number") return false; + if (volume < 0 || volume > 100) return false; + + await pactl("set-source-volume", input ? input.toString() : "@DEFAULT_SOURCE@", volume + "%"); + return true; + }, + setOutputVolume: async (volume, input) => { + if (typeof volume !== "number") return false; + if (input && typeof input !== "number") return false; + if (volume < 0 || volume > 100) return false; + + await pactl("set-sink-volume", input ? input.toString() : "@DEFAULT_SINK@", volume + "%"); + return true; + }, + setInputMuted: async (mute, input) => { + if (typeof mute !== "boolean") return false; + if (input && typeof input !== "number") return false; + + await pactl("set-source-mute", input ? input.toString() : "@DEFAULT_SOURCE@", mute ? "1" : "0"); + return true; + }, + setOutputMuted: async (mute, input) => { + if (typeof mute !== "boolean") return false; + if (input && typeof input !== "number") return false; + + await pactl("set-sink-mute", input ? input.toString() : "@DEFAULT_SINK@", mute ? "1" : "0"); + return true; + } +} + +module.exports = self;
\ No newline at end of file diff --git a/lib/libmangoaudio/package.json b/lib/libmangoaudio/package.json new file mode 100644 index 0000000..dcc53a4 --- /dev/null +++ b/lib/libmangoaudio/package.json @@ -0,0 +1,11 @@ +{ + "name": "libmangoaudio", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "MIT" +} @@ -6,7 +6,7 @@ const path = require('path') const createWindow = () => { const mainWindow = new BrowserWindow({ - backgroundColor: "#6495ED", + backgroundColor: "#ed9464", x: 0, y: 0, frame: false, @@ -1,10 +1,11 @@ #!/bin/bash cd /mango -apt install -y network-manager xserver-xorg x11-xserver-utils xinit libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libgtk-3-0 libasound2 fonts-inter ecryptfs-utils nodejs xxd +apt install -y network-manager xserver-xorg x11-xserver-utils xinit libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libgtk-3-0 libasound2 fonts-inter ecryptfs-utils nodejs xxd pulseaudio alsa-utils apt autoremove -y chmod -R +x * cp ./setup/modm\@.service /etc/systemd/system/modm\@.service cp ./setup/mostartup.service /etc/systemd/system/mostartup.service +cp ./setup/moaudio.service /etc/systemd/system/moaudio.service cp ./setup/xinitrc /root/.xinitrc cp ./setup/xinitrc /.xinitrc systemctl daemon-reload @@ -23,22 +24,28 @@ systemctl disable networking.service systemctl disable NetworkManager.service systemctl disable wpa_supplicant.service systemctl disable polkit.service -mkdir -p /mango/users/0/crypt -mkdir -p /mango/users/0/lock -mkdir -p /mango/users/0/home -echo "Owner" > /mango/users/0/name -rm /root/.ecryptfs -rm /.ecryptfs -ln -s /mango/users/0/crypt /root/.ecryptfs -ln -s /mango/users/0/crypt /.ecryptfs -( stty -echo; printf "Passphrase: " 1>&2; PASSWORD="password"; stty echo; echo 1>&2; head -c 24 /dev/random | xxd -p; echo "$PASSWORD"; ) | ecryptfs-wrap-passphrase /mango/users/0/crypt/wrapped-passphrase -KEY=$(node setup/cryptsetup.js) -echo "/mango/users/0/lock /mango/users/0/home ecryptfs" > /mango/users/0/crypt/secret.conf -echo $KEY > /mango/users/0/key -echo $KEY > /mango/users/0/crypt/secret.sig -echo $KEY >> /mango/users/0/crypt/secret.sig -PASSPHRASE=$(node setup/unwraptest.js) -mount -t ecryptfs /mango/users/0/lock /mango/users/0/home -o verbosity=0,key=passphrase:passphrase_passwd=$PASSPHRASE,ecryptfs_sig=$KEY,ecryptfs_fnek_sig=$KEY,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs -mkdir -p /mango/users/0/home/data /mango/users/0/home/data/Music /mango/users/0/home/data/Downloads /mango/users/0/home/data/Documents /mango/users/0/home/data/Pictures -umount /mango/users/0/home + +if [ -d "/mango/users/0" ]; then + echo "Users already setup" +else + mkdir -p /mango/users/0/crypt + mkdir -p /mango/users/0/lock + mkdir -p /mango/users/0/home + echo "Owner" > /mango/users/0/name + rm /root/.ecryptfs + rm /.ecryptfs + ln -s /mango/users/0/crypt /root/.ecryptfs + ln -s /mango/users/0/crypt /.ecryptfs + ( stty -echo; printf "Passphrase: " 1>&2; PASSWORD="password"; stty echo; echo 1>&2; head -c 24 /dev/random | xxd -p; echo "$PASSWORD"; ) | ecryptfs-wrap-passphrase /mango/users/0/crypt/wrapped-passphrase + KEY=$(node setup/cryptsetup.js) + echo "/mango/users/0/lock /mango/users/0/home ecryptfs" > /mango/users/0/crypt/secret.conf + echo $KEY > /mango/users/0/key + echo $KEY > /mango/users/0/crypt/secret.sig + echo $KEY >> /mango/users/0/crypt/secret.sig + PASSPHRASE=$(node setup/unwraptest.js) + mount -t ecryptfs /mango/users/0/lock /mango/users/0/home -o verbosity=0,key=passphrase:passphrase_passwd=$PASSPHRASE,ecryptfs_sig=$KEY,ecryptfs_fnek_sig=$KEY,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs + mkdir -p /mango/users/0/home/data /mango/users/0/home/data/Music /mango/users/0/home/data/Downloads /mango/users/0/home/data/Documents /mango/users/0/home/data/Pictures + umount /mango/users/0/home +fi + mkdir /mango/session
\ No newline at end of file diff --git a/setup/moaudio.service b/setup/moaudio.service new file mode 100644 index 0000000..9afd229 --- /dev/null +++ b/setup/moaudio.service @@ -0,0 +1,11 @@ +[Unit] +Description=mangoOS Audio Subsystem +DefaultDependencies=no +Conflicts=rescue.service + +[Service] +ExecStart=pulseaudio +Restart=always + +[Install] +WantedBy=basic.target
\ No newline at end of file diff --git a/setup/xinitrc b/setup/xinitrc index c73bda4..f3c1b5e 100644 --- a/setup/xinitrc +++ b/setup/xinitrc @@ -1,4 +1,4 @@ #!/bin/bash cd /mango -xsetroot -solid "#6495ED" -bg "#6495ED" +xsetroot -solid "#ed9464" -bg "#ed9464" ./init.sh
\ No newline at end of file @@ -1,19 +1,19 @@ #!/bin/bash -echo -en "\e]P06495ED" # black -echo -en "\e]P86495ED" # darkgrey -echo -en "\e]P16495ED" # darkred -echo -en "\e]P96495ED" # red -echo -en "\e]P26495ED" # darkgreen -echo -en "\e]PA6495ED" # green -echo -en "\e]P36495ED" # brown -echo -en "\e]PB6495ED" # yellow -echo -en "\e]P46495ED" # darkblue -echo -en "\e]PC6495ED" # blue -echo -en "\e]P56495ED" # darkmagenta -echo -en "\e]PD6495ED" # magenta -echo -en "\e]P66495ED" # darkcyan -echo -en "\e]PE6495ED" # cyan -echo -en "\e]P76495ED" # lightgrey -echo -en "\e]PF6495ED" # white +echo -en "\e]P0ed9464" # black +echo -en "\e]P8ed9464" # darkgrey +echo -en "\e]P1ed9464" # darkred +echo -en "\e]P9ed9464" # red +echo -en "\e]P2ed9464" # darkgreen +echo -en "\e]PAed9464" # green +echo -en "\e]P3ed9464" # brown +echo -en "\e]PBed9464" # yellow +echo -en "\e]P4ed9464" # darkblue +echo -en "\e]PCed9464" # blue +echo -en "\e]P5ed9464" # darkmagenta +echo -en "\e]PDed9464" # magenta +echo -en "\e]P6ed9464" # darkcyan +echo -en "\e]PEed9464" # cyan +echo -en "\e]P7ed9464" # lightgrey +echo -en "\e]PFed9464" # white clear
\ No newline at end of file diff --git a/wallpaper.jpg b/wallpaper.jpg Binary files differnew file mode 100644 index 0000000..ad7c0d2 --- /dev/null +++ b/wallpaper.jpg @@ -1,21 +1,21 @@ #!/bin/bash -echo -en "\e]P06495ED" # black -echo -en "\e]P86495ED" # darkgrey -echo -en "\e]P16495ED" # darkred -echo -en "\e]P96495ED" # red -echo -en "\e]P26495ED" # darkgreen -echo -en "\e]PA6495ED" # green -echo -en "\e]P36495ED" # brown -echo -en "\e]PB6495ED" # yellow -echo -en "\e]P46495ED" # darkblue -echo -en "\e]PC6495ED" # blue -echo -en "\e]P56495ED" # darkmagenta -echo -en "\e]PD6495ED" # magenta -echo -en "\e]P66495ED" # darkcyan -echo -en "\e]PE6495ED" # cyan -echo -en "\e]P76495ED" # lightgrey -echo -en "\e]PF6495ED" # white +echo -en "\e]P0ed9464" # black +echo -en "\e]P8ed9464" # darkgrey +echo -en "\e]P1ed9464" # darkred +echo -en "\e]P9ed9464" # red +echo -en "\e]P2ed9464" # darkgreen +echo -en "\e]PAed9464" # green +echo -en "\e]P3ed9464" # brown +echo -en "\e]PBed9464" # yellow +echo -en "\e]P4ed9464" # darkblue +echo -en "\e]PCed9464" # blue +echo -en "\e]P5ed9464" # darkmagenta +echo -en "\e]PDed9464" # magenta +echo -en "\e]P6ed9464" # darkcyan +echo -en "\e]PEed9464" # cyan +echo -en "\e]P7ed9464" # lightgrey +echo -en "\e]PFed9464" # white clear startx >/dev/null 2>&1
\ No newline at end of file |