Implemented strict linting standards and prettier formatting config. (#248)
* Implemented strict linting standards and prettier formatting config. * More linter fixes and type updates. * More linter updates and type fixes * Remove noisy comments * Linter and type updates * Linter, formatting and type updates. * Linter updates * Type updates * Type updates * fixed all linter errors * Fixed all linting, formatting and type issues. * Resolve merge conflicts.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error: This import is a special directive that tells the compiler to use the GTop library
|
||||
import GTop from 'gi://GTop';
|
||||
|
||||
let previousCpuData = new GTop.glibtop_cpu();
|
||||
GTop.glibtop_get_cpu(previousCpuData);
|
||||
|
||||
export const computeCPU = () => {
|
||||
export const computeCPU = (): number => {
|
||||
const currentCpuData = new GTop.glibtop_cpu();
|
||||
GTop.glibtop_get_cpu(currentCpuData);
|
||||
|
||||
@@ -17,5 +17,4 @@ export const computeCPU = () => {
|
||||
previousCpuData = currentCpuData;
|
||||
|
||||
return cpuUsagePercentage;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -1,28 +1,21 @@
|
||||
import options from "options";
|
||||
import options from 'options';
|
||||
|
||||
// Module initializer
|
||||
import { module } from "../module"
|
||||
import { module } from '../module';
|
||||
|
||||
// import { CpuData } from "lib/types/customModules/cpu";
|
||||
import Button from "types/widgets/button";
|
||||
import Gtk from "types/@girs/gtk-3.0/gtk-3.0";
|
||||
import Button from 'types/widgets/button';
|
||||
import Gtk from 'types/@girs/gtk-3.0/gtk-3.0';
|
||||
|
||||
// Utility Methods
|
||||
import { inputHandler } from "customModules/utils";
|
||||
import { computeCPU } from "./computeCPU";
|
||||
import { pollVariable } from "customModules/PollVar";
|
||||
import { inputHandler } from 'customModules/utils';
|
||||
import { computeCPU } from './computeCPU';
|
||||
import { pollVariable } from 'customModules/PollVar';
|
||||
import { Module } from 'lib/types/bar';
|
||||
|
||||
// All the user configurable options for the cpu module that are needed
|
||||
const {
|
||||
label,
|
||||
round,
|
||||
leftClick,
|
||||
rightClick,
|
||||
middleClick,
|
||||
scrollUp,
|
||||
scrollDown,
|
||||
pollingInterval
|
||||
} = options.bar.customModules.cpu;
|
||||
const { label, round, leftClick, rightClick, middleClick, scrollUp, scrollDown, pollingInterval } =
|
||||
options.bar.customModules.cpu;
|
||||
|
||||
export const cpuUsage = Variable(0);
|
||||
|
||||
@@ -37,21 +30,19 @@ pollVariable(
|
||||
computeCPU,
|
||||
);
|
||||
|
||||
export const Cpu = () => {
|
||||
const renderLabel = (cpuUsg: number, rnd: boolean) => {
|
||||
export const Cpu = (): Module => {
|
||||
const renderLabel = (cpuUsg: number, rnd: boolean): string => {
|
||||
return rnd ? `${Math.round(cpuUsg)}%` : `${cpuUsg.toFixed(2)}%`;
|
||||
}
|
||||
};
|
||||
|
||||
const cpuModule = module({
|
||||
textIcon: "",
|
||||
label: Utils.merge(
|
||||
[cpuUsage.bind("value"), round.bind("value")],
|
||||
(cpuUsg, rnd) => {
|
||||
return renderLabel(cpuUsg, rnd);
|
||||
}),
|
||||
tooltipText: "CPU",
|
||||
boxClass: "cpu",
|
||||
showLabelBinding: label.bind("value"),
|
||||
textIcon: '',
|
||||
label: Utils.merge([cpuUsage.bind('value'), round.bind('value')], (cpuUsg, rnd) => {
|
||||
return renderLabel(cpuUsg, rnd);
|
||||
}),
|
||||
tooltipText: 'CPU',
|
||||
boxClass: 'cpu',
|
||||
showLabelBinding: label.bind('value'),
|
||||
props: {
|
||||
setup: (self: Button<Gtk.Widget, Gtk.Widget>) => {
|
||||
inputHandler(self, {
|
||||
@@ -72,9 +63,8 @@ export const Cpu = () => {
|
||||
},
|
||||
});
|
||||
},
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return cpuModule;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user