ags: Add keyboard layout widget

This commit is contained in:
Sweetbread 2025-01-11 18:55:43 +03:00
parent 7fa285f0cc
commit a198789a17
3 changed files with 17 additions and 1 deletions

View File

@ -56,6 +56,8 @@ window.Bar {
} }
} }
.Layout.en { color: $accent; }
.SysTray button { .SysTray button {
all: unset; all: unset;
padding: 8px; padding: 8px;
@ -89,7 +91,7 @@ window.Bar {
.AudioSlider icon { margin-left: 8px; } .AudioSlider icon { margin-left: 8px; }
.Workspaces, .Media, .SysTray, .AudioSlider, .Time { .Workspaces, .Layout, .Media, .SysTray, .AudioSlider, .Time {
@extend %item; @extend %item;
} }
} }

View File

@ -5,6 +5,7 @@ import Time from "./elements/Time"
import Wifi from "./elements/Wifi" import Wifi from "./elements/Wifi"
import Audio from "./elements/Audio" import Audio from "./elements/Audio"
import Media from "./elements/Media" import Media from "./elements/Media"
import Layout from "./elements/Keyboard"
import SysTray from "./elements/SysTray" import SysTray from "./elements/SysTray"
import Workspaces from "./elements/Workspaces" import Workspaces from "./elements/Workspaces"
import BatteryLevel from "./elements/Battery" import BatteryLevel from "./elements/Battery"
@ -21,6 +22,7 @@ export default function Bar(monitor: Gdk.Monitor) {
<centerbox className="Container"> <centerbox className="Container">
<box hexpand halign={Gtk.Align.START}> <box hexpand halign={Gtk.Align.START}>
<Workspaces /> <Workspaces />
<Layout />
</box> </box>
<box> <box>
<Media /> <Media />

View File

@ -0,0 +1,12 @@
import { Variable, bind } from "astal"
import Hyprland from "gi://AstalHyprland"
export default function Layout() {
const hl = Hyprland.get_default();
let layout = Variable("en");
hl.connect("keyboard-layout", (_, __, l) => { layout.set(`${l}`.slice(0, 2).toLowerCase()) })
return <box className={bind(layout).as((l) => `Layout ${l}`)}>
<label label={bind(layout)}/>
</box>
}