summaryrefslogtreecommitdiff
path: root/widgets/tasklist.lua
blob: 3acd07f8a6f279be09c1fabef9d5a4f0dbeff631 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
local awful = require("awful")
local wibox = require("wibox")
local wibox_tooltip = require("lib.wiboxtooltip")
local beautiful = require("beautiful")

local separator = { widget = wibox.widget.separator, opacity = 0 }

function tooltip_tag_clients()
	local text = ""
	for _, c in ipairs(awful.screen.focused():get_clients(false)) do
		local ctext = c.name
		if c == client.focus then
			ctext = "* " .. ctext
		end
		text = text .. ctext .. "\n"
	end
	return text:sub(1, -2) -- remove last newline
end

function create_tasklist(s)
	local tasklist = awful.widget.tasklist {
		screen  = s,
		filter  = awful.widget.tasklist.filter.focused,
		buttons = tasklist_buttons,
		widget_template = {
			id     = "text_role",
			widget = wibox.widget.textbox,
			align  = "center",
		},
	}

	local popup = wibox_tooltip(tasklist, awful.widget.tasklist {
		screen = s,
		filter = awful.widget.tasklist.filter.currenttags,
		layout = {
			layout = wibox.layout.fixed.vertical,
		},
		widget_template = {
			id     = "text_role",
			widget = wibox.widget.textbox,
			align  = "center",
		},
		style = {
			font_focus = beautiful.font_mono_bold,
		},
	})

	return wibox.widget {
		layout = wibox.layout.align.horizontal,
		expand = "outside",
		separator,
		tasklist,
		separator,
	}
end

---- signal for changing tasklist filter based on layout
---- DOESNT WORK TODO
--local naughty = require("naughty")
--s:connect_signal("property::layout", function()
--	naughty.notify({
--		title = "Hello, AwesomeWM!",
--		text = "This is a notification.",
--		timeout = 5,  -- Timeout in seconds
--		position = "top_right"  -- Position on the screen
--	})
--	if awful.layout.get(s) == awful.layout.suit.max then
--		s.mytasklist.filter = awful.widget.tasklist.filter.currenttags
--	else
--		s.mytasklist.filter = awful.widget.tasklist.filter.focused
--	end
--end
--)

return create_tasklist