ags(bar,scripts,i18n): added i18n system(wip), changed some bar stuff and started doing control center

This commit is contained in:
retrozinndev
2025-02-04 12:39:25 -03:00
parent 09692bae90
commit b544f4a45b
32 changed files with 980 additions and 141 deletions
+4 -2
View File
@@ -19,7 +19,8 @@ export function Audio() {
} as Widget.LabelProps),
new Widget.Label({
className: "icon nf",
label: bind(wp!.defaultSpeaker, "volume").as((volume: number) => Math.round(volume * 100).toString() + "%")
label: bind(wp!.defaultSpeaker, "volume").as((volume: number) =>
Math.round(volume * 100).toString() + "%")
} as Widget.LabelProps)
]
})
@@ -33,7 +34,8 @@ export function Audio() {
label: "󰍬"
} as Widget.LabelProps),
new Widget.Label({
label: bind(wp!.defaultMicrophone, "volume").as((volume: number) => Math.round(volume * 100).toString() + "%")
label: bind(wp!.defaultMicrophone, "volume").as((volume: number) =>
Math.round(volume * 100).toString() + "%")
} as Widget.LabelProps)
]
})
+5 -7
View File
@@ -1,16 +1,14 @@
import { Box, Button } from "astal/gtk3/widget";
import { GLib, Variable } from "astal";
import { Widget } from "astal/gtk3";
const dateTimeFormat = "%A %d, %H:%M"
const time = new Variable<string>("").poll(600, () =>
GLib.DateTime.new_now_local().format(dateTimeFormat)!);
import { getDateTime } from "../../scripts/time";
import { GLib } from "astal";
export function Clock(): JSX.Element {
return new Widget.Box({
className: "clock",
child: new Widget.Button({
label: time()
label: getDateTime().as((dateTime: GLib.DateTime) => {
return dateTime.format("%A %d, %H:%M")
})
} as Widget.ButtonProps)
} as Widget.BoxProps);
}
+7 -10
View File
@@ -1,6 +1,7 @@
import { bind } from "astal";
import { Gtk, Widget } from "astal/gtk3";
import AstalHyprland from "gi://AstalHyprland";
import { getAppIcon } from "../../scripts/apps";
const hyprland = AstalHyprland.get_default();
@@ -11,14 +12,8 @@ export function FocusedWindow() {
children: [
new Widget.Icon({
className: "icon",
icon: bind(hyprland, "focusedClient").as(Boolean) && bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) => {
switch(client.initialClass) {
case "zen":
return "zen-browser";
default:
return client.initialClass;
}}),
icon: bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) =>
getAppIcon(client.initialClass) || "image-missing"),
iconSize: Gtk.IconSize.SMALL_TOOLBAR
}),
new Widget.Box({
@@ -29,12 +24,14 @@ export function FocusedWindow() {
new Widget.Label({
className: "class",
xalign: 0,
label: bind(hyprland, "focusedClient").as(Boolean) && bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) => client.get_class())
label: bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) =>
client?.["class"])
} as Widget.LabelProps),
new Widget.Label({
className: "title",
xalign: 0,
label: bind(hyprland, "focusedClient").as(Boolean) && bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) => client.get_title())
label: bind(hyprland, "focusedClient").as((client: AstalHyprland.Client) =>
client?.["title"])
} as Widget.LabelProps)
]
})
+2 -2
View File
@@ -1,10 +1,10 @@
import { Box, Button } from "astal/gtk3/widget";
import { Process } from "astal";
import AstalHyprland from "gi://AstalHyprland";
export function Logo() {
return (
<Box className={"logo"}>
<Button onClick={ () => Process.exec("hyprctl dispatch exec anyrun") } label={""} />
<Button onClick={ () => AstalHyprland.get_default().dispatch("exec", "anyrun") } label={""} />
</Box>
)
}
+54 -8
View File
@@ -2,7 +2,6 @@ import { bind } from "astal";
import { Gtk, Widget } from "astal/gtk3";
import AstalMpris from "gi://AstalMpris";
import { Separator, SeparatorProps } from "../Separator";
import { Wal } from "../../scripts/pywal";
const mpris: AstalMpris.Mpris = AstalMpris.get_default();
let defaultPlayer: (AstalMpris.Player|undefined) = mpris.get_players()?.[0];
@@ -10,6 +9,7 @@ let defaultPlayer: (AstalMpris.Player|undefined) = mpris.get_players()?.[0];
const playerIcons = {
spotify: '󰓇',
clapper: '󰿎',
mpv: '',
spotube: '󰋋',
firefox: '󰈹'
}
@@ -20,7 +20,46 @@ export function Media(): JSX.Element {
defaultPlayer = players?.[0] as AstalMpris.Player;
});
return new Widget.EventBox({
const mediaControlsRevealer: Widget.Revealer = new Widget.Revealer({
transitionType: Gtk.RevealerTransitionType.SLIDE_RIGHT,
transitionDuration: 260,
revealChild: false,
child: new Widget.Box({
className: "media-controls",
homogeneous: false,
children: [
new Widget.Button({
className: "previous",
label: "󰒮",
onClick: () => {
if(bind(defaultPlayer!, "canGoPrevious").as(Boolean))
defaultPlayer?.previous();
}
} as Widget.ButtonProps),
new Widget.Button({
className: "pause",
label: bind(defaultPlayer!, "playback_status").as((status: AstalMpris.PlaybackStatus) => {
return status === AstalMpris.PlaybackStatus.PLAYING ? "󰏤" : "󰐊"
}),
onClick: () => {
if(bind(defaultPlayer!, "canPlay").as(Boolean)
|| bind(defaultPlayer!, "canPause").as(Boolean))
defaultPlayer?.play_pause();
}
} as Widget.ButtonProps),
new Widget.Button({
className: "next",
label: "󰒭",
onClick: () => {
if(bind(defaultPlayer!, "canGoNext").as(Boolean))
defaultPlayer?.next();
}
} as Widget.ButtonProps)
]
} as Widget.BoxProps)
} as Widget.RevealerProps);
const mediaWidget = new Widget.EventBox({
className: "media-eventbox",
visible: bind(mpris, "players").as((players: Array<AstalMpris.Player>) => players?.[0]).as(Boolean),
child: new Widget.Box({
@@ -42,7 +81,7 @@ export function Media(): JSX.Element {
} as Widget.LabelProps),
Separator({
size: 2,
cssColor: `rgb(150, 150, 150)`,
cssColor: `rgb(180, 180, 180)`,
alpha: 1
} as SeparatorProps),
new Widget.Label({
@@ -51,12 +90,19 @@ export function Media(): JSX.Element {
} as Widget.LabelProps)
]
} as Widget.BoxProps),
new Widget.Revealer({
transitionType: Gtk.RevealerTransitionType.SLIDE_RIGHT,
transitionDuration: 400,
revealChild: false //FIXME
} as Widget.RevealerProps)
mediaControlsRevealer
]
} as Widget.BoxProps)
} as Widget.EventBoxProps);
mediaWidget.connect("hover", () => {
mediaControlsRevealer.set_reveal_child(true);
mediaWidget.className = mediaWidget.className + " reveal";
});
mediaWidget.connect("hover-lost", () => {
mediaControlsRevealer.set_reveal_child(false);
mediaWidget.className = mediaWidget.className.replaceAll(" reveal", "");
})
return mediaWidget;
}
+4 -1
View File
@@ -1,5 +1,5 @@
import { bind } from "astal";
import { Astal, Gtk, Widget } from "astal/gtk3";
import { Gtk, Widget } from "astal/gtk3";
import AstalTray from "gi://AstalTray"
const astalTray = AstalTray.get_default();
@@ -7,6 +7,7 @@ const astalTray = AstalTray.get_default();
export function Tray() {
return new Widget.Box({
className: "tray",
visible: bind(astalTray, "items").as((items: Array<AstalTray.TrayItem>) => items.length > 0),
children: bind(astalTray, "items").as((items: Array<AstalTray.TrayItem>) =>
items.map((item: AstalTray.TrayItem) =>
new Widget.MenuButton({
@@ -15,6 +16,8 @@ export function Tray() {
menuModel: bind(item, "menuModel"),
usePopover: false,
actionGroup: bind(item, "actionGroup").as((actionGroup: any) => ["dbusmenu", actionGroup]),
direction: Gtk.ArrowType.DOWN,
halign: Gtk.Align.CENTER,
child: new Widget.Icon({
gIcon: bind(item, "gicon"),
iconSize: Gtk.IconSize.SMALL_TOOLBAR
+24 -14
View File
@@ -1,21 +1,31 @@
import { bind } from "astal";
import { Widget } from "astal/gtk3";
import { Gdk, Gtk, Widget } from "astal/gtk3";
import AstalHyprland from "gi://AstalHyprland";
const hyprland = AstalHyprland.get_default();
export function Workspaces() {
return new Widget.Box({
className: "workspaces",
children: bind(hyprland, "workspaces").as((workspaces) =>
workspaces.sort((a: AstalHyprland.Workspace, b: AstalHyprland.Workspace) =>
a.get_id() - b.get_id())
.map((workspace: AstalHyprland.Workspace) =>
new Widget.Button({
className: bind(hyprland, "focusedWorkspace").as((focusedWs: AstalHyprland.Workspace) => workspace === focusedWs ? "focus" : ""),
onClicked: () => workspace.focus()
} as Widget.ButtonProps)
)
)
} as Widget.BoxProps);
const workspacesEventBox = new Widget.EventBox({
onScroll: (_, event) =>
event.delta_y > 0 ? hyprland.dispatch("workspace", "e-1") : hyprland.dispatch("workspace", "e+1"),
child: new Widget.Box({
className: "workspaces",
vexpand: false,
valign: Gtk.Align.CENTER,
children: bind(hyprland, "workspaces").as((workspaces) => {
const sortedWorkspaces = workspaces.sort((a: AstalHyprland.Workspace, b: AstalHyprland.Workspace) => a.get_id() - b.get_id());
return sortedWorkspaces.map((workspace: AstalHyprland.Workspace) =>
new Widget.Button({
className: bind(hyprland, "focusedWorkspace").as((focusedWs: AstalHyprland.Workspace) => workspace === focusedWs ? "focus" : ""),
visible: true,
onClicked: () => workspace.focus()
} as Widget.ButtonProps)
)
})
} as Widget.BoxProps)
} as Widget.EventBoxProps);
return workspacesEventBox;
}