Refractor of lb to lemonBar for easy reading

This commit is contained in:
snxraven 2021-09-24 10:55:09 -04:00
parent a22e0e468f
commit d50355ad77

23
main.js
View File

@ -1,5 +1,5 @@
// Required Modules
var lb = require("lemonbar");
var lemonBar = require("lemonbar");
var wifi = require('node-wifi');
const monitor = require('node-active-window');
var address = require('network-address')
@ -56,7 +56,7 @@ function formatBytes(bytes, decimals = 2) {
const file = '/home/raven/Documents/cache.json'
// Launching Main PID for LemonBar
lb.launch({
lemonBar.launch({
lemonbar: "/usr/bin/lemonbar", // Lemonbar binary
shell: "/bin/sh", // Shell to use for actions
shelloutput: true, // Print shell STDOUT
@ -72,7 +72,7 @@ lb.launch({
bottom: false, // Dock bar at bottom instead of top
forceDocking: false, // Force docking without asking the window manager
name: null, // Set the WM_NAME atom value for the bar
name: "Linux", // Set the WM_NAME atom value for the bar
areas: 10 // Number of clickable areas
})
@ -114,7 +114,7 @@ async function update() {
checkDiskSpace('/').then((diskSpace) => {
free.m(function (err, freeRamMB) {
cpuUsage(perc => lb.append(lb.left + require("os").userInfo().username.lbFg("#fff") + " | CPU: ".lbFg("#fff") + (Math.round(perc * 100) / 100).toFixed(2).lbFg("#fff") + " | Mem: ".lbFg("#fff") + freeRamMB[0].free.lbFg("#fff") + " MB".lbFg("#fff") + " | ".lbFg("#fff") + formatBytes(diskSpace.free).toString().lbFg("#fff")));
cpuUsage(perc => lemonBar.append(lemonBar.left + require("os").userInfo().username.lbFg("#fff") + " | CPU: ".lbFg("#fff") + (Math.round(perc * 100) / 100).toFixed(2).lbFg("#fff") + " | Mem: ".lbFg("#fff") + freeRamMB[0].free.lbFg("#fff") + " MB".lbFg("#fff") + " | ".lbFg("#fff") + formatBytes(diskSpace.free).toString().lbFg("#fff")));
});
})
@ -126,22 +126,29 @@ async function update() {
// If charging show its status, else, show nothing for charging
if (charging) {
lb.append(lb.right + (date.format(now, 'hh:mm:ss').toString.lbFg("#fff") + " | ".lbFg("#fff") + date.format(now, pattern).toString().lbFg("#fff") + " | BAT: ".lbFg("#fff") + level.toString().lbFg("#fff") + " (Charging)".lbFg("#fff") + " " + "| WIFI: ".lbFg("#fff") + wifiSSID.ssid.lbFg("#fff") + " | IP: ".lbFg("#fff") + address().lbFg("#fff")).lbSwap)
lemonBar.append(lemonBar.right +
(date.format(now, 'hh:mm:ss').toString.lbFg("#fff") +
" | ".lbFg("#fff") + date.format(now, pattern).toString().lbFg("#fff") +
" | BAT: ".lbFg("#fff") +
level.toString().lbFg("#fff") + " (Charging)".lbFg("#fff")
+ " " + "| WIFI: ".lbFg("#fff") + wifiSSID.ssid.lbFg("#fff")
+ " | IP: ".lbFg("#fff")
+ address().lbFg("#fff")).lbSwap)
} else {
lb.append(lb.right + (date.format(now, 'hh:mm:ss').toString().lbFont(font).lbFg("#fff") + " | ".lbFg("#fff") + date.format(now, pattern).toString().lbFg("#fff") + " | BAT: ".lbFg("#fff") + level.toString().lbFg("#fff") + " " + "| WIFI: ".lbFg("#fff") + wifiSSID.toString().lbFg("#fff") + " | IP: ".lbFg("#fff") + address().lbFg("#fff")).lbSwap)
lemonBar.append(lemonBar.right + (date.format(now, 'hh:mm:ss').toString().lbFont(font).lbFg("#fff") + " | ".lbFg("#fff") + date.format(now, pattern).toString().lbFg("#fff") + " | BAT: ".lbFg("#fff") + level.toString().lbFg("#fff") + " " + "| WIFI: ".lbFg("#fff") + wifiSSID.toString().lbFg("#fff") + " | IP: ".lbFg("#fff") + address().lbFg("#fff")).lbSwap)
}
monitor.getActiveWindow((err, window) => {
if (!err) {
lb.append((lb.center + window.app.lbFg("#fff")))
lemonBar.append((lemonBar.center + window.app.lbFg("#fff")))
} else
console.log(err)
}); // Grab the active window and and page name
// Write the data to lemonbar
lb.write()
lemonBar.write()
})
})