dotfiles/awesome/components/pastel/top-panel.lua

75 lines
2.9 KiB
Lua

-- ████████╗ ██████╗ ██████╗ ██████╗ █████╗ ███╗ ██╗███████╗██╗
-- ╚══██╔══╝██╔═══██╗██╔══██╗ ██╔══██╗██╔══██╗████╗ ██║██╔════╝██║
-- ██║ ██║ ██║██████╔╝ ██████╔╝███████║██╔██╗ ██║█████╗ ██║
-- ██║ ██║ ██║██╔═══╝ ██╔═══╝ ██╔══██║██║╚██╗██║██╔══╝ ██║
-- ██║ ╚██████╔╝██║ ██║ ██║ ██║██║ ╚████║███████╗███████╗
-- ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚══════╝
-- ===================================================================
-- Initialization
-- ===================================================================
local awful = require("awful")
local beautiful = require("beautiful")
local wibox = require("wibox")
local gears = require("gears")
local dpi = beautiful.xresources.apply_dpi
-- import widgets
local task_list = require("widgets.task-list")
-- define module table
local top_panel = {}
-- ===================================================================
-- Bar Creation
-- ===================================================================
top_panel.create = function(s)
local panel = awful.wibar({
screen = s,
position = "top",
ontop = true,
height = beautiful.top_panel_height,
width = s.geometry.width,
})
panel:setup {
expand = "none",
layout = wibox.layout.align.horizontal,
task_list.create(s),
wibox.widget.textclock('%a %b %d, %H:%M:%S', 1),
{
layout = wibox.layout.fixed.horizontal,
wibox.layout.margin(wibox.widget.systray(), dpi(5), dpi(5), dpi(5), dpi(5)),
require("widgets.bluetooth"),
require("widgets.network")(),
require("widgets.battery"),
wibox.layout.margin(require("widgets.layout-box"), dpi(5), dpi(5), dpi(5), dpi(5))
}
}
-- ===================================================================
-- Functionality
-- ===================================================================
-- hide panel when client is fullscreen
local function change_panel_visibility(client)
if client.screen == s then
panel.ontop = not client.fullscreen
end
end
-- connect panel visibility function to relevant signals
client.connect_signal("property::fullscreen", change_panel_visibility)
client.connect_signal("focus", change_panel_visibility)
end
return top_panel