summaryrefslogtreecommitdiff
path: root/pkgs/astal/src/widget/bar/focusedClient.lua
blob: 329cc4ed9e6d7b41a884fe4cae6b782c89a4c40a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
local astal = require("astal")
local Widget = require("astal.gtk3.widget")
local Hyprland = astal.require("AstalHyprland")
local bind = astal.bind

local hypr = Hyprland.get_default()

function Client(client)
	-- sanity check
	if not client then
		return nil
	end

	return Widget.Label({
		ellipsize = "END",
		max_width_chars = 50,
		label = bind(client, "title"):as(tostring),
	})
end

return function()
	local focused = bind(hypr, "focused-client")

	return Widget.Box({
		class_name = "focusedClient",
		visible = focused,
		focused:as(Client)
	})
end