Reworked a whole lot. New config file and theme config file for easier changes. Did #19. And much more
This commit is contained in:
@@ -9,7 +9,6 @@ local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local watch = awful.widget.watch
|
||||
local wibox = require("wibox")
|
||||
require("src.core.signals")
|
||||
|
||||
local icon_dir = awful.util.getdir("config") .. "src/assets/icons/cpu/"
|
||||
|
||||
@@ -22,7 +21,53 @@ return function(widget)
|
||||
{
|
||||
id = "icon",
|
||||
widget = wibox.widget.imagebox,
|
||||
image = gears.color.recolor_image(icon_dir .. "gpu.svg", color["Grey900"]),
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
image = gears.color.recolor_image(icon_dir .. "gpu.svg", Theme_config.gpu_usage.fg),
|
||||
resize = false
|
||||
},
|
||||
id = "icon_layout",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
top = dpi(2),
|
||||
widget = wibox.container.margin,
|
||||
id = "icon_margin"
|
||||
},
|
||||
spacing = dpi(10),
|
||||
{
|
||||
id = "label",
|
||||
align = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
id = "gpu_layout",
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
id = "container",
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = Theme_config.gpu_usage.bg,
|
||||
fg = Theme_config.gpu_usage.fg,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(6))
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
Hover_signal(gpu_usage_widget, Theme_config.gpu_usage.bg, Theme_config.gpu_usage.fg)
|
||||
|
||||
local gpu_temp_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
id = "icon",
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
image = gears.color.recolor_image(icon_dir .. "cpu.svg", Theme_config.gpu_temp.fg),
|
||||
resize = false
|
||||
},
|
||||
id = "icon_layout",
|
||||
@@ -48,51 +93,9 @@ return function(widget)
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = color["Green200"],
|
||||
fg = color["Grey900"],
|
||||
fg = Theme_config.gpu_temp.fg,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
Hover_signal(gpu_usage_widget, color["Green200"], color["Grey900"])
|
||||
|
||||
local gpu_temp_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
id = "icon",
|
||||
widget = wibox.widget.imagebox,
|
||||
image = gears.color.recolor_image(icon_dir .. "cpu.svg", color["Grey900"]),
|
||||
resize = false
|
||||
},
|
||||
id = "icon_layout",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
top = dpi(2),
|
||||
widget = wibox.container.margin,
|
||||
id = "icon_margin"
|
||||
},
|
||||
spacing = dpi(10),
|
||||
{
|
||||
id = "label",
|
||||
align = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
id = "gpu_layout",
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
id = "container",
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = color["Blue200"],
|
||||
fg = color["Grey900"],
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(6))
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
@@ -117,22 +120,29 @@ return function(widget)
|
||||
local temp_color
|
||||
local temp_num = tonumber(stdout)
|
||||
|
||||
if temp_num < 50 then
|
||||
if temp_num then
|
||||
|
||||
if temp_num < 50 then
|
||||
temp_color = color["Green200"]
|
||||
temp_icon = icon_dir .. "thermometer-low.svg"
|
||||
elseif temp_num >= 50 and temp_num < 80 then
|
||||
temp_color = color["Orange200"]
|
||||
temp_icon = icon_dir .. "thermometer.svg"
|
||||
elseif temp_num >= 80 then
|
||||
temp_color = color["Red200"]
|
||||
temp_icon = icon_dir .. "thermometer-high.svg"
|
||||
end
|
||||
else
|
||||
temp_num = "NaN"
|
||||
temp_color = color["Green200"]
|
||||
temp_icon = icon_dir .. "thermometer-low.svg"
|
||||
elseif temp_num >= 50 and temp_num < 80 then
|
||||
temp_color = color["Orange200"]
|
||||
temp_icon = icon_dir .. "thermometer.svg"
|
||||
elseif temp_num >= 80 then
|
||||
temp_color = color["Red200"]
|
||||
temp_icon = icon_dir .. "thermometer-high.svg"
|
||||
end
|
||||
|
||||
Hover_signal(gpu_temp_widget, temp_color, color["Grey900"])
|
||||
Hover_signal(gpu_temp_widget, temp_color, Theme_config.gpu_temp.fg)
|
||||
gpu_temp_widget.container.gpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon)
|
||||
gpu_temp_widget:set_bg(temp_color)
|
||||
gpu_temp_widget.container.gpu_layout.label.text = tostring(temp_num) .. "°C"
|
||||
awesome.emit_signal("update::gpu_temp_widget", temp_num, temp_icon)
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user