fix: use seperate repository for status-bar
This commit is contained in:
@@ -30,6 +30,8 @@ local function setup_luau()
|
|||||||
enabled = true,
|
enabled = true,
|
||||||
suggestServices = true,
|
suggestServices = true,
|
||||||
suggestRequires = true,
|
suggestRequires = true,
|
||||||
|
requireStyle = "alwaysAbsolute",
|
||||||
|
stringRequires = { enabled = true },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
2
astal/.gitignore
vendored
2
astal/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
node_modules/
|
|
||||||
@girs/
|
|
||||||
29
astal/app.ts
29
astal/app.ts
@@ -1,29 +0,0 @@
|
|||||||
import { App, Gdk } from "astal/gtk3";
|
|
||||||
import style from "./style.scss";
|
|
||||||
import Bar from "./widget/Bar";
|
|
||||||
import { GLib } from "astal";
|
|
||||||
|
|
||||||
App.start({
|
|
||||||
css: style,
|
|
||||||
icons: "icons",
|
|
||||||
main() {},
|
|
||||||
});
|
|
||||||
|
|
||||||
let knownMonitors = new Set();
|
|
||||||
|
|
||||||
function checkMonitors() {
|
|
||||||
const currentMonitors = App.get_monitors();
|
|
||||||
currentMonitors.forEach((monitor) => {
|
|
||||||
if (!knownMonitors.has(monitor.model)) {
|
|
||||||
knownMonitors.add(monitor.model);
|
|
||||||
Bar(monitor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
checkMonitors();
|
|
||||||
|
|
||||||
GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 10, () => {
|
|
||||||
checkMonitors();
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"lockfileVersion": 1,
|
|
||||||
"workspaces": {
|
|
||||||
"": {
|
|
||||||
"name": "astal-shell",
|
|
||||||
"dependencies": {
|
|
||||||
"astal": "/nix/store/pvb3x021mr6xknm91gqq76gy32n96vj0-astal-gjs/share/astal/gjs",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"packages": {
|
|
||||||
"astal": ["astal@file:../../../../nix/store/pvb3x021mr6xknm91gqq76gy32n96vj0-astal-gjs/share/astal/gjs", {}],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
21
astal/env.d.ts
vendored
21
astal/env.d.ts
vendored
@@ -1,21 +0,0 @@
|
|||||||
declare const SRC: string
|
|
||||||
|
|
||||||
declare module "inline:*" {
|
|
||||||
const content: string
|
|
||||||
export default content
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module "*.scss" {
|
|
||||||
const content: string
|
|
||||||
export default content
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module "*.blp" {
|
|
||||||
const content: string
|
|
||||||
export default content
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module "*.css" {
|
|
||||||
const content: string
|
|
||||||
export default content
|
|
||||||
}
|
|
||||||
70
astal/flake.lock
generated
70
astal/flake.lock
generated
@@ -1,70 +0,0 @@
|
|||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"ags": {
|
|
||||||
"inputs": {
|
|
||||||
"astal": "astal",
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1744557573,
|
|
||||||
"narHash": "sha256-XAyj0iDuI51BytJ1PwN53uLpzTDdznPDQFG4RwihlTQ=",
|
|
||||||
"owner": "aylur",
|
|
||||||
"repo": "ags",
|
|
||||||
"rev": "3ed9737bdbc8fc7a7c7ceef2165c9109f336bff6",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "aylur",
|
|
||||||
"repo": "ags",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"astal": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"ags",
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1742571008,
|
|
||||||
"narHash": "sha256-5WgfJAeBpxiKbTR/gJvxrGYfqQRge5aUDcGKmU1YZ1Q=",
|
|
||||||
"owner": "aylur",
|
|
||||||
"repo": "astal",
|
|
||||||
"rev": "dc0e5d37abe9424c53dcbd2506a4886ffee6296e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "aylur",
|
|
||||||
"repo": "astal",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1750365781,
|
|
||||||
"narHash": "sha256-XE/lFNhz5lsriMm/yjXkvSZz5DfvKJLUjsS6pP8EC50=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "08f22084e6085d19bcfb4be30d1ca76ecb96fe54",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"ags": "ags",
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
{
|
|
||||||
description = "Desktop widgets";
|
|
||||||
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
||||||
|
|
||||||
ags = {
|
|
||||||
url = "github:aylur/ags";
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs =
|
|
||||||
{
|
|
||||||
self,
|
|
||||||
nixpkgs,
|
|
||||||
ags,
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
system = "x86_64-linux";
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
|
|
||||||
extraPkgs = with ags.packages.${system}; [
|
|
||||||
hyprland
|
|
||||||
battery
|
|
||||||
wireplumber
|
|
||||||
network
|
|
||||||
];
|
|
||||||
in
|
|
||||||
{
|
|
||||||
packages.${system} = {
|
|
||||||
status-bar = ags.lib.bundle {
|
|
||||||
inherit pkgs;
|
|
||||||
src = ./.;
|
|
||||||
name = "status-bar";
|
|
||||||
entry = "app.ts";
|
|
||||||
|
|
||||||
extraPackages =
|
|
||||||
with pkgs;
|
|
||||||
extraPkgs
|
|
||||||
++ [
|
|
||||||
libgtop
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
devShells.${system} = {
|
|
||||||
default = pkgs.mkShell {
|
|
||||||
buildInputs = [
|
|
||||||
(ags.packages.${system}.default.override {
|
|
||||||
extraPackages =
|
|
||||||
with pkgs;
|
|
||||||
extraPkgs
|
|
||||||
++ [
|
|
||||||
libgtop
|
|
||||||
];
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>NixOS</title><path d="M7.352 1.592l-1.364.002L5.32 2.75l1.557 2.713-3.137-.008-1.32 2.34H14.11l-1.353-2.332-3.192-.006-2.214-3.865zm6.175 0l-2.687.025 5.846 10.127 1.341-2.34-1.59-2.765 2.24-3.85-.683-1.182h-1.336l-1.57 2.705-1.56-2.72zm6.887 4.195l-5.846 10.125 2.696-.008 1.601-2.76 4.453.016.682-1.183-.666-1.157-3.13-.008L21.778 8.1l-1.365-2.313zM9.432 8.086l-2.696.008-1.601 2.76-4.453-.016L0 12.02l.666 1.157 3.13.008-1.575 2.71 1.365 2.315L9.432 8.086zM7.33 12.25l-.006.01-.002-.004-1.342 2.34 1.59 2.765-2.24 3.85.684 1.182H7.35l.004-.006h.001l1.567-2.698 1.558 2.72 2.688-.026-.004-.006h.01L7.33 12.25zm2.55 3.93l1.354 2.332 3.192.006 2.215 3.865 1.363-.002.668-1.156-1.557-2.713 3.137.008 1.32-2.34H9.881Z"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 802 B |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill="#7EBAE4" d="M50.732 43.771L20.525 96.428l-7.052-12.033 8.14-14.103-16.167-.042L2 64.237l3.519-6.15 23.013.073 8.27-14.352 13.93-.037zm2.318 42.094l60.409.003-6.827 12.164-16.205-.045 8.047 14.115-3.45 6.01-7.05.008-11.445-20.097-16.483-.034-6.996-12.124zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148 8.12-14.072 6.897.002 3.532 6.143-11.57 20.024 8.213 14.386-6.933 12.16z" clip-rule="evenodd" fill-rule="evenodd"/><path fill="#5277C3" d="M39.831 65.463l30.202 52.66-13.88.131-8.063-14.148-8.12 14.072-6.897-.002-3.532-6.143 11.57-20.024-8.213-14.386 6.933-12.16zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045-8.047-14.115 3.45-6.01 7.051-.01 11.444 20.097 16.484.034 6.996 12.124zm2.357 42.216l30.207-52.658 7.052 12.034-8.141 14.102 16.168.043L126 64.006l-3.519 6.15-23.013-.073-8.27 14.352-13.93.037z" clip-rule="evenodd" fill-rule="evenodd"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 934 B |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"><path fill="#7EBAE4" d="M50.732 43.771L20.525 96.428l-7.052-12.033 8.14-14.103-16.167-.042L2 64.237l3.519-6.15 23.013.073 8.27-14.352 13.93-.037zm2.318 42.094l60.409.003-6.827 12.164-16.205-.045 8.047 14.115-3.45 6.01-7.05.008-11.445-20.097-16.483-.034-6.996-12.124zm35.16-23.074l-30.202-52.66L71.888 10l8.063 14.148 8.12-14.072 6.897.002 3.532 6.143-11.57 20.024 8.213 14.386-6.933 12.16z" clip-rule="evenodd" fill-rule="evenodd" style="--darkreader-inline-fill: var(--darkreader-background-7ebae4, #195178);" data-darkreader-inline-fill=""/><path fill="#5277C3" d="M39.831 65.463l30.202 52.66-13.88.131-8.063-14.148-8.12 14.072-6.897-.002-3.532-6.143 11.57-20.024-8.213-14.386 6.933-12.16zm35.08-23.207l-60.409-.003L21.33 30.09l16.204.045-8.047-14.115 3.45-6.01 7.051-.01 11.444 20.097 16.484.034 6.996 12.124zm2.357 42.216l30.207-52.658 7.052 12.034-8.141 14.102 16.168.043L126 64.006l-3.519 6.15-23.013-.073-8.27 14.352-13.93.037z" clip-rule="evenodd" fill-rule="evenodd" style="--darkreader-inline-fill: var(--darkreader-background-5277c3, #314f8e);" data-darkreader-inline-fill=""/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB |
21
astal/package-lock.json
generated
21
astal/package-lock.json
generated
@@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "astal-shell",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"name": "astal-shell",
|
|
||||||
"dependencies": {
|
|
||||||
"astal": "/nix/store/pvb3x021mr6xknm91gqq76gy32n96vj0-astal-gjs/share/astal/gjs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"../../../../nix/store/pvb3x021mr6xknm91gqq76gy32n96vj0-astal-gjs/share/astal/gjs": {
|
|
||||||
"name": "astal",
|
|
||||||
"license": "LGPL-2.1"
|
|
||||||
},
|
|
||||||
"node_modules/astal": {
|
|
||||||
"resolved": "../../../../nix/store/pvb3x021mr6xknm91gqq76gy32n96vj0-astal-gjs/share/astal/gjs",
|
|
||||||
"link": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "astal-shell",
|
|
||||||
"dependencies": {
|
|
||||||
"astal": "/nix/store/pvb3x021mr6xknm91gqq76gy32n96vj0-astal-gjs/share/astal/gjs"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
134
astal/style.scss
134
astal/style.scss
@@ -1,134 +0,0 @@
|
|||||||
@use "sass:color";
|
|
||||||
|
|
||||||
$bg: #212223;
|
|
||||||
$fg: #f1f1f1;
|
|
||||||
$accent: #378DF7;
|
|
||||||
$accent-white: #ffffff;
|
|
||||||
$radius: 7px;
|
|
||||||
$bg-color-6: rgb(40, 42, 54);
|
|
||||||
$inactive-bg-color: rgb(68, 71, 90);
|
|
||||||
|
|
||||||
window.Bar {
|
|
||||||
border: none;
|
|
||||||
box-shadow: none;
|
|
||||||
font-family: Dejavu Sans Mono;
|
|
||||||
background-color: color.adjust($bg, $alpha: -0.2);
|
|
||||||
color: $fg;
|
|
||||||
font-size: 1.1em;
|
|
||||||
|
|
||||||
label {
|
|
||||||
margin: 0 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-box {
|
|
||||||
background-color: $bg-color-6;
|
|
||||||
padding: 0 4px;
|
|
||||||
margin: 0 2px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inactive {
|
|
||||||
background-color: $inactive-bg-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
.client-title label {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nix-icon {
|
|
||||||
font-size: 24px;
|
|
||||||
padding: 0 2px;
|
|
||||||
background-color: #003366;
|
|
||||||
border-top-right-radius: 4px;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.workspaces {
|
|
||||||
font-weight: bold;
|
|
||||||
|
|
||||||
button {
|
|
||||||
all: unset;
|
|
||||||
background-color: transparent;
|
|
||||||
|
|
||||||
&:hover label {
|
|
||||||
background-color: color.adjust($fg, $alpha: -0.84);
|
|
||||||
border-color: color.adjust($accent, $alpha: -0.8);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active label {
|
|
||||||
background-color: color.adjust($fg, $alpha: -0.8)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
label {
|
|
||||||
transition: 200ms;
|
|
||||||
padding: 3px 8px;
|
|
||||||
margin: 0px;
|
|
||||||
border-radius: 0;
|
|
||||||
border: 3px solid transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.focused label {
|
|
||||||
background-color: color.adjust($accent-white, $alpha: -0.84);
|
|
||||||
border-bottom: 3px solid $accent-white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.SysTray {
|
|
||||||
margin-right: 8px;
|
|
||||||
|
|
||||||
button {
|
|
||||||
padding: 0 4px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.FocusedClient {
|
|
||||||
color: $accent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.Media .Cover {
|
|
||||||
min-height: 1.2em;
|
|
||||||
min-width: 1.2em;
|
|
||||||
border-radius: $radius;
|
|
||||||
background-position: center;
|
|
||||||
background-size: contain;
|
|
||||||
}
|
|
||||||
|
|
||||||
.Battery label {
|
|
||||||
padding-left: 0;
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.AudioSlider {
|
|
||||||
* {
|
|
||||||
all: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
icon {
|
|
||||||
margin-right: .6em;
|
|
||||||
}
|
|
||||||
|
|
||||||
& {
|
|
||||||
margin: 0 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
trough {
|
|
||||||
background-color: color.adjust($fg, $alpha: -0.8);
|
|
||||||
border-radius: $radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
highlight {
|
|
||||||
background-color: $accent;
|
|
||||||
min-height: .8em;
|
|
||||||
border-radius: $radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
slider {
|
|
||||||
background-color: $fg;
|
|
||||||
border-radius: $radius;
|
|
||||||
min-height: 1em;
|
|
||||||
min-width: 1em;
|
|
||||||
margin: -.2em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
|
||||||
"compilerOptions": {
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"strict": false,
|
|
||||||
"target": "ES2022",
|
|
||||||
"module": "ES2022",
|
|
||||||
"moduleResolution": "Bundler",
|
|
||||||
// "checkJs": true,
|
|
||||||
// "allowJs": true,
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"jsxImportSource": "astal/gtk3",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import { App, Astal, Gtk, Gdk } from "astal/gtk3";
|
|
||||||
import Workspaces from "./workspaces";
|
|
||||||
import Audio from "./audio";
|
|
||||||
import NetworkModule from "./network";
|
|
||||||
import Cpu from "./cpu-widget";
|
|
||||||
import Ram from "./ram";
|
|
||||||
import Disk from "./disk";
|
|
||||||
import Battery from "./battery";
|
|
||||||
import Time from "./time";
|
|
||||||
import Title from "./title";
|
|
||||||
|
|
||||||
export default function Bar(gdkmonitor: Gdk.Monitor) {
|
|
||||||
const { TOP, LEFT, RIGHT } = Astal.WindowAnchor;
|
|
||||||
|
|
||||||
//@ts-ignore
|
|
||||||
return (
|
|
||||||
<window
|
|
||||||
className="Bar"
|
|
||||||
gdkmonitor={gdkmonitor}
|
|
||||||
exclusivity={Astal.Exclusivity.EXCLUSIVE}
|
|
||||||
anchor={TOP | LEFT | RIGHT}
|
|
||||||
application={App}
|
|
||||||
>
|
|
||||||
<centerbox>
|
|
||||||
<box hexpand halign={Gtk.Align.START}>
|
|
||||||
<box className="nix-icon">
|
|
||||||
<icon icon="nixos-3" />
|
|
||||||
</box>
|
|
||||||
<Workspaces monitor={gdkmonitor} />
|
|
||||||
</box>
|
|
||||||
<box className="client-title">
|
|
||||||
<Title />
|
|
||||||
</box>
|
|
||||||
<box hexpand halign={Gtk.Align.END}>
|
|
||||||
<Audio />
|
|
||||||
<NetworkModule />
|
|
||||||
<Cpu />
|
|
||||||
<Ram />
|
|
||||||
<Disk />
|
|
||||||
<Battery />
|
|
||||||
<Time />
|
|
||||||
</box>
|
|
||||||
</centerbox>
|
|
||||||
</window>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { bind, Variable } from "astal"
|
|
||||||
import AstalWp from "gi://AstalWp?version=0.1"
|
|
||||||
|
|
||||||
export default function Audio() {
|
|
||||||
const speaker = AstalWp.get_default()?.default_speaker!
|
|
||||||
const derived = Variable.derive([bind(speaker, "volume"), bind(speaker, "mute")], (volume: number, muted: boolean) => {
|
|
||||||
if (muted) {
|
|
||||||
return { label: ` (muted)`, muted }
|
|
||||||
}
|
|
||||||
return { label: `${Math.floor(volume * 100)}% ` }
|
|
||||||
})
|
|
||||||
|
|
||||||
return <box className={derived((v) => ["status-box", v.muted && "inactive"].filter(Boolean).join(" "))}>
|
|
||||||
<label
|
|
||||||
label={derived((v) => v.label)} />
|
|
||||||
</box>
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { bind, Variable } from "astal"
|
|
||||||
import AstalBattery from "gi://AstalBattery?version=0.1"
|
|
||||||
|
|
||||||
export default function Battery() {
|
|
||||||
const battery = AstalBattery.get_default()
|
|
||||||
const battery_info = Variable.derive([bind(battery, "percentage"), bind(battery, "charging")], (percentage, charging) => {
|
|
||||||
const full_percentage = Math.floor(percentage * 100)
|
|
||||||
if (charging) {
|
|
||||||
return { label: `${full_percentage == 100 ? "FULL" : "CHR"}: ${full_percentage}%` }
|
|
||||||
}
|
|
||||||
return { label: `${full_percentage == 100 ? "FULL" : "BAT"}: ${full_percentage}%` }
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!battery.is_battery) {
|
|
||||||
return <></>
|
|
||||||
}
|
|
||||||
return <box className="status-box">
|
|
||||||
<label label={battery_info((i) => i.label)} />
|
|
||||||
</box>
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import { bind, GLib, Variable } from "astal";
|
|
||||||
import { calc_cpu_usage, get_cpu_snapshot } from "./cpu";
|
|
||||||
|
|
||||||
let s1 = get_cpu_snapshot();
|
|
||||||
let cpu_usage_percent = Variable(0);
|
|
||||||
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, () => {
|
|
||||||
const s2 = get_cpu_snapshot();
|
|
||||||
cpu_usage_percent.set(calc_cpu_usage(s1, s2));
|
|
||||||
s1 = s2;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function Cpu() {
|
|
||||||
return <box className="status-box">
|
|
||||||
<label label={bind(cpu_usage_percent).as((u) => `${u}% `)} />
|
|
||||||
</box>
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
import { GLib, Variable } from "astal";
|
|
||||||
import GTop from "gi://GTop";
|
|
||||||
import Wp05 from "gi://Wp";
|
|
||||||
|
|
||||||
type Snapshot = {
|
|
||||||
total: number;
|
|
||||||
user: number;
|
|
||||||
sys: number;
|
|
||||||
idle: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function get_cpu_snapshot() {
|
|
||||||
const cpu = new GTop.glibtop_cpu();
|
|
||||||
GTop.glibtop_get_cpu(cpu);
|
|
||||||
return {
|
|
||||||
total: cpu.total,
|
|
||||||
user: cpu.user + cpu.nice,
|
|
||||||
sys: cpu.sys,
|
|
||||||
idle: cpu.idle,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function calc_cpu_usage(a: Snapshot, b: Snapshot) {
|
|
||||||
const total_diff = b.total - a.total;
|
|
||||||
const active_diff = b.user + b.sys - (a.user + a.sys);
|
|
||||||
return Math.round(total_diff > 0 ? (100 * active_diff) / total_diff : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function get_ram_info() {
|
|
||||||
const mem = new GTop.glibtop_mem();
|
|
||||||
GTop.glibtop_get_mem(mem);
|
|
||||||
return {
|
|
||||||
total: mem.total,
|
|
||||||
used: mem.total - mem.free - mem.cached - mem.buffer,
|
|
||||||
free: mem.free,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function format_bytes(bytes: number) {
|
|
||||||
let units = ["B", "KiB", "MiB", "GiB", "TiB"];
|
|
||||||
let i = 0;
|
|
||||||
let num: number = bytes;
|
|
||||||
while (num >= 1024 && i < units.length - 1) {
|
|
||||||
num /= 1024;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${num.toFixed(2)}${units[i]}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function get_disk_space() {
|
|
||||||
const usage = new GTop.glibtop_fsusage();
|
|
||||||
GTop.glibtop_get_fsusage(usage, "/");
|
|
||||||
|
|
||||||
const free_bytes = usage.bavail * usage.block_size;
|
|
||||||
|
|
||||||
return format_bytes(free_bytes);
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import { bind, Variable } from "astal"
|
|
||||||
import { get_disk_space } from "./cpu"
|
|
||||||
|
|
||||||
let disk_space = Variable(get_disk_space()).poll(5000, () => get_disk_space())
|
|
||||||
export default function Disk() {
|
|
||||||
return <box className="status-box">
|
|
||||||
<label label={bind(disk_space).as((s) => `${s}`)} />
|
|
||||||
</box>
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
import { bind, Variable } from "astal";
|
|
||||||
import AstalNetwork from "gi://AstalNetwork?version=0.1";
|
|
||||||
|
|
||||||
const disconnected_label = { label: `Disconnected ⚠` };
|
|
||||||
|
|
||||||
function create_label(
|
|
||||||
primary: AstalNetwork.Primary,
|
|
||||||
wired: AstalNetwork.Wired,
|
|
||||||
wifi?: AstalNetwork.Wifi,
|
|
||||||
) {
|
|
||||||
if (primary === AstalNetwork.Primary.WIRED) {
|
|
||||||
return { label: `🖧 Wired ${wired.device.interface}` };
|
|
||||||
}
|
|
||||||
if (!wifi) {
|
|
||||||
return disconnected_label;
|
|
||||||
}
|
|
||||||
if (wifi.active_access_point !== null) {
|
|
||||||
return { label: `${wifi.ssid} (${wifi.strength}%) ` };
|
|
||||||
}
|
|
||||||
return disconnected_label;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function NetworkModule() {
|
|
||||||
const network = AstalNetwork.get_default();
|
|
||||||
const wifi = network.wifi;
|
|
||||||
const wired = network.wired;
|
|
||||||
|
|
||||||
let derived;
|
|
||||||
if (!wifi) {
|
|
||||||
derived = Variable.derive([bind(network, "primary")], (primary) => {
|
|
||||||
return create_label(primary, wired);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
derived = Variable.derive(
|
|
||||||
[bind(network, "primary"), bind(wifi, "ssid"), bind(wifi, "strength")],
|
|
||||||
(primary) => {
|
|
||||||
return create_label(primary, wired, wifi);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<box className="status-box">
|
|
||||||
<label label={derived((v) => v.label)} />
|
|
||||||
</box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import { bind, GLib, Variable } from "astal"
|
|
||||||
import { get_ram_info } from "./cpu"
|
|
||||||
|
|
||||||
let info = Variable(get_ram_info())
|
|
||||||
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, () => {
|
|
||||||
info.set(get_ram_info())
|
|
||||||
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
export default function Ram() {
|
|
||||||
return <box className="status-box">
|
|
||||||
<label label={bind(info).as((i) => `${Math.round((i.used / i.total) * 100)}% `)} />
|
|
||||||
</box>
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import { bind, GLib, Variable } from "astal"
|
|
||||||
|
|
||||||
let current_time = Variable(GLib.DateTime.new_now_local().format("%H:%M"))
|
|
||||||
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, () => {
|
|
||||||
const now = GLib.DateTime.new_now_local()
|
|
||||||
current_time.set(now.format("%b %e (%a) %H:%M"))
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
export default function Time() {
|
|
||||||
|
|
||||||
return <box className="status-box">
|
|
||||||
<label label={bind(current_time)} />
|
|
||||||
</box>
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import { bind, Variable } from "astal"
|
|
||||||
import AstalHyprland from "gi://AstalHyprland?version=0.1";
|
|
||||||
|
|
||||||
const hyprland = AstalHyprland.get_default()
|
|
||||||
|
|
||||||
function get_title() {
|
|
||||||
return hyprland.focusedClient?.title ?? ""
|
|
||||||
}
|
|
||||||
|
|
||||||
const title = Variable(get_title()).poll(200, () => get_title())
|
|
||||||
|
|
||||||
export default function Title() {
|
|
||||||
return (
|
|
||||||
<label label={title(t => t)} />
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import { bind } from "astal"
|
|
||||||
import { Gdk } from "astal/gtk3"
|
|
||||||
import AstalHyprland from "gi://AstalHyprland?version=0.1"
|
|
||||||
|
|
||||||
export default function Workspaces({ monitor }: { monitor: Gdk.Monitor }) {
|
|
||||||
const hypr = AstalHyprland.get_default()
|
|
||||||
|
|
||||||
return <box className="workspaces">
|
|
||||||
{bind(hypr, "workspaces").as(wss => wss.filter(ws => !(ws.id >= -99 && ws.id <= -2))
|
|
||||||
.sort((a, b) => a.id - b.id)
|
|
||||||
.map(ws => {
|
|
||||||
if (ws.monitor.model !== monitor.model) return <></>
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
className={bind(hypr, "focusedWorkspace").as(fw =>
|
|
||||||
ws === fw ? "focused" : "")}
|
|
||||||
onClicked={() => ws.focus()}>
|
|
||||||
{ws.id}
|
|
||||||
</button>
|
|
||||||
)
|
|
||||||
}))}
|
|
||||||
</box>
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
custom-fonts.inputs.nixpkgs.follows = "nixpkgs";
|
custom-fonts.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
status-bar = {
|
status-bar = {
|
||||||
url = "path:../astal";
|
url = "github:rocketcamel/dotfiles-status-bar";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user