summaryrefslogtreecommitdiff
path: root/awesome/bar.lua
blob: e9465d31e9dd0a8d749a16d49a72fddab13e5d79 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
local gears = require("gears")
local awful = require("awful")
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
-- Theme handling library
local beautiful = require("beautiful")
-- Notification library
local naughty = require("naughty")
local menubar = require("menubar")

local hotkeys_popup = require("awful.hotkeys_popup")
-- Enable hotkeys help widget for VIM and other apps
-- when client with a matching name is opened:
require("awful.hotkeys_popup.keys")

-- Load widgets
local widget_cpu_usage = require("widgets.cpu")
local widget_ram_usage = require("widgets.ram")
local widget_temperature = require("widgets.temperature")
local classiclayoutbox = require("widgets.classiclayoutbox")

-- Menu
-- Create a launcher widget and a main menu
myawesomemenu = {
	{ "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
	{ "restart", awesome.restart },
	{ "quit", function() awesome.quit() end },
}

mymainmenu = awful.menu({
	items = {
		{ "awesome", myawesomemenu, beautiful.awesome_icon },
		{ "open terminal", terminal }
	}
})

mylauncher = awful.widget.launcher({
	image = beautiful.awesome_icon,
	menu = mymainmenu
})

-- Menubar configuration
menubar.utils.terminal = terminal -- Set the terminal for applications that require it

-- Wibar
-- Create a textclock widget
--mytextclock = wibox.widget.textclock("%A, %B %e, %-I:%M %p")
-- x60
mytextclock = wibox.widget.textclock("%a, %b %e, %-H:%M")

-- Create a wibox for each screen and add it
local taglist_buttons = gears.table.join(
	awful.button({ }, 1, function(t) t:view_only() end),
	awful.button({ modkey }, 1, function(t) if client.focus then client.focus:move_to_tag(t) end end),
	awful.button({ }, 3, awful.tag.viewtoggle),
	awful.button({ modkey }, 3, function(t) if client.focus then client.focus:toggle_tag(t) end end),
	awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
	awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
)

local tasklist_buttons = gears.table.join(
	awful.button({ }, 1, function (c) c:emit_signal("request::activate", "tasklist", {raise = true}) end),
	awful.button({ }, 3, function() awful.menu.client_list({ theme = { width = 250 } }) end),
	awful.button({ }, 4, function () awful.client.focus.byidx(1) end),
	awful.button({ }, 5, function () awful.client.focus.byidx(-1) end)
)



--local function set_wallpaper(s)
--	-- Wallpaper
--	if beautiful.wallpaper then
--		local wallpaper = beautiful.wallpaper
--		-- If wallpaper is a function, call it with the screen
--		if type(wallpaper) == "function" then
--			wallpaper = wallpaper(s)
--		end
--		gears.wallpaper.maximized(wallpaper, s, true)
--	end
--end

-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
--screen.connect_signal("property::geometry", set_wallpaper)

awful.screen.connect_for_each_screen(function (s)
	awful.tag({"1", "2", "3", "4", "5", "6", "7", "8", "9"}, s, awful.layout.layouts[1])
	s.mypromptbox = awful.widget.prompt()

	--s.mylayoutbox = awful.widget.layoutbox {
	--	screen  = s,
	--	buttons = {
	--		awful.button({ }, 1, function () awful.layout.inc( 1) end),
	--		awful.button({ }, 3, function () awful.layout.inc(-1) end),
	--		awful.button({ }, 4, function () awful.layout.inc(-1) end),
	--		awful.button({ }, 5, function () awful.layout.inc( 1) end),
	--	}
	--}


	-- Create the wibox
	s.mywibox = awful.wibar({ position = "top", screen = s })

	-- Add widgets to the wibox
	s.mywibox:setup {
		layout = wibox.layout.align.horizontal,
		expand = "none",
		spacing = 8,
		-- Left widgets
		{
			layout = wibox.layout.fixed.horizontal,
			spacing = 8,
			{
				layout = wibox.layout.fixed.horizontal,
				--awful.widget.layoutbox(s),
				classiclayoutbox(s),
				awful.widget.taglist {
					screen  = s,
					filter  = awful.widget.taglist.filter.noempty,
					buttons = taglist_buttons,
				},
			},
			{
				layout = wibox.layout.align.horizontal,
				expand = "outside",
				wibox.widget { widget = wibox.widget.separator, opacity = 0 },
				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",
					},
				},
				wibox.widget { widget = wibox.widget.separator, opacity = 0 },
			},
		},
		-- Middle widget
		{
			layout = wibox.layout.fixed.horizontal,
			mytextclock,
		},
		-- Right widgets
		{
			layout = wibox.layout.fixed.horizontal,
			spacing = 8,
			{
				layout = wibox.layout.fixed.horizontal,
				wibox.widget.textbox "CPU: ",
				widget_cpu_usage,
				wibox.widget.textbox "% ",
				widget_temperature "/sys/class/hwmon/hwmon2/temp1_input",
				wibox.widget.textbox "°",
			},
			{
				layout = wibox.layout.fixed.horizontal,
				wibox.widget.textbox "RAM: ",
				widget_ram_usage,
				wibox.widget.textbox "%",
			},
			mylauncher,
		},
	}

	---- Signal for changing tasklist filter based on layout
	---- DOESNT WORK TODO
	--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
	--)

end)