Powerline items

This commit is contained in:
Thomas Avé 2022-07-21 22:32:00 +02:00
parent a1e43a186d
commit 61a3faad4b
2 changed files with 69 additions and 44 deletions

View File

@ -22,26 +22,39 @@ local volume_widget = require("widgets.volume-widget.volume")
-- import widgets
local task_list = require("widgets.task-list")
-- define module table
-- ===================================================================
-- Helper functions
-- ===================================================================
local function pl(widget, bgcolor, adjacentcolor)
local container = wibox.widget{
{
{
layout = wibox.layout.fixed.horizontal,
wibox.layout.margin(widget, dpi(6), dpi(10)),
lain.util.separators.arrow_left(bgcolor, adjacentcolor),
},
bg = bgcolor,
widget = wibox.container.background
},
top = 2, bottom = 2, left = 0, right = 0,
widget = wibox.container.margin
}
return container
end
-- ===================================================================
-- Custom Widgets
-- ===================================================================
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,
@ -58,13 +71,41 @@ local updates_indicator = wibox.widget{
forced_width = 18,
widget = wibox.widget.imagebox,
},
top = 8, bottom = 0, left = 5, right = 0,
top = 7, bottom = 0, left = 5, right = 0,
widget = wibox.container.margin
}
},
widget = wibox.container.background
}
local frequency_widget = wibox.widget{
layout = wibox.layout.fixed.horizontal,
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 | awk \'{printf \\"%.2f\\n\\", $0}\'"', 1),
wibox.widget.textbox('GHz')
}
local memory_widget = wibox.widget{
layout = wibox.layout.fixed.horizontal,
lain.widget.mem({
settings = function()
widget:set_markup(lain.util.markup.font(theme.font, mem_now.used .. " MB"))
end,
}),
}
local cpu_widget = wibox.widget{
layout = wibox.layout.fixed.horizontal,
lain.widget.cpu({
settings = function()
widget:set_markup(lain.util.markup.font(theme.font, "CPU: " .. cpu_now.usage .. "%"))
end,
})
}
-- ===================================================================
-- Bar Creation
-- ===================================================================
top_panel.create = function(s)
local panel = awful.wibar({
screen = s,
@ -72,7 +113,7 @@ top_panel.create = function(s)
ontop = true,
height = beautiful.top_panel_height,
width = s.geometry.width,
bg = beautiful.bg_normal .. "99"
bg = theme.bg_normal .. "99"
})
panel:setup {
@ -82,28 +123,15 @@ top_panel.create = function(s)
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 | awk \'{printf \\"%.2f\\n\\", $0}\'"', 1),
wibox.widget.textbox('GHz | '),
awful.widget.watch('bash -c "sensors | grep Tctl | cut -f 10 -d \' \' | cut -c 2-"', 5),
wibox.widget.textbox(' '),
pl(wibox.widget{}, theme.bg_normal .. "00", theme.top_panel_powerline),
pl(wibox.widget.systray(), theme.top_panel_powerline, theme.bg_normal),
pl(volume_widget({widget_type='icon_and_text'}), theme.bg_normal, theme.top_panel_powerline),
pl(updates_indicator, theme.top_panel_powerline, theme.bg_normal),
pl(memory_widget, theme.bg_normal, theme.top_panel_powerline),
pl(cpu_widget, theme.top_panel_powerline, theme.bg_normal),
pl(frequency_widget, theme.bg_normal, theme.top_panel_powerline),
pl(awful.widget.watch('bash -c "sensors | grep Tctl | cut -f 10 -d \' \' | cut -c 2-"', 5), theme.top_panel_powerline, theme.bg_normal),
pl(require("widgets.layout-box"), theme.bg_normal, theme.bg_normal),
}
}
@ -128,10 +156,6 @@ top_panel.create = function(s)
awful.spawn('bash -c "WINIT_X11_SCALE_FACTOR=1 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

View File

@ -48,7 +48,7 @@ theme.useless_gap = dpi(5)
theme.gap_single_client = false
-- Window Borders
theme.border_width = dpi(1)
theme.border_width = dpi(0)
theme.border_normal = theme.bg_normal
theme.border_focus = "#ff0000"
theme.border_marked = theme.fg_urgent
@ -72,12 +72,13 @@ theme.tasklist_fg_normal = theme.fg_normal
-- Panel Sizing
theme.top_panel_height = dpi(32)
theme.top_panel_powerline = "#3480eb"
-- Notification Sizing
theme.notification_max_width = dpi(350)
-- System Tray
theme.bg_systray = theme.bg_normal
theme.bg_systray = theme.top_panel_powerline
theme.systray_icon_spacing = dpi(15)
-- Titlebars