From 93be64eeaf79eca0e1e63e786a8d871d726a0650 Mon Sep 17 00:00:00 2001 From: Pascal Date: Wed, 25 Mar 2026 23:49:59 +0100 Subject: [PATCH] Added battey state widget --- package-lock.json | 18 +++++++++++++++++- style.scss | 2 +- widget/Bar.tsx | 3 ++- widget/System.tsx | 20 ++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c950048..805990a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,8 @@ "": { "dependencies": { "ags": "*", - "gnim": "*" + "gnim": "*", + "prettier": "^3.8.1" }, "devDependencies": { "@eslint/js": "^10.0.1", @@ -1121,6 +1122,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.8.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz", + "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/style.scss b/style.scss index e133afb..eab85db 100644 --- a/style.scss +++ b/style.scss @@ -72,7 +72,7 @@ window.Bar { margin: 2px; .tray-item { - padding: 2px 4px; // Reduced vertical padding + //padding: 2px 4px; // Reduced vertical padding margin: 0; background: transparent; border: none; diff --git a/widget/Bar.tsx b/widget/Bar.tsx index a44fda1..e6b495a 100644 --- a/widget/Bar.tsx +++ b/widget/Bar.tsx @@ -1,7 +1,7 @@ import app from "ags/gtk4/app" import { Astal, Gtk, Gdk } from "ags/gtk4" import Workspaces from "./Workspaces" -import { Clock, SysTray } from "./System" +import { Clock, SysTray, Battery } from "./System" import Media from "./Media" import Controls from "./Controls" import ThemeSwitcher from "./ThemeSwitcher" @@ -38,6 +38,7 @@ function Right({ gdkmonitor }: { gdkmonitor: Gdk.Monitor }) { > + ) diff --git a/widget/System.tsx b/widget/System.tsx index 27c2f82..9ddae64 100644 --- a/widget/System.tsx +++ b/widget/System.tsx @@ -1,6 +1,7 @@ import { Gtk } from "ags/gtk4" import { createPoll } from "ags/time" import AstalTray from "gi://AstalTray?version=0.1" +import AstalBattery from "gi://AstalBattery?version=0.1" import { createBinding, For } from "ags" export function Clock() { @@ -55,3 +56,22 @@ export function SysTray() { ) } + +export function Battery() { + const bat = AstalBattery.get_default() + return ( + + + + ) +}