Big rewrite part 1

This commit is contained in:
Rene Kievits
2023-04-20 01:04:06 +02:00
parent 61930bf561
commit 3a85753a74
78 changed files with 3364 additions and 4090 deletions

View File

@@ -1,10 +1,11 @@
--------------------------------------------------------------------------------------------------------------
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
--------------------------------------------------------------------------------------------------------------
local tinsert = table.insert
local pairs = pairs
-- Awesome Libs
local aplacement = require('awful.placement')
local apopup = require('awful.popup')
local dpi = require('beautiful').xresources.apply_dpi
local beautiful = require('beautiful')
local dpi = beautiful.xresources.apply_dpi
local wibox = require('wibox')
local capi = {
@@ -12,93 +13,99 @@ local capi = {
client = client,
}
return function(s, widgets)
local function prepare_widgets(w)
local layout = {
forced_height = dpi(50),
layout = wibox.layout.fixed.horizontal,
}
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 == #w then
table.insert(layout,
{
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,
})
end
local function prepare_widgets(w)
local layout = {
layout = wibox.layout.fixed.horizontal,
}
for i, widget in pairs(w) do
if i == 1 then
tinsert(layout,
{
widget,
left = dpi(6),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin,
})
elseif i == #w then
tinsert(layout,
{
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin,
})
else
tinsert(layout,
{
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin,
})
end
return layout
end
local top_center = apopup {
screen = s,
widget = prepare_widgets(widgets),
ontop = false,
bg = Theme_config.center_bar.bg,
visible = true,
maximum_width = dpi(500),
placement = function(c) aplacement.top(c, { margins = dpi(10) }) end,
}
top_center:struts {
top = dpi(55),
}
capi.client.connect_signal('manage', function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end)
capi.client.connect_signal('unmanage', function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end)
capi.client.connect_signal('property::selected', function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end)
capi.awesome.connect_signal('refresh', function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end)
return layout
end
return setmetatable({}, {
__call = function(_, s, widgets)
local top_center = apopup {
screen = s,
widget = {
prepare_widgets(widgets),
widget = wibox.container.constraint,
strategy = 'exact',
height = dpi(50),
},
ontop = false,
bg = beautiful.colorscheme.bg,
visible = true,
maximum_width = dpi(500),
placement = function(c) aplacement.top(c, { margins = dpi(10) }) end,
}
top_center:struts {
top = dpi(60),
}
capi.client.connect_signal('manage', function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end)
capi.client.connect_signal('unmanage', function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end)
capi.client.connect_signal('property::selected', function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end)
capi.awesome.connect_signal('refresh', function(c)
if #s.selected_tag:clients() < 1 then
top_center.visible = false
else
top_center.visible = true
end
end)
end,
})

View File

@@ -1,25 +1,28 @@
--------------------------------------------------------------------------------------------------------------
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
--------------------------------------------------------------------------------------------------------------
local setmetatable = setmetatable
local table = table
local ipairs = ipairs
local pairs = pairs
-- Awesome Libs
local lgi = require('lgi')
local Gio = lgi.Gio
local abutton = require('awful.button')
local aplacement = require('awful.placement')
local apopup = require('awful.popup')
local awidget = require('awful.widget')
local beautiful = require('beautiful')
local dpi = require('beautiful').xresources.apply_dpi
local gcolor = require('gears.color')
local gfilesystem = require('gears.filesystem')
local gtable = require('gears.table')
local wibox = require('wibox')
local gcolor = require('gears.color')
local awidget = require('awful.widget')
local aplacement = require('awful.placement')
local gtimer = require('gears.timer')
local amenu = require('awful.menu')
local lgi = require('lgi')
local Gio = lgi.Gio
local wibox = require('wibox')
-- Local libs
local config = require('src.tools.config')
local context_menu = require('src.modules.context_menu.init')
local context_menu = require('src.modules.context_menu')
local hover = require('src.tools.hover')
local icon_lookup = require('src.tools.gio_icon_lookup')()
local capi = {
awesome = awesome,
@@ -102,8 +105,8 @@ function dock:get_element_widget(desktop_file)
local GDesktopAppInfo = Gio.DesktopAppInfo.new_from_filename(desktop_file)
local icon = Get_gicon_path(nil, GDesktopAppInfo.get_string(GDesktopAppInfo, 'Icon')) or
Get_gicon_path(nil, Gio.DesktopAppInfo.get_string(GDesktopAppInfo, 'X-AppImage-Old-Icon')) or ''
local icon = icon_lookup:get_gicon_path(nil, GDesktopAppInfo.get_string(GDesktopAppInfo, 'Icon')) or
icon_lookup:get_gicon_path(nil, Gio.DesktopAppInfo.get_string(GDesktopAppInfo, 'X-AppImage-Old-Icon')) or ''
local widget = wibox.widget {
{
@@ -118,19 +121,19 @@ function dock:get_element_widget(desktop_file)
id = 'icon_role',
},
widget = wibox.container.constraint,
width = User_config.dock_icon_size,
height = User_config.dock_icon_size,
width = beautiful.user_config.dock_icon_size,
height = beautiful.user_config.dock_icon_size,
},
widget = wibox.container.margin,
margins = dpi(5),
},
widget = wibox.container.constraint,
width = User_config.dock_icon_size + dpi(10), -- + margins
height = User_config.dock_icon_size + dpi(10),
width = beautiful.user_config.dock_icon_size + dpi(10), -- + margins
height = beautiful.user_config.dock_icon_size + dpi(10),
strategy = 'exact',
},
bg = Theme_config.dock.element.bg,
shape = Theme_config.dock.element.shape,
bg = beautiful.colorscheme.bg1,
shape = beautiful.shape[8],
widget = wibox.container.background,
}
@@ -138,9 +141,9 @@ function dock:get_element_widget(desktop_file)
for _, action in ipairs(Gio.DesktopAppInfo.list_actions(GDesktopAppInfo)) do
table.insert(action_entries, {
name = Gio.DesktopAppInfo.get_action_name(GDesktopAppInfo, action) or '',
icon = Get_gicon_path(nil, GDesktopAppInfo.get_string(GDesktopAppInfo, 'Icon')) or
Get_gicon_path(nil, Gio.DesktopAppInfo.get_string(GDesktopAppInfo, 'X-AppImage-Old-Icon')) or
gcolor.recolor_image(icondir .. 'entry.svg', Theme_config.dock.cm_icon),
icon = icon_lookup:get_gicon_path(nil, GDesktopAppInfo.get_string(GDesktopAppInfo, 'Icon')) or
icon_lookup:get_gicon_path(nil, Gio.DesktopAppInfo.get_string(GDesktopAppInfo, 'X-AppImage-Old-Icon')) or
gcolor.recolor_image(icondir .. 'entry.svg', beautiful.colorscheme.bg_yellow),
callback = function()
Gio.DesktopAppInfo.launch_action(GDesktopAppInfo, action)
end,
@@ -149,7 +152,7 @@ function dock:get_element_widget(desktop_file)
table.insert(action_entries, {
name = 'Remove from Dock',
icon = gcolor.recolor_image(icondir .. 'context_menu/entry.svg', Theme_config.dock.cm_icon),
icon = gcolor.recolor_image(icondir .. 'context_menu/entry.svg', beautiful.colorscheme.bg_yellow),
callback = function()
local data = config.read_json(gfilesystem.get_configuration_dir() .. 'src/config/dock_' .. self.screen.index .. '.json')
for i, v in ipairs(data) do
@@ -243,11 +246,8 @@ end
---@param args {desktop_file: string} The path to the .desktop file
function dock:pin_element(args)
if not args then return end
local e = args.desktop_file
assert(e, 'No desktop file provided')
self:emit_signal('dock::pin_element', e)
self:write_elements_to_file_async()
@@ -267,19 +267,19 @@ function dock:add_start_element()
id = 'icon_role',
},
widget = wibox.container.constraint,
width = User_config.dock_icon_size,
height = User_config.dock_icon_size,
width = beautiful.user_config.dock_icon_size,
height = beautiful.user_config.dock_icon_size,
},
widget = wibox.container.margin,
margins = dpi(5),
},
widget = wibox.container.constraint,
width = User_config.dock_icon_size + dpi(10), -- + margins
height = User_config.dock_icon_size + dpi(10),
width = beautiful.user_config.dock_icon_size + dpi(10), -- + margins
height = beautiful.user_config.dock_icon_size + dpi(10),
strategy = 'exact',
},
bg = Theme_config.dock.element.bg,
shape = Theme_config.dock.element.shape,
bg = beautiful.colorscheme.bg1,
shape = beautiful.shape[8],
widget = wibox.container.background,
}
@@ -297,9 +297,6 @@ function dock:add_start_element()
return widget
end
---Unpins an element from the dock by removing it from the pinned table, then writes the table to the file
---emits the signal `dock::unpin_element` then successfully removed from the table
---@param args {desktop_file: string} The path to the .desktop file
function dock:unpin_element(args)
if not args then return end
@@ -367,7 +364,7 @@ local function check_for_dock_hide(self, a_popup)
minimized = false
local y = c:geometry().y
local h = c.height
if (y + h) >= self.screen.geometry.height - User_config.dock_icon_size - 35 then
if (y + h) >= self.screen.geometry.height - beautiful.user_config.dock_icon_size - 35 then
self.visible = false
return
else
@@ -451,7 +448,7 @@ function dock.new(args)
forced_width = dpi(2),
forced_height = dpi(20),
thickness = dpi(2),
color = Theme_config.dock.element.border,
color = beautiful.colorscheme.border_color,
},
{
spacing = dpi(5),
@@ -473,7 +470,7 @@ function dock.new(args)
ontop = true,
visible = true,
placement = function(c) aplacement.bottom(c, { margins = dpi(10) }) end,
bg = Theme_config.dock.bg,
bg = beautiful.colorscheme.bg,
screen = args.screen,
}
@@ -500,7 +497,7 @@ function dock.new(args)
forced_height = dpi(20),
forced_width = dpi(2),
thickness = dpi(2),
color = Theme_config.dock.element.border,
color = beautiful.colorscheme.border_color,
},
widget = wibox.container.margin,
right = dpi(5),
@@ -520,19 +517,19 @@ function dock.new(args)
id = 'icon_role',
},
widget = wibox.container.constraint,
width = User_config.dock_icon_size,
height = User_config.dock_icon_size,
width = beautiful.user_config.dock_icon_size,
height = beautiful.user_config.dock_icon_size,
},
widget = wibox.container.margin,
margins = dpi(5),
},
widget = wibox.container.constraint,
width = User_config.dock_icon_size + dpi(10), -- + margins
height = User_config.dock_icon_size + dpi(10),
width = beautiful.user_config.dock_icon_size + dpi(10), -- + margins
height = beautiful.user_config.dock_icon_size + dpi(10),
strategy = 'exact',
},
bg = Theme_config.dock.element.bg,
shape = Theme_config.dock.element.shape,
bg = beautiful.colorscheme.bg1,
shape = beautiful.shape[8],
widget = wibox.container.background,
}
@@ -543,15 +540,19 @@ function dock.new(args)
}
element:buttons(gtable.join(
abutton({}, 1, function(c)
if c == client.focus then
c.minimized = true
abutton({}, 1, function()
if client == client.focus then
client.minimized = true
else
c:emit_signal('request::activate', 'tasklist', { raise = true })
if client.first_tag then
client.first_tag:view_only()
end
client:emit_signal('request::activate')
client:raise()
end
end),
abutton({}, 3, function()
amenu.client_list { theme = { width = dpi(250) } }
--TODO: Add context menu with options
end)
))

View File

@@ -1,71 +1,71 @@
--------------------------------------------------------------------------------------------------------------
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
--------------------------------------------------------------------------------------------------------------
local tinsert = table.insert
local ipairs = ipairs
return function(s)
---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_kind))
elseif widget == 'Bluetooth' then
table.insert(widget_table, require('src.widgets.bluetooth')(s))
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'))
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')(s))
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') { screen = s })
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')())
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))
local beautiful = require('beautiful')
return setmetatable({}, {
__call = function(_, s)
local function get_widgets(widgets)
local widget_table = {}
if widgets then
for _, widget in ipairs(widgets) do
if widget == 'Audio' then
tinsert(widget_table, require('src.widgets.audio')(s))
elseif widget == 'Battery' then
tinsert(widget_table, require('src.widgets.battery')(beautiful.user_config.battery_kind))
elseif widget == 'Bluetooth' then
tinsert(widget_table, require('src.widgets.bluetooth')(s))
elseif widget == 'Clock' then
tinsert(widget_table, require('src.widgets.clock') {})
elseif widget == 'Cpu Frequency' then
tinsert(widget_table, require('src.widgets.cpu_info')('freq'))
elseif widget == 'Cpu Temperature' then
tinsert(widget_table, require('src.widgets.cpu_info')('temp'))
elseif widget == 'Cpu Usage' then
tinsert(widget_table, require('src.widgets.cpu_info')('usage'))
elseif widget == 'Date' then
tinsert(widget_table, require('src.widgets.date')(s))
elseif widget == 'Gpu Temperature' then
tinsert(widget_table, require('src.widgets.gpu_info')('temp'))
elseif widget == 'Gpu Usage' then
tinsert(widget_table, require('src.widgets.gpu_info')('usage'))
elseif widget == 'Keyboard Layout' then
tinsert(widget_table, require('src.widgets.kblayout')(s))
elseif widget == 'Tiling Layout' then
tinsert(widget_table, require('src.widgets.layout_list')(s))
elseif widget == 'Network' then
tinsert(widget_table, require('src.widgets.network')(s))
elseif widget == 'Power Button' then
tinsert(widget_table, require('src.widgets.power') {})
elseif widget == 'Ram Usage' then
tinsert(widget_table, require('src.widgets.ram_info') {})
elseif widget == 'Systray' then
tinsert(widget_table, require('src.widgets.systray') {})
elseif widget == 'Taglist' then
tinsert(widget_table, require('src.widgets.taglist')(s))
elseif widget == 'Tasklist' then
tinsert(widget_table, require('src.widgets.tasklist')(s))
end
end
end
return widget_table
end
if beautiful.user_config.crylia_bar then
for index, screen in ipairs(beautiful.user_config.crylia_bar) 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
return widget_table
end
if User_config.crylia_bar then
for index, screen in ipairs(User_config.crylia_bar) 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') { screen = s }
end
require('src.modules.crylia_bar.dock') { screen = s }
end,
})

