From ad22dbdfebbb0def2ec2d8e2c91469e9a9e4fdf7 Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Thu, 30 Jan 2025 21:31:19 +1100
Subject: sideleft: create popdown window
---
config.ts | 16 +++
scss/bar.scss | 9 --
scss/popdowns/index.scss | 1 +
scss/popdowns/sideleft.scss | 131 ++++++++++++++++++++++++
src/modules/bar.tsx | 32 +++---
src/modules/popdowns/index.tsx | 2 +
src/modules/popdowns/sideleft.tsx | 203 ++++++++++++++++++++++++++++++++++++++
src/services/cpu.ts | 45 +++++++++
src/services/gpu.ts | 55 +++++++++++
src/services/memory.ts | 60 +++++++++++
src/services/storage.ts | 61 ++++++++++++
tsconfig.json | 4 +-
12 files changed, 598 insertions(+), 21 deletions(-)
create mode 100644 scss/popdowns/sideleft.scss
create mode 100644 src/modules/popdowns/sideleft.tsx
create mode 100644 src/services/cpu.ts
create mode 100644 src/services/gpu.ts
create mode 100644 src/services/memory.ts
create mode 100644 src/services/storage.ts
diff --git a/config.ts b/config.ts
index 4bae082..667e786 100644
--- a/config.ts
+++ b/config.ts
@@ -84,3 +84,19 @@ export const weather = {
location: "", // Location as a string or empty to autodetect
imperial: false,
};
+
+export const cpu = {
+ interval: 2000,
+};
+
+export const gpu = {
+ interval: 2000,
+};
+
+export const memory = {
+ interval: 5000,
+};
+
+export const storage = {
+ interval: 5000,
+};
diff --git a/scss/bar.scss b/scss/bar.scss
index 0afd02a..ead4d9e 100644
--- a/scss/bar.scss
+++ b/scss/bar.scss
@@ -114,14 +114,5 @@
color: scheme.$red;
font-weight: bold;
font-size: lib.s(16);
-
- &:hover,
- &:focus {
- background-color: scheme.$surface1;
- }
-
- &:active {
- background-color: scheme.$surface2;
- }
}
}
diff --git a/scss/popdowns/index.scss b/scss/popdowns/index.scss
index cae1473..524505e 100644
--- a/scss/popdowns/index.scss
+++ b/scss/popdowns/index.scss
@@ -4,3 +4,4 @@
@forward "networks";
@forward "media";
@forward "sideright";
+@forward "sideleft";
diff --git a/scss/popdowns/sideleft.scss b/scss/popdowns/sideleft.scss
new file mode 100644
index 0000000..7b84ada
--- /dev/null
+++ b/scss/popdowns/sideleft.scss
@@ -0,0 +1,131 @@
+@use "sass:color";
+@use "../scheme";
+@use "../lib";
+@use "../font";
+
+$-accent: scheme.$yellow;
+
+.sideleft {
+ @include lib.rounded(8);
+ @include lib.border($-accent, 0.4, 2);
+ @include lib.shadow;
+ @include font.mono;
+
+ background-color: scheme.$crust;
+ color: $-accent;
+ padding: lib.s(12);
+ font-size: lib.s(14);
+
+ @include lib.spacing(10, true);
+
+ & > * {
+ @include lib.rounded(5);
+
+ background-color: scheme.$base;
+ padding: lib.s(16) lib.s(20);
+ }
+
+ .user {
+ @include lib.spacing(15);
+
+ .face {
+ @include lib.rounded(1000);
+
+ background-position: center;
+ background-repeat: no-repeat;
+ background-size: cover;
+ min-width: lib.s(48);
+ min-height: lib.s(48);
+ font-size: lib.s(24);
+ }
+
+ .details {
+ font-size: lib.s(14);
+
+ @include lib.spacing(3, true);
+
+ .name {
+ font-size: lib.s(18);
+ color: scheme.$text;
+ }
+ }
+
+ .power {
+ @include lib.element-decel;
+ @include font.icon;
+
+ font-size: lib.s(24);
+ color: scheme.$red;
+
+ &:hover,
+ &:focus {
+ color: color.mix(scheme.$red, scheme.$base, 80%);
+ }
+
+ &:active {
+ color: color.mix(scheme.$red, scheme.$base, 60%);
+ }
+ }
+ }
+
+ .locations {
+ @include lib.spacing(30);
+
+ & > * {
+ @include lib.spacing(8, true);
+ }
+
+ $-colours: scheme.$pink, scheme.$yellow, scheme.$maroon, scheme.$green, scheme.$mauve, scheme.$lavender;
+ @for $i from 1 through 6 {
+ .loc#{$i} {
+ @include lib.element-decel;
+
+ color: nth($-colours, $i);
+
+ &:hover,
+ &:focus {
+ color: color.mix(nth($-colours, $i), scheme.$base, 80%);
+ }
+
+ &:active {
+ color: color.mix(nth($-colours, $i), scheme.$base, 60%);
+ }
+ }
+ }
+ }
+
+ .hw-resources {
+ @include lib.spacing(10, true);
+
+ .resource {
+ font-size: lib.s(13);
+
+ .inner {
+ font-size: lib.s(16);
+
+ @include lib.spacing(20);
+ }
+
+ .slider {
+ @include lib.rounded(5);
+ @include lib.fluent-decel(1000ms);
+
+ min-height: lib.s(10);
+ background-color: scheme.$surface0;
+ color: scheme.$red;
+ }
+
+ $-names: gpu, cpu, memory, storage;
+ $-colours: scheme.$green, scheme.$maroon, scheme.$yellow, scheme.$pink;
+ @for $i from 1 through length($-names) {
+ &.#{nth($-names, $i)} {
+ color: nth($-colours, $i);
+
+ .slider {
+ color: nth($-colours, $i);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/modules/bar.tsx b/src/modules/bar.tsx
index eb42d0b..16c505a 100644
--- a/src/modules/bar.tsx
+++ b/src/modules/bar.tsx
@@ -1,21 +1,21 @@
+import type { Monitor } from "@/services/monitors";
+import Players from "@/services/players";
+import Updates from "@/services/updates";
+import { getAppCategoryIcon } from "@/utils/icons";
+import { ellipsize } from "@/utils/strings";
+import { bindCurrentTime, osIcon } from "@/utils/system";
+import { setupCustomTooltip } from "@/utils/widgets";
+import type PopupWindow from "@/widgets/popupwindow";
import { execAsync, register, Variable } from "astal";
import { bind, kebabify } from "astal/binding";
import { App, Astal, astalify, Gdk, Gtk, type ConstructProps } from "astal/gtk3";
+import { bar as config } from "config";
import AstalBluetooth from "gi://AstalBluetooth";
import AstalHyprland from "gi://AstalHyprland";
import AstalNetwork from "gi://AstalNetwork";
import AstalNotifd from "gi://AstalNotifd";
import AstalTray from "gi://AstalTray";
import AstalWp01 from "gi://AstalWp";
-import { bar as config } from "../../config";
-import type { Monitor } from "../services/monitors";
-import Players from "../services/players";
-import Updates from "../services/updates";
-import { getAppCategoryIcon } from "../utils/icons";
-import { ellipsize } from "../utils/strings";
-import { bindCurrentTime, osIcon } from "../utils/system";
-import { setupCustomTooltip } from "../utils/widgets";
-import type PopupWindow from "../widgets/popupwindow";
const hyprland = AstalHyprland.get_default();
@@ -44,7 +44,13 @@ const togglePopup = (self: JSX.Element, event: Astal.ClickEvent, name: string) =
}
};
-const OSIcon = () => ;
+const OSIcon = () => (
+