ags
ags copied to clipboard
feat: Add layout in Actives
It allows user to define widget like this:
import PanelButton from "../PanelButton"
import options from "options"
import { sh } from "lib/utils"
const hyprland = await Service.import("hyprland")
const switch_language = () => {
sh("hyprctl switchxkblayout gaming-keyboard next")
}
const update_icon = (callback_update) => {
let current_layout = hyprland.active.layout
callback_update(current_layout.language)
}
const short_name_lang = (name) => {
if (name.includes("Eng")){
return 'EN'
}
if (name.includes("Rus")){
return 'RU'
}
}
export default () => {
const btn = PanelButton({
window: "Language",
class_name: "language",
child: Widget.Label({
justification: "center",
vpack: "center",
}),
on_clicked: () => switch_language()
})
const update = () => {
update_icon(
(result) => {btn.label = short_name_lang(result)}
)
}
return btn.hook(hyprland, update)
}
This widget allows multilingual users to easily check their current kb layout and switch it from bar