View File

@@ -1,66 +1,72 @@
--------------------------------------------------------------------------------------------------------------
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
--------------------------------------------------------------------------------------------------------------
local tinsert = table.insert
local pairs = pairs
-- Awesome Libs
local awful = require('awful')
local aplacement = require('awful.placement')
local apopup = require('awful.popup')
local beautiful = require('beautiful')
local dpi = require('beautiful').xresources.apply_dpi
local wibox = require('wibox')
return function(s, w)
local function prepare_widgets(widgets)
local layout = {
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,
})
elseif i == #widgets then
table.insert(layout,
{
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,
})
end
end
return layout
end
local top_left = awful.popup {
screen = s,
widget = prepare_widgets(w),
ontop = false,
bg = Theme_config.left_bar.bg,
visible = true,
maximum_width = dpi(650),
placement = function(c) awful.placement.top_left(c, { margins = dpi(10) }) end,
}
top_left:struts {
top = dpi(55),
local function prepare_widgets(w)
local layout = {
layout = wibox.layout.fixed.horizontal,
}
Global_config.top_struts = dpi(55)
for i, widget in pairs(w) do
if i == 1 then
tinsert(layout,
{
widget,
left = dpi(6),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin,
})
elseif i == #w then
tinsert(layout,
{
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin,
})
else
tinsert(layout,
{
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin,
})
end
end
return layout
end
return setmetatable({}, {
__call = function(_, s, w)
local top_left = apopup {
screen = s,
widget = {
prepare_widgets(w),
widget = wibox.container.constraint,
strategy = 'exact',
height = dpi(50),
},
ontop = false,
bg = beautiful.colorscheme.bg,
visible = true,
maximum_width = dpi(850),
placement = function(c) aplacement.top_left(c, { margins = dpi(10) }) end,
}
top_left:struts {
top = dpi(60),
}
end,
})

View File

@@ -1,65 +1,72 @@
--------------------------------------------------------------------------------------------------------------
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
--------------------------------------------------------------------------------------------------------------
local tinsert = table.insert
local pairs = pairs
-- Awesome Libs
local awful = require('awful')
local dpi = require('beautiful').xresources.apply_dpi
local aplacement = require('awful.placement')
local apopup = require('awful.popup')
local beautiful = require('beautiful')
local dpi = beautiful.xresources.apply_dpi
local wibox = require('wibox')
return function(s, w)
local function prepare_widgets(widgets)
local layout = {
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,
})
elseif i == #widgets then
table.insert(layout,
{
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,
})
end
local function prepare_widgets(w)
local layout = {
layout = wibox.layout.fixed.horizontal,
}
for i, widget in pairs(w) do
if i == 1 then
tinsert(layout,
{
widget,
left = dpi(6),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin,
})
elseif i == #w then
tinsert(layout,
{
widget,
left = dpi(3),
right = dpi(6),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin,
})
else
tinsert(layout,
{
widget,
left = dpi(3),
right = dpi(3),
top = dpi(6),
bottom = dpi(6),
widget = wibox.container.margin,
})
end
return layout
end
local top_right = awful.popup {
widget = prepare_widgets(w),
ontop = false,
bg = Theme_config.right_bar.bg,
visible = true,
screen = s,
placement = function(c) awful.placement.top_right(c, { margins = dpi(10) }) end,
}
top_right:struts {
top = dpi(55),
}
Global_config.top_struts = top_right
return layout
end
return setmetatable({}, {
__call = function(_, s, w)
local top_right = apopup {
widget = {
prepare_widgets(w),
widget = wibox.container.constraint,
strategy = 'exact',
height = dpi(50),
},
ontop = false,
bg = beautiful.colorscheme.bg,
visible = true,
screen = s,
placement = function(c) aplacement.top_right(c, { margins = dpi(10) }) end,
}
top_right:struts {
top = dpi(60),
}
end,
})