-- ████████╗ ██████╗ ██████╗ ██████╗ █████╗ ███╗ ██╗███████╗██╗ -- ╚══██╔══╝██╔═══██╗██╔══██╗ ██╔══██╗██╔══██╗████╗ ██║██╔════╝██║ -- ██║ ██║ ██║██████╔╝ ██████╔╝███████║██╔██╗ ██║█████╗ ██║ -- ██║ ██║ ██║██╔═══╝ ██╔═══╝ ██╔══██║██║╚██╗██║██╔══╝ ██║ -- ██║ ╚██████╔╝██║ ██║ ██║ ██║██║ ╚████║███████╗███████╗ -- ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚══════╝ -- =================================================================== -- Initialization -- =================================================================== local awful = require("awful") local beautiful = require("beautiful") local wibox = require("wibox") local theme = require("theme") local lain = require("lain") local dpi = beautiful.xresources.apply_dpi local battery_widget = require("widgets.battery-widget.battery") local volume_widget = require("widgets.volume-widget.volume") -- import widgets local task_list = require("widgets.task-list") -- define module table local top_panel = {} local task_lists = {layout = wibox.layout.fixed.horizontal} awful.screen.connect_for_each_screen(function(s) table.insert(task_lists, task_list.create(s)) end) -- =================================================================== -- Bar Creation -- =================================================================== local icons_widget = wibox.widget { layout = wibox.layout.fixed.horizontal, wibox.layout.margin(wibox.widget.systray(), dpi(0), dpi(7), dpi(8), dpi(7)), wibox.layout.margin(volume_widget({widget_type='arc'}), dpi(5), dpi(7), dpi(8), dpi(7)), -- wibox.layout.margin(battery_widget({font=theme.font, display_notification=true}), dpi(7), dpi(7), dpi(7), dpi(7)), } local updates_indicator = wibox.widget{ { layout = wibox.layout.fixed.horizontal, { { widget = awful.widget.watch('bash -c "checkupdates | wc -l"', 360), }, top = 0, bottom = 0, left = 0, right = 0, widget = wibox.container.margin }, { { image = "/usr/share/icons/Papirus/48x48/apps/org.kde.archUpdate.svg", forced_width = 18, widget = wibox.widget.imagebox, }, top = 8, bottom = 0, left = 5, right = 0, widget = wibox.container.margin } }, widget = wibox.container.background } top_panel.create = function(s) local panel = awful.wibar({ screen = s, position = "top", ontop = true, height = beautiful.top_panel_height, width = s.geometry.width, bg = beautiful.bg_normal .. "99" }) panel:setup { expand = "none", layout = wibox.layout.align.horizontal, task_lists, wibox.widget.textclock('%a %b %d, %H:%M:%S', 1), { layout = wibox.layout.fixed.horizontal, icons_widget, wibox.widget.textbox(' | '), updates_indicator, wibox.widget.textbox(' | '), wibox.layout.margin(require("widgets.layout-box"), dpi(5), dpi(5), dpi(5), dpi(5)), 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() widget:set_markup(lain.util.markup.font(theme.font, "CPU: " .. cpu_now.usage .. "%")) end, }), wibox.widget.textbox(' | '), 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 | '), awful.widget.watch('bash -c "sensors | grep Tctl | cut -f 10 -d \' \' | cut -c 2-"', 5), wibox.widget.textbox(' '), } } -- =================================================================== -- 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) updates_indicator:connect_signal("button::press", function(c, _, _, button) awful.spawn('alacritty -e bash -c "yay ; echo \'\nDone, press any key to exit...\' ; read"') 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) end return top_panel