2022-07-19 19:45:11 +02:00
|
|
|
-- ████████╗ ██████╗ ██████╗ ██████╗ █████╗ ███╗ ██╗███████╗██╗
|
|
|
|
-- ╚══██╔══╝██╔═══██╗██╔══██╗ ██╔══██╗██╔══██╗████╗ ██║██╔════╝██║
|
|
|
|
-- ██║ ██║ ██║██████╔╝ ██████╔╝███████║██╔██╗ ██║█████╗ ██║
|
|
|
|
-- ██║ ██║ ██║██╔═══╝ ██╔═══╝ ██╔══██║██║╚██╗██║██╔══╝ ██║
|
|
|
|
-- ██║ ╚██████╔╝██║ ██║ ██║ ██║██║ ╚████║███████╗███████╗
|
|
|
|
-- ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚══════╝
|
|
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
-- Initialization
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
|
|
|
|
|
|
local awful = require("awful")
|
|
|
|
local beautiful = require("beautiful")
|
|
|
|
local wibox = require("wibox")
|
2022-07-19 22:11:37 +02:00
|
|
|
local theme = require("theme")
|
2022-07-19 19:45:11 +02:00
|
|
|
local gears = require("gears")
|
2022-07-19 22:11:37 +02:00
|
|
|
local lain = require("lain")
|
2022-07-19 19:45:11 +02:00
|
|
|
local dpi = beautiful.xresources.apply_dpi
|
2022-07-19 22:11:37 +02:00
|
|
|
local icons = gears.filesystem.get_configuration_dir() .. "/icons/top-panel/"
|
2022-07-19 19:45:11 +02:00
|
|
|
|
|
|
|
-- import widgets
|
|
|
|
local task_list = require("widgets.task-list")
|
|
|
|
|
|
|
|
-- define module table
|
|
|
|
local top_panel = {}
|
|
|
|
|
|
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
-- Bar Creation
|
|
|
|
-- ===================================================================
|
|
|
|
|
|
|
|
|
2022-07-19 22:11:37 +02:00
|
|
|
local updates_indicator = wibox.widget{
|
|
|
|
{
|
|
|
|
layout = wibox.layout.fixed.horizontal,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
widget = awful.widget.watch('bash -c "checkupdates | wc -l"', 360),
|
|
|
|
},
|
|
|
|
top = 4, bottom = 4, left = 10, right = 10,
|
|
|
|
widget = wibox.container.margin
|
|
|
|
},
|
|
|
|
wibox.widget.textbox(' Updates '),
|
|
|
|
},
|
|
|
|
widget = wibox.container.background
|
|
|
|
}
|
|
|
|
|
2022-07-19 19:45:11 +02:00
|
|
|
top_panel.create = function(s)
|
|
|
|
local panel = awful.wibar({
|
|
|
|
screen = s,
|
|
|
|
position = "top",
|
|
|
|
ontop = true,
|
|
|
|
height = beautiful.top_panel_height,
|
|
|
|
width = s.geometry.width,
|
2022-07-19 22:11:37 +02:00
|
|
|
bg = beautiful.bg_normal .. "99"
|
2022-07-19 19:45:11 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
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)),
|
2022-07-21 14:00:26 +02:00
|
|
|
wibox.widget.textbox(' | '),
|
2022-07-19 22:11:37 +02:00
|
|
|
updates_indicator,
|
|
|
|
wibox.widget.textbox(' | '),
|
|
|
|
lain.widget.mem({
|
|
|
|
settings = function()
|
|
|
|
widget:set_markup(lain.util.markup.font(theme.font, " " .. mem_now.used .. " MB "))
|
|
|
|
end,
|
|
|
|
}),
|
|
|
|
wibox.widget.textbox(' | '),
|
|
|
|
lain.widget.cpu({
|
|
|
|
settings = function()
|
2022-07-21 14:00:26 +02:00
|
|
|
widget:set_markup(lain.util.markup.font(theme.font, " CPU: " .. cpu_now.usage .. "% "))
|
2022-07-19 22:11:37 +02:00
|
|
|
end,
|
|
|
|
}),
|
|
|
|
wibox.widget.textbox(' | '),
|
2022-07-21 14:00:26 +02:00
|
|
|
awful.widget.watch('bash -c "/usr/bin/cat /proc/cpuinfo | grep MHz | cut -b 12- | sort -r | head -n 1 | xargs printf \'%f / 1000\n\' | bc -l | cut -b -4"', 1),
|
|
|
|
wibox.widget.textbox('GHz | '),
|
2022-07-19 22:11:37 +02:00
|
|
|
awful.widget.watch('bash -c "sensors | grep Tctl | cut -f 10 -d \' \' | cut -c 2-"', 5),
|
|
|
|
wibox.widget.textbox(' | '),
|
|
|
|
wibox.layout.margin(require("widgets.layout-box"), dpi(5), dpi(5), dpi(5), dpi(5)),
|
|
|
|
wibox.widget.textbox(' '),
|
2022-07-19 19:45:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- ===================================================================
|
|
|
|
-- 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)
|
|
|
|
|
2022-07-19 22:11:37 +02:00
|
|
|
updates_indicator:connect_signal("button::press", function(c, _, _, button)
|
2022-07-20 00:24:45 +02:00
|
|
|
awful.spawn('alacritty -e bash -c "yay ; echo \'\nDone, press any key to exit...\' ; read"')
|
2022-07-19 22:11:37 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
updates_indicator:connect_signal("mouse::enter", function(c) c:set_bg(theme.bg_normal .. "99") end)
|
|
|
|
updates_indicator:connect_signal("mouse::leave", function(c) c:set_bg(theme.bg_normal .. "20") end)
|
|
|
|
|
|
|
|
|
2022-07-19 19:45:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return top_panel
|