Added the ability to assign shortcuts to all bar modules. (#278)

This commit is contained in:
Jas Singh
2024-09-21 16:47:59 -07:00
committed by GitHub
parent 6be9030ac5
commit b47864d8e1
28 changed files with 497 additions and 94 deletions

View File

@@ -3,15 +3,14 @@ import options from 'options';
// Module initializer
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';
// Utility Methods
import { inputHandler } from 'customModules/utils';
import { computeCPU } from './computeCPU';
import { pollVariable } from 'customModules/PollVar';
import { Module } from 'lib/types/bar';
import { BarBoxChild } from 'lib/types/bar';
import { Attribute, Child } from 'lib/types/widget';
// All the user configurable options for the cpu module that are needed
const { label, round, leftClick, rightClick, middleClick, scrollUp, scrollDown, pollingInterval } =
@@ -30,7 +29,7 @@ pollVariable(
computeCPU,
);
export const Cpu = (): Module => {
export const Cpu = (): BarBoxChild => {
const renderLabel = (cpuUsg: number, rnd: boolean): string => {
return rnd ? `${Math.round(cpuUsg)}%` : `${cpuUsg.toFixed(2)}%`;
};
@@ -44,7 +43,7 @@ export const Cpu = (): Module => {
boxClass: 'cpu',
showLabelBinding: label.bind('value'),
props: {
setup: (self: Button<Gtk.Widget, Gtk.Widget>) => {
setup: (self: Button<Child, Attribute>) => {
inputHandler(self, {
onPrimaryClick: {
cmd: leftClick,