fix some bugs in the icon lookup

This commit is contained in:
Crylia
2022-08-25 01:55:28 +02:00
parent fa656cd5f3
commit 3d743c6be0
14 changed files with 625 additions and 35 deletions

View File

@@ -3,7 +3,6 @@
--------------------------------------------------------------------------------------------------------------
-- Awesome Libs
local awful = require("awful")
local async = require("async")
local dpi = require("beautiful").xresources.apply_dpi
local Gio = require("lgi").Gio
local gears = require("gears")
@@ -26,7 +25,7 @@ return function(screen)
---@param size number The size of the widget
---@return widox.widget | nil The widget or nil if the program is not found
local function create_dock_element(program, size)
if not program then return end
local dock_element = wibox.widget {
{
{
@@ -165,13 +164,15 @@ return function(screen)
end
local prog = json:decode(data:read("a"))
if (not prog) or prog == "" then return end
for _, pr in ipairs(prog) do
local indicators = { layout = wibox.layout.flex.horizontal, spacing = dpi(5) }
local col = Theme_config.dock.indicator_bg
for _, c in ipairs(client.get()) do
local icon_name = pr.icon
if icon_name:match(string.lower(c.class or c.name)) or c.class:match(string.lower(icon_name)) or
c.name:match(string.lower(icon_name)) then
if not c.class then return end
if icon_name:match(string.lower(c.class)) or c.class:match(string.lower(icon_name)) or
(string.lower(c.name) == string.lower(icon_name)) or c.name:match(string.lower(icon_name)) then
if c == client.focus then
col = Theme_config.dock.indicator_focused_bg
elseif c.urgent then
@@ -252,6 +253,9 @@ return function(screen)
return
end
local dock_data = json:decode(data:read("a"))
if (not dock_data) or dock_data == "" then
return
end
for _, program in ipairs(dock_data) do
table.insert(dock_elements, create_dock_element(program, User_config.dock_icon_size))
end

View File

@@ -0,0 +1,130 @@
------------------------------------
-- This is the network controller --
------------------------------------
-- Awesome Libs
local awful = require("awful")
local dpi = require("beautiful").xresources.apply_dpi
local gears = require("gears")
local wibox = require("wibox")
local rubato = require("src.lib.rubato")
local icondir = awful.util.getdir("config") .. "src/assets/icons/network/"
return function(s)
local function get_connected_network()
end
local network_controller = wibox.widget {
{
{
{ -- Connected
{ --Connected header
{
{
text = "Connected to",
widget = wibox.widget.textbox
},
widget = wibox.container.background
},
widget = wibox.container.margin
},
{ -- Connected network
{
get_connected_network(),
widget = wibox.container.background
},
widget = wibox.container.margin
},
layout = wibox.layout.fixed.vertical
},
{ -- Discovered networks
{ --Discovered header
{
{
text = "Available networks",
widget = wibox.widget.textbox
},
widget = wibox.container.background
},
widget = wibox.container.margin
},
{ -- Discovered networks list
},
spacing = dpi(10),
layout = wibox.layout.fixed.vertical
},
{ -- Airplanemode/Refresh buttons
{ -- Airplane mode toggle
{
{
{
-- TODO: Replace with image
text = "Airplane mode",
widget = wibox.widgeet.textbox
},
widget = wibox.container.margin
},
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(5))
end,
widget = wibox.container.background
},
widget = wibox.container.margin
},
{ -- Refresh button
{
{
{
-- TODO: Replace with image
text = "Refresh",
widget = wibox.widgeet.textbox
},
widget = wibox.container.margin
},
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(5))
end,
widget = wibox.container.background
},
widget = wibox.container.margin
},
layout = wibox.layout.align.horizontal
},
layout = wibox.layout.fixed.vertical
},
margins = dpi(10),
widget = wibox.container.margin
},
width = dpi(400),
strategy = "exact",
widget = wibox.container.constraint
}
local network_controller_container = awful.popup {
widget = wibox.container.background,
bg = Theme_config.network_controller.bg,
border_color = Theme_config.network_controller.border_color,
border_width = Theme_config.network_controller.border_width,
screen = s,
stretch = false,
visible = false,
ontop = true,
placement = function(c) awful.placement.align(c,
{ position = "top_right", margins = { right = dpi(350), top = dpi(60) } })
end,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, dpi(12))
end
}
network_controller_container:setup {
network_controller,
layout = wibox.layout.fixed.vertical
}
end

View File

@@ -649,12 +649,20 @@ return function()
}
awesome.connect_signal(
"update::backlight",
function(backlight, backlight_icon)
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(backlight_icon,
"brightness::get",
function(brightness)
local icon = icondir .. "brightness/brightness"
if brightness >= 0 and brightness < 34 then
icon = icon .. "-low"
elseif brightness >= 34 and brightness < 67 then
icon = icon .. "-medium"
elseif brightness >= 67 then
icon = icon .. "-high"
end
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(icon .. ".svg",
Theme_config.notification_center.status_bar.backlight_color)
tooltip.text = "Backlight: " .. backlight .. "%"
rubato_timer.target = backlight
tooltip.text = "Backlight: " .. brightness .. "%"
rubato_timer.target = brightness
end
)
elseif widget == "battery" then