Skip to content

Commit

Permalink
os filters
Browse files Browse the repository at this point in the history
  • Loading branch information
NoobishSVK committed Feb 3, 2023
1 parent 6256cbe commit 93a284c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
39 changes: 25 additions & 14 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const os = require('os');
* @param appVersion Current version of the app
*/
const replaceValues = require('./values.js');
const appVersion = "1.1.4";
const appVersion = "1.2.0";


////////////////////////////////////////////////
Expand All @@ -38,11 +38,7 @@ const cpuPromise = new Promise((resolve, reject) => {
si.cpu(function(data) {
cpuModel = Object.entries(replaceValues)
.reduce((acc, [key, value]) => acc.replace(key, value), data.brand);

cpuFrequency = Object.entries(replaceValues)
.reduce((acc, [key, value]) => acc.replace(key, value), data.speedMax.toFixed(1));

resolve(data.manufacturer + " " +cpuModel + " @ " + cpuFrequency + " GHz");
resolve(data.manufacturer + " " +cpuModel + " @ " + data.speedMax.toFixed(1) + " GHz");
});
});

Expand All @@ -59,33 +55,48 @@ const ramPromise = new Promise((resolve, reject) => {

const osPromise = new Promise((resolve, reject) => {
si.osInfo(function(data) {
resolve(data.distro + data.arch
.replace('x86', '[32-bit]')
.replace('x64', ' [64-bit]')
.replace('arm64', ' [ARM 64-bit]'));
resolve(
data.distro.replace('Microsoft ', '') +
data.arch
.replace('x86', '[32-bit]')
.replace('x64', ' [64-bit]')
.replace('arm64', ' [ARM 64-bit]'));
});
});

/**
* Data handling - happens after all the data is gathered and ready to parse via @function Promise.all
* @param specCpu, @param specGpu, @param specRam, @param specOs parsed data values ready for display
* @param osLogo gathers the OS Logo and uses it as the small circle on the bottom right side
*/

Promise.all([cpuPromise, gpuPromise, ramPromise, osPromise])
.then(values => {
const [specCpu, specGpu, specRam, specOs] = values;

drawConsoleData(specCpu, specGpu, specRam, specOs);
let osLogo = 'checkmark';


if(specOs.includes("Windows")) {
osLogo = 'windows';
}
if(specOs.includes("Linux")) {
osLogo = 'linux';
}
if(specOs.includes("macOS")) {
osLogo = 'macos';
}

client.updatePresence({
state: specGpu + " • " + specRam + "GB RAM",
details: specCpu,
largeImageText: specOs,
smallImageText: "DiscordSpecsRP " + appVersion,
largeImageText: "DiscordSpecsRP " + appVersion,
smallImageText: specOs,
largeImageKey: 'logo',
smallImageKey: 'checkmark',
smallImageKey: osLogo,
instance: true,
buttons: [{label : 'Share your specs now!' , url: 'https://github.com/NoobishSVK/DiscordSpecsRP'}]
buttons: [{label: 'Share your specs now!' , url: 'https://github.com/NoobishSVK/DiscordSpecsRP'}]
});
})
.catch(error => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "RPC Specs allows everyone to see your PC specs dynamically in Discord Rich Presence!",
"main": "./main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"app": ".",
"build-pkg": "pkg --compress GZip ."
},
"pkg": {
Expand Down
2 changes: 1 addition & 1 deletion values.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const replaceValues = {
'Series': '',
'Graphics': '',
'& Display': '',
'AMD': '',
'AMD': ''
};

module.exports = replaceValues;

0 comments on commit 93a284c

Please sign in to comment.