Implement framework for custom modules and out of the box custom modules as well. (#213)

* Create declarative module scaffolding

* Added ram module (WIP)

* Updates to options, styling and more.

* Added function for styling custom modules.

* Added utility functions and cleaned up code

* Type and fn name updates.

* Update module utils to handle absent values.

* Added icon color in style2 that was missing.

* Linted utils.ts

* Add CPU module and update RAM module to use /proc/meminfo.

* Added disk storage module.

* Consolidate code

* Added netstat module and removed elements from systray default ignore list.

* Added keyboard layout module.

* Fix hook types and move module to customModules directory

* Added updates modules.

* Spacing updates

* Added weather module.

* Added power menu and power module in bar. Increased update default interval to 6 ours.

* Updated styling of bar buttons, made power menu label toggleable, etc.

* Consolidate code and add dynamic tooltips based on data being used.

* Make default custom mogules matugen compatible

* Update base theme

* Fix custom module background coloring

* Remove testing opacity.

* Update themes to account for new modules

* Update nix stuff for libgtop (Need someone to test this)

* Update nix

* Update fractions to multiplications

* Move styling in style directory

* Implement a polling framework for variables that can dynamically adjust polling intervals.

* Netstat module updates when interface name is changed.

* Readme update
This commit is contained in:
Jas Singh
2024-09-02 21:10:59 -07:00
committed by GitHub
parent 4f009b9978
commit 4cdda38604
107 changed files with 6444 additions and 1482 deletions

View File

@@ -1,6 +1,9 @@
import { opt, mkOptions } from "lib/option"
import { NetstatIcon, NetstatLabelType, PowerIcon, RateUnit, ResourceLabelType, StorageIcon, UpdatesIcon } from "lib/types/bar";
import { KbIcon, KbLabelType } from "lib/types/customModules/kbLayout";
import { BarButtonStyles, NotificationAnchor, OSDAnchor, OSDOrientation } from "lib/types/options";
import { MatugenScheme, MatugenTheme, MatugenVariation } from "lib/types/options";
import { UnitType } from "lib/types/weather";
// WARN: CHANGING THESE VALUES WILL PREVENT MATUGEN COLOR GENERATION FOR THE CHANGED VALUE
export const colors = {
@@ -38,6 +41,7 @@ const secondary_colors = {
text: "#cdd6f3",
pink: "#f5c2e6",
red: "#f38ba7",
peach: "#fab386",
mantle: "#181824",
surface1: "#454759",
surface0: "#313243",
@@ -238,6 +242,63 @@ const options = mkOptions(OPTIONS, {
total: opt(colors.lavender),
spacing: opt("0.5em"),
},
modules: {
ram: {
background: opt(colors.base2),
text: opt(colors.yellow),
icon: opt(colors.yellow),
icon_background: opt(colors.base2),
spacing: opt("0.45em"),
},
cpu: {
background: opt(colors.base2),
text: opt(colors.red),
icon: opt(colors.red),
icon_background: opt(colors.base2),
spacing: opt("0.5em"),
},
storage: {
background: opt(colors.base2),
text: opt(colors.pink),
icon: opt(colors.pink),
icon_background: opt(colors.base2),
spacing: opt("0.45em"),
},
netstat: {
background: opt(colors.base2),
text: opt(colors.green),
icon: opt(colors.green),
icon_background: opt(colors.base2),
spacing: opt("0.45em"),
},
kbLayout: {
background: opt(colors.base2),
text: opt(colors.sky),
icon: opt(colors.sky),
icon_background: opt(colors.base2),
spacing: opt("0.45em"),
},
updates: {
background: opt(colors.base2),
text: opt(colors.mauve),
icon: opt(colors.mauve),
icon_background: opt(colors.base2),
spacing: opt("0.45em"),
},
weather: {
background: opt(colors.base2),
text: opt(colors.lavender),
icon: opt(colors.lavender),
icon_background: opt(colors.base2),
spacing: opt("0.45em"),
},
power: {
background: opt(colors.base2),
icon: opt(colors.red),
icon_background: opt(colors.base2),
spacing: opt("0.45em"),
}
},
},
menus: {
monochrome: opt(false),
@@ -629,6 +690,42 @@ const options = mkOptions(OPTIONS, {
},
},
},
power: {
scaling: opt(90),
radius: opt("0.4em"),
background: {
color: opt(colors.crust),
},
border: {
color: opt(colors.surface0),
},
buttons: {
shutdown: {
background: opt(colors.base),
icon_background: opt(secondary_colors.red),
text: opt(colors.red),
icon: opt(secondary_colors.mantle),
},
restart: {
background: opt(colors.base),
icon_background: opt(secondary_colors.peach),
text: opt(colors.peach),
icon: opt(secondary_colors.mantle),
},
logout: {
background: opt(colors.base),
icon_background: opt(secondary_colors.green),
text: opt(colors.green),
icon: opt(secondary_colors.mantle),
},
sleep: {
background: opt(colors.base),
icon_background: opt(secondary_colors.sky),
text: opt(colors.sky),
icon: opt(secondary_colors.mantle),
},
}
},
notifications: {
scaling: opt(100),
height: opt("58em"),
@@ -655,7 +752,7 @@ const options = mkOptions(OPTIONS, {
width: opt("0.35em"),
radius: opt("0.2em")
}
},
}
}
}
}
@@ -752,10 +849,7 @@ const options = mkOptions(OPTIONS, {
label: opt(true),
},
systray: {
ignore: opt([
"KDE Connect Indicator",
"spotify-client",
]),
ignore: opt([]),
},
clock: {
icon: opt("󰸗"),
@@ -772,9 +866,101 @@ const options = mkOptions(OPTIONS, {
notifications: {
show_total: opt(false),
},
customModules: {
scrollSpeed: opt(5),
ram: {
label: opt(true),
labelType: opt<ResourceLabelType>("percentage"),
round: opt(true),
pollingInterval: opt(2000),
leftClick: opt(""),
rightClick: opt(""),
middleClick: opt(""),
},
cpu: {
label: opt(true),
round: opt(true),
pollingInterval: opt(2000),
leftClick: opt(""),
rightClick: opt(""),
middleClick: opt(""),
scrollUp: opt(""),
scrollDown: opt(""),
},
storage: {
label: opt(true),
icon: opt<StorageIcon>("󰋊"),
round: opt(false),
labelType: opt<ResourceLabelType>("percentage"),
pollingInterval: opt(2000),
leftClick: opt(""),
rightClick: opt(""),
middleClick: opt(""),
},
netstat: {
label: opt(true),
networkInterface: opt(""),
icon: opt<NetstatIcon>("󰖟"),
round: opt(true),
labelType: opt<NetstatLabelType>("full"),
rateUnit: opt<RateUnit>("auto"),
pollingInterval: opt(2000),
leftClick: opt(""),
rightClick: opt(""),
middleClick: opt(""),
},
kbLayout: {
label: opt(true),
labelType: opt<KbLabelType>("code"),
icon: opt<KbIcon>("󰌌"),
leftClick: opt(""),
rightClick: opt(""),
middleClick: opt(""),
scrollUp: opt(""),
scrollDown: opt(""),
},
updates: {
updateCommand: opt("$HOME/.config/ags/scripts/checkUpdates.sh -arch"),
label: opt(true),
padZero: opt(true),
icon: opt<UpdatesIcon>("󰏖"),
pollingInterval: opt(1000 * 60 * 60 * 6),
leftClick: opt(""),
rightClick: opt(""),
middleClick: opt(""),
scrollUp: opt(""),
scrollDown: opt(""),
},
weather: {
label: opt(true),
unit: opt<UnitType>("imperial"),
leftClick: opt(""),
rightClick: opt(""),
middleClick: opt(""),
scrollUp: opt(""),
scrollDown: opt(""),
},
power: {
icon: opt<PowerIcon>(""),
showLabel: opt(true),
leftClick: opt("menu:powerdropdown"),
rightClick: opt(""),
middleClick: opt(""),
scrollUp: opt(""),
scrollDown: opt(""),
},
}
},
menus: {
power: {
showLabel: opt(true),
confirmation: opt(true),
sleep: opt("systemctl suspend"),
reboot: opt("systemctl reboot"),
logout: opt("pkill Hyprland"),
shutdown: opt("shutdown now"),
},
dashboard: {
powermenu: {
confirmation: opt(true),
@@ -863,7 +1049,7 @@ const options = mkOptions(OPTIONS, {
},
weather: {
interval: opt(60000),
unit: opt<"metric" | "imperial">("imperial"),
unit: opt<UnitType>("imperial"),
location: opt("Los Angeles"),
key: opt<string>(
JSON.parse(Utils.readFile(`${App.configDir}/.weather.json`) || "{}")?.weather_api_key || "",