Reworked a whole lot. New config file and theme config file for easier changes. Did #19. And much more

This commit is contained in:
Kievits Rene
2022-06-14 06:33:33 +02:00
parent fd74ab9fb4
commit 521d392769
60 changed files with 2216 additions and 1450 deletions

View File

@@ -19,7 +19,7 @@ return function(s, widgets)
maximum_width = dpi(500),
placement = function(c) awful.placement.top(c, { margins = dpi(10) }) end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end
}
@@ -27,42 +27,42 @@ return function(s, widgets)
top = 55
}
local function prepare_widgets(widgets)
local function prepare_widgets(w)
local layout = {
forced_height = 45,
forced_height = dpi(50),
layout = wibox.layout.fixed.horizontal
}
for i, widget in pairs(widgets) do
for i, widget in pairs(w) do
if i == 1 then
table.insert(layout,
{
widget,
left = dpi(6),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
elseif i == #widgets then
widget,
left = dpi(6),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
elseif i == #w then
table.insert(layout,
{
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
else
table.insert(layout,
{
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
end
end
return layout
@@ -78,45 +78,45 @@ return function(s, widgets)
client.connect_signal(
"manage",
function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end
end
)
client.connect_signal(
"unmanage",
function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end
end
)
client.connect_signal(
"tag::switched",
"property::selected",
function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end
end
)
awesome.connect_signal(
"refresh",
function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end
end
)
end

View File

@@ -8,31 +8,38 @@ local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local desktop_parser = require("src.tools.desktop_parser")
return function(screen, programs)
local function create_dock_element(class, program, name, user_icon, is_steam, size)
if program == nil or class == nil then
local function create_dock_element(program, size)
if not program then
return
end
is_steam = is_steam or false
user_icon = user_icon or nil
local dock_element = wibox.widget {
{
{
{
resize = true,
forced_width = size,
forced_height = size,
image = user_icon or Get_icon(user_vars.icon_theme, nil, program, class, is_steam),
widget = wibox.widget.imagebox,
id = "icon",
{
resize = true,
widget = wibox.widget.imagebox,
valign = "center",
halign = "center",
id = "icon",
},
id = "icon_container",
strategy = "exact",
width = size,
height = size,
widget = wibox.container.constraint
},
margins = dpi(5),
widget = wibox.container.margin,
id = "margin"
},
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 10)
gears.shape.rounded_rect(cr, width, height, dpi(10))
end,
bg = color["Grey900"],
widget = wibox.container.background,
@@ -44,8 +51,10 @@ return function(screen, programs)
widget = wibox.container.margin
}
dock_element.background.margin.icon_container.icon.image = xdg_icon_lookup:find_icon(program["Icon"], 64)
for _, c in ipairs(client.get()) do
if string.lower(c.class):match(program) and c == client.focus then
if string.lower(c.class):match(program["Icon"]) and c == client.focus then
dock_element.background.bg = color["Grey800"]
end
end
@@ -54,18 +63,16 @@ return function(screen, programs)
dock_element:connect_signal(
"button::press",
function()
if is_steam then
awful.spawn("steam steam://rungameid/" .. program)
else
awful.spawn(program)
function(_, _, _, button)
if button == 1 then
awful.spawn(program["Exec"])
end
end
)
awful.tooltip {
objects = { dock_element },
text = name,
text = program["Name"],
mode = "outside",
preferred_alignments = "middle",
margins = dpi(10)
@@ -81,10 +88,10 @@ return function(screen, programs)
visible = true,
screen = screen,
type = "dock",
height = user_vars.dock_icon_size + 10,
height = User_config.dock_icon_size + 10,
placement = function(c) awful.placement.bottom(c, { margins = dpi(10) }) end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 15)
gears.shape.rounded_rect(cr, width, height, dpi(16))
end
}
@@ -97,14 +104,14 @@ return function(screen, programs)
type = "dock",
id = "fakedock",
height = dpi(10),
placement = function(c) awful.placement.bottom(c, { margins = dpi(0) }) end,
placement = function(c) awful.placement.bottom(c) end,
}
local function get_dock_elements(pr)
local dock_elements = { layout = wibox.layout.fixed.horizontal }
for i, p in ipairs(pr) do
dock_elements[i] = create_dock_element(p[1], p[2], p[3], p[4], p[5], user_vars.dock_icon_size)
dock_elements[i] = create_dock_element(desktop_parser(p), User_config.dock_icon_size)
end
return dock_elements
@@ -118,7 +125,7 @@ return function(screen, programs)
for i = 0, amount, 1 do
fake_elements[i] = wibox.widget {
bg = '00000000',
forced_width = user_vars.dock_icon_size + dpi(20),
forced_width = User_config.dock_icon_size + dpi(20),
forced_height = dpi(10),
id = "fake",
widget = wibox.container.background
@@ -134,27 +141,31 @@ return function(screen, programs)
local indicators = { layout = wibox.layout.flex.horizontal, spacing = dpi(5) }
local col = color["Grey600"]
for i, c in ipairs(clients) do
if string.lower(c.class or c.name):match(string.lower(pr[1]) or string.lower(pr[2])) then
if c == client.focus then
col = color["YellowA200"]
elseif c.urgent then
col = color["RedA200"]
elseif c.maximized then
col = color["GreenA200"]
elseif c.minimized then
col = color["BlueA200"]
elseif c.fullscreen then
col = color["PinkA200"]
else
col = color["Grey600"]
local icon = desktop_parser(pr)
if icon then
local icon_name = icon["Icon"] or ""
if icon_name:match(string.lower(c.class or c.name or nil)) then
if c == client.focus then
col = color["YellowA200"]
elseif c.urgent then
col = color["RedA200"]
elseif c.maximized then
col = color["GreenA200"]
elseif c.minimized then
col = color["BlueA200"]
elseif c.fullscreen then
col = color["PinkA200"]
else
col = color["Grey600"]
end
indicators[i] = wibox.widget {
widget = wibox.container.background,
shape = gears.shape.rounded_rect,
forced_height = dpi(3),
bg = col,
forced_width = dpi(5),
}
end
indicators[i] = wibox.widget {
widget = wibox.container.background,
shape = gears.shape.rounded_rect,
forced_height = dpi(3),
bg = col,
forced_width = dpi(5),
}
end
end
container[index] = wibox.widget {
@@ -206,7 +217,7 @@ return function(screen, programs)
if not c.minimized then
local y = c:geometry().y
local h = c.height
if (y + h) >= s.geometry.height - user_vars.dock_icon_size - 35 then
if (y + h) >= s.geometry.height - User_config.dock_icon_size - 35 then
dock.visible = false
return
else
@@ -304,10 +315,4 @@ return function(screen, programs)
dock_intelligent_hide:again()
end
)
dock:setup {
get_dock_elements(programs),
create_incicator_widget(programs),
layout = wibox.layout.fixed.vertical
}
end

View File

@@ -3,50 +3,71 @@
--------------------------------------------------------------------------------------------------------------
return function(s)
xdg_icon_lookup = require("src.tools.xdg_icon_lookup")()
-- Every Widget
--[[
If you are going to use a widget on a single screen only, put it inside the s.index == X where X is the screen number.
This will lead to better performance and prevent widgets to be loaded but not used
--]]
s.audio = require("src.widgets.audio")(s)
s.date = require("src.widgets.date")()
s.clock = require("src.widgets.clock")()
s.layoutlist = require("src.widgets.layout_list")()
s.powerbutton = require("src.widgets.power")()
s.kblayout = require("src.widgets.kblayout")(s)
s.taglist = require("src.widgets.taglist")(s)
s.tasklist = require("src.widgets.tasklist")(s)
-- s.battery = require("src.widgets.battery")()
-- s.bluetooth = require("src.widgets.bluetooth")()
-- s.cpu_freq = require("src.widgets.cpu_info")("freq", "average")
-- s.systray = require("src.widgets.systray")(s)
-- s.cpu_usage = require("src.widgets.cpu_info")("usage")
-- s.cpu_temp = require("src.widgets.cpu_info")("temp")
-- s.gpu_usage = require("src.widgets.gpu_info")("usage")
-- s.gpu_temp = require("src.widgets.gpu_info")("temp")
-- s.network = require("src.widgets.network")()
-- s.ram_info = require("src.widgets.ram_info")()
if s.index == 1 then
s.systray = require("src.widgets.systray")(s)
s.cpu_usage = require("src.widgets.cpu_info")("usage")
s.cpu_temp = require("src.widgets.cpu_info")("temp")
s.gpu_usage = require("src.widgets.gpu_info")("usage")
s.gpu_temp = require("src.widgets.gpu_info")("temp")
require("src.modules.crylia_bar.left_bar")(s, { s.layoutlist, s.systray, s.taglist })
require("src.modules.crylia_bar.center_bar")(s, { s.tasklist })
require("src.modules.crylia_bar.right_bar")(s, { s.gpu_usage, s.gpu_temp, s.cpu_usage, s.cpu_temp, s.audio, s.kblayout, s.date, s.clock, s.powerbutton })
require("src.modules.crylia_bar.dock")(s, user_vars.dock_programs)
---Lookup function to return the widget from its easy name string
---@param widgets table
---@return widget
local function get_widgets(widgets)
local widget_table = {}
if widgets then
for _, widget in ipairs(widgets) do
if widget == "Audio" then
table.insert(widget_table, require("src.widgets.audio")(s))
elseif widget == "Battery" then
table.insert(widget_table, require("src.widgets.battery")(User_config.battery_path))
elseif widget == "Bluetooth" then
table.insert(widget_table, require("src.widgets.bluetooth")())
elseif widget == "Clock" then
table.insert(widget_table, require("src.widgets.clock")())
elseif widget == "Cpu Frequency" then
table.insert(widget_table, require("src.widgets.cpu_info")("freq", User_config.cpu_frequency))
elseif widget == "Cpu Temperature" then
table.insert(widget_table, require("src.widgets.cpu_info")("temp"))
elseif widget == "Cpu Usage" then
table.insert(widget_table, require("src.widgets.cpu_info")("usage"))
elseif widget == "Date" then
table.insert(widget_table, require("src.widgets.date")())
elseif widget == "Gpu Temperature" then
table.insert(widget_table, require("src.widgets.gpu_info")("temp"))
elseif widget == "Gpu Usage" then
table.insert(widget_table, require("src.widgets.gpu_info")("usage"))
elseif widget == "Keyboard Layout" then
table.insert(widget_table, require("src.widgets.kblayout")(s))
elseif widget == "Tiling Layout" then
table.insert(widget_table, require("src.widgets.layout_list")())
elseif widget == "Network" then
table.insert(widget_table, require("src.widgets.network")())
elseif widget == "Power Button" then
table.insert(widget_table, require("src.widgets.power")())
elseif widget == "Ram Usage" then
table.insert(widget_table, require("src.widgets.ram_info")())
elseif widget == "Systray" then
table.insert(widget_table, require("src.widgets.systray")(s))
elseif widget == "Taglist" then
table.insert(widget_table, require("src.widgets.taglist")(s))
elseif widget == "Tasklist" then
table.insert(widget_table, require("src.widgets.tasklist")(s))
end
end
end
return widget_table
end
if s.index == 2 then
s.network = require("src.widgets.network")()
s.ram_info = require("src.widgets.ram_info")()
require("src.modules.crylia_bar.left_bar")(s, { s.layoutlist, s.taglist })
require("src.modules.crylia_bar.center_bar")(s, { s.tasklist })
require("src.modules.crylia_bar.right_bar")(s, { s.ram_info, s.audio, s.kblayout, s.network, s.date, s.clock, s.powerbutton })
if User_config.widgets then
for index, screen in ipairs(User_config.widgets) do
if index == s.index then
if screen.left_bar then
require("src.modules.crylia_bar.left_bar")(s, get_widgets(screen.left_bar))
end
if screen.center_bar then
require("src.modules.crylia_bar.center_bar")(s, get_widgets(screen.center_bar))
end
if screen.right_bar then
require("src.modules.crylia_bar.right_bar")(s, get_widgets(screen.right_bar))
end
end
end
end
require("src.modules.crylia_bar.dock")(s, User_config.dock_programs)
end

View File

@@ -8,18 +8,20 @@ local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
return function(s, widgets)
return function(s, w)
local top_left = awful.popup {
screen = s,
widget = wibox.container.background,
widget = {
},
ontop = false,
bg = color["Grey900"],
visible = true,
maximum_width = dpi(650),
placement = function(c) awful.placement.top_left(c, { margins = dpi(10) }) end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end
}
@@ -29,47 +31,47 @@ return function(s, widgets)
local function prepare_widgets(widgets)
local layout = {
forced_height = 45,
forced_height = dpi(50),
layout = wibox.layout.fixed.horizontal
}
for i, widget in pairs(widgets) do
if i == 1 then
table.insert(layout,
{
widget,
left = dpi(6),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
widget,
left = dpi(6),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
elseif i == #widgets then
table.insert(layout,
{
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
else
table.insert(layout,
{
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
end
end
return layout
end
top_left:setup {
prepare_widgets(widgets),
prepare_widgets(w),
nil,
nil,
layout = wibox.layout.fixed.horizontal

View File

@@ -8,7 +8,7 @@ local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
return function(s, widgets)
return function(s, w)
local top_right = awful.popup {
widget = wibox.container.background,
@@ -18,7 +18,7 @@ return function(s, widgets)
screen = s,
placement = function(c) awful.placement.top_right(c, { margins = dpi(10) }) end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 5)
gears.shape.rounded_rect(cr, width, height, dpi(6))
end
}
@@ -28,40 +28,40 @@ return function(s, widgets)
local function prepare_widgets(widgets)
local layout = {
forced_height = 45,
forced_height = dpi(50),
layout = wibox.layout.fixed.horizontal
}
for i, widget in pairs(widgets) do
if i == 1 then
table.insert(layout,
{
widget,
left = dpi(6),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
widget,
left = dpi(6),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
elseif i == #widgets then
table.insert(layout,
{
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
else
table.insert(layout,
{
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin
})
end
end
return layout
@@ -70,7 +70,7 @@ return function(s, widgets)
top_right:setup {
nil,
nil,
prepare_widgets(widgets),
prepare_widgets(w),
layout = wibox.layout.align.horizontal
}
end