ags: setup example bar
This commit is contained in:
parent
347690561d
commit
dae1dcde13
10 changed files with 359 additions and 66 deletions
|
|
@ -1,13 +0,0 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
programs.ags = {
|
||||
enable = true;
|
||||
|
||||
# additional packages to add to gjs's runtime
|
||||
extraPackages = with pkgs; [
|
||||
gtksourceview
|
||||
webkitgtk
|
||||
accountsservice
|
||||
];
|
||||
};
|
||||
}
|
||||
2
homeManagerModules/niri/ags/.gitignore
vendored
Normal file
2
homeManagerModules/niri/ags/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
@girs/
|
||||
node_modules/
|
||||
26
homeManagerModules/niri/ags/ags.nix
Normal file
26
homeManagerModules/niri/ags/ags.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{ inputs, pkgs, ... }:
|
||||
{
|
||||
programs.ags = {
|
||||
enable = true;
|
||||
|
||||
configDir = ../ags;
|
||||
|
||||
# additional packages to add to gjs's runtime
|
||||
extraPackages = [
|
||||
inputs.ags.packages.${pkgs.system}.battery
|
||||
inputs.ags.packages.${pkgs.system}.mpris
|
||||
inputs.ags.packages.${pkgs.system}.wireplumber
|
||||
inputs.ags.packages.${pkgs.system}.network
|
||||
inputs.ags.packages.${pkgs.system}.tray
|
||||
];
|
||||
};
|
||||
|
||||
home.packages = [
|
||||
inputs.ags.packages.${pkgs.system}.io
|
||||
inputs.ags.packages.${pkgs.system}.battery
|
||||
inputs.ags.packages.${pkgs.system}.mpris
|
||||
inputs.ags.packages.${pkgs.system}.wireplumber
|
||||
inputs.ags.packages.${pkgs.system}.network
|
||||
inputs.ags.packages.${pkgs.system}.tray
|
||||
];
|
||||
}
|
||||
13
homeManagerModules/niri/ags/app.ts
Normal file
13
homeManagerModules/niri/ags/app.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { App } from "astal/gtk3";
|
||||
import style from "./style.scss";
|
||||
import Bar from "./widget/Bar";
|
||||
|
||||
App.start({
|
||||
css: style,
|
||||
instanceName: "js",
|
||||
requestHandler(request, res) {
|
||||
print(request);
|
||||
res("ok");
|
||||
},
|
||||
main: () => App.get_monitors().map(Bar),
|
||||
});
|
||||
21
homeManagerModules/niri/ags/env.d.ts
vendored
Normal file
21
homeManagerModules/niri/ags/env.d.ts
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
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;
|
||||
}
|
||||
88
homeManagerModules/niri/ags/style.scss
Normal file
88
homeManagerModules/niri/ags/style.scss
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
$bg: #212223;
|
||||
$fg: #f1f1f1;
|
||||
$accent: #378DF7;
|
||||
$radius: 7px;
|
||||
|
||||
window.Bar {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
background-color: $bg;
|
||||
color: $fg;
|
||||
font-size: 1.1em;
|
||||
font-weight: bold;
|
||||
|
||||
button {
|
||||
all: unset;
|
||||
background-color: transparent;
|
||||
|
||||
&:hover label {
|
||||
background-color: transparentize($fg, 0.84);
|
||||
border-color: transparentize($accent, 0.8);
|
||||
}
|
||||
|
||||
&:active label {
|
||||
background-color: transparentize($fg, 0.8)
|
||||
}
|
||||
}
|
||||
|
||||
label {
|
||||
transition: 200ms;
|
||||
padding: 0 8px;
|
||||
margin: 2px;
|
||||
border-radius: $radius;
|
||||
border: 1pt solid transparent;
|
||||
}
|
||||
|
||||
.Workspaces .focused label {
|
||||
color: $accent;
|
||||
border-color: $accent;
|
||||
}
|
||||
|
||||
.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: transparentize($fg, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
homeManagerModules/niri/ags/tsconfig.json
Normal file
22
homeManagerModules/niri/ags/tsconfig.json
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"strict": true,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "Bundler",
|
||||
// "checkJs": true,
|
||||
// "allowJs": true,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "/home/fedfer/.local/share/ags/gtk3",
|
||||
"paths": {
|
||||
"astal": [
|
||||
"/home/fedfer/.local/share/ags"
|
||||
],
|
||||
"astal/*": [
|
||||
"/home/fedfer/.local/share/ags/*"
|
||||
]
|
||||
},
|
||||
}
|
||||
}
|
||||
128
homeManagerModules/niri/ags/widget/Bar.tsx
Normal file
128
homeManagerModules/niri/ags/widget/Bar.tsx
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
import { App } from "astal/gtk3";
|
||||
import { Variable, GLib, bind } from "astal";
|
||||
import { Astal, Gtk, Gdk } from "astal/gtk3";
|
||||
import Mpris from "gi://AstalMpris";
|
||||
import Battery from "gi://AstalBattery";
|
||||
import Wp from "gi://AstalWp";
|
||||
import Network from "gi://AstalNetwork";
|
||||
import Tray from "gi://AstalTray";
|
||||
|
||||
function SysTray() {
|
||||
const tray = Tray.get_default();
|
||||
|
||||
return <box>
|
||||
{bind(tray, "items").as(items => items.map(item => {
|
||||
if (item.iconThemePath)
|
||||
App.add_icons(item.iconThemePath);
|
||||
|
||||
const menu = item.create_menu();
|
||||
|
||||
return <button
|
||||
tooltipMarkup={bind(item, "tooltipMarkup")}
|
||||
onDestroy={() => menu?.destroy()}
|
||||
onClickRelease={self => {
|
||||
menu?.popup_at_widget(self, Gdk.Gravity.SOUTH, Gdk.Gravity.NORTH, null);
|
||||
}}>
|
||||
<icon gIcon={bind(item, "gicon")} />
|
||||
</button>;
|
||||
}))}
|
||||
</box>;
|
||||
}
|
||||
|
||||
function Wifi() {
|
||||
const { wifi } = Network.get_default();
|
||||
|
||||
return <icon
|
||||
tooltipText={bind(wifi, "ssid").as(String)}
|
||||
className="Wifi"
|
||||
icon={bind(wifi, "iconName")}
|
||||
/>;
|
||||
}
|
||||
|
||||
function AudioSlider() {
|
||||
const speaker = Wp.get_default()?.audio.defaultSpeaker!;
|
||||
|
||||
return <box className="AudioSlider" css="min-width: 140px">
|
||||
<icon icon={bind(speaker, "volumeIcon")} />
|
||||
<slider
|
||||
hexpand
|
||||
onDragged={({ value }) => speaker.volume = value}
|
||||
value={bind(speaker, "volume")}
|
||||
/>
|
||||
</box>;
|
||||
}
|
||||
|
||||
function BatteryLevel() {
|
||||
const bat = Battery.get_default();
|
||||
|
||||
return <box className="Battery"
|
||||
visible={bind(bat, "isPresent")}>
|
||||
<icon icon={bind(bat, "batteryIconName")} />
|
||||
<label label={bind(bat, "percentage").as(p =>
|
||||
`${Math.floor(p * 100)} %`
|
||||
)} />
|
||||
</box>;
|
||||
}
|
||||
|
||||
function Media() {
|
||||
const mpris = Mpris.get_default();
|
||||
|
||||
return <box className="Media">
|
||||
{bind(mpris, "players").as(ps => ps[0] ? (
|
||||
<box>
|
||||
<box
|
||||
className="Cover"
|
||||
valign={Gtk.Align.CENTER}
|
||||
css={bind(ps[0], "coverArt").as(cover =>
|
||||
`background-image: url('${cover}');`
|
||||
)}
|
||||
/>
|
||||
<label
|
||||
label={bind(ps[0], "title").as(() =>
|
||||
`${ps[0].title} - ${ps[0].artist}`
|
||||
)}
|
||||
/>
|
||||
</box>
|
||||
) : (
|
||||
"Nothing Playing"
|
||||
))}
|
||||
</box>;
|
||||
}
|
||||
|
||||
function Time({ format = "%H:%M - %A %e." }) {
|
||||
const time = Variable<string>("").poll(1000, () =>
|
||||
GLib.DateTime.new_now_local().format(format)!);
|
||||
|
||||
return <label
|
||||
className="Time"
|
||||
onDestroy={() => time.drop()}
|
||||
label={time()}
|
||||
/>;
|
||||
}
|
||||
|
||||
export default function Bar(monitor: Gdk.Monitor) {
|
||||
const anchor = Astal.WindowAnchor.TOP
|
||||
| Astal.WindowAnchor.LEFT
|
||||
| Astal.WindowAnchor.RIGHT;
|
||||
|
||||
return <window
|
||||
className="Bar"
|
||||
gdkmonitor={monitor}
|
||||
exclusivity={Astal.Exclusivity.EXCLUSIVE}
|
||||
anchor={anchor}>
|
||||
<centerbox>
|
||||
<box hexpand halign={Gtk.Align.START}>
|
||||
</box>
|
||||
<box>
|
||||
<Media />
|
||||
</box>
|
||||
<box hexpand halign={Gtk.Align.END} >
|
||||
<SysTray />
|
||||
<Wifi />
|
||||
<AudioSlider />
|
||||
<BatteryLevel />
|
||||
<Time />
|
||||
</box>
|
||||
</centerbox>
|
||||
</window>;
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
imports = [ ./ags.nix ];
|
||||
imports = [ ./ags/ags.nix ];
|
||||
|
||||
services.mako = {
|
||||
enable = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue