a lot of stuff
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
-- This is the audio widget --
|
||||
------------------------------
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
@@ -61,50 +61,39 @@ return function(s)
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
capi.awesome.connect_signal(
|
||||
"audio::get",
|
||||
function(muted, volume)
|
||||
if muted then
|
||||
audio_widget.container.audio_layout.label.visible = false
|
||||
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(
|
||||
gears.color.recolor_image(icondir .. "volume-mute" .. ".svg", Theme_config.audio.fg))
|
||||
else
|
||||
audio_widget.container:set_right(10)
|
||||
local icon = icondir .. "volume"
|
||||
audio_widget.container.audio_layout.spacing = dpi(5)
|
||||
audio_widget.container.audio_layout.label.visible = true
|
||||
volume = tonumber(volume)
|
||||
if not volume then
|
||||
return
|
||||
end
|
||||
if volume < 1 then
|
||||
icon = icon .. "-mute"
|
||||
audio_widget.container.audio_layout.spacing = dpi(0)
|
||||
audio_widget.container.audio_layout.label.visible = false
|
||||
elseif volume >= 1 and volume < 34 then
|
||||
icon = icon .. "-low"
|
||||
elseif volume >= 34 and volume < 67 then
|
||||
icon = icon .. "-medium"
|
||||
elseif volume >= 67 then
|
||||
icon = icon .. "-high"
|
||||
end
|
||||
audio_widget.container.audio_layout.label:set_text(volume .. "%")
|
||||
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(
|
||||
gears.color.recolor_image(icon .. ".svg", Theme_config.audio.fg))
|
||||
capi.awesome.connect_signal("audio::get", function(muted, volume)
|
||||
if muted then
|
||||
audio_widget.container.audio_layout.label.visible = false
|
||||
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(
|
||||
gears.color.recolor_image(icondir .. "volume-mute" .. ".svg", Theme_config.audio.fg))
|
||||
else
|
||||
audio_widget.container:set_right(10)
|
||||
local icon = icondir .. "volume"
|
||||
audio_widget.container.audio_layout.spacing = dpi(5)
|
||||
audio_widget.container.audio_layout.label.visible = true
|
||||
volume = tonumber(volume)
|
||||
if not volume then
|
||||
return
|
||||
end
|
||||
if volume < 1 then
|
||||
icon = icon .. "-mute"
|
||||
audio_widget.container.audio_layout.spacing = dpi(0)
|
||||
audio_widget.container.audio_layout.label.visible = false
|
||||
elseif volume >= 1 and volume < 34 then
|
||||
icon = icon .. "-low"
|
||||
elseif volume >= 34 and volume < 67 then
|
||||
icon = icon .. "-medium"
|
||||
elseif volume >= 67 then
|
||||
icon = icon .. "-high"
|
||||
end
|
||||
audio_widget.container.audio_layout.label:set_text(volume .. "%")
|
||||
audio_widget.container.audio_layout.icon_margin.icon_layout.icon:set_image(
|
||||
gears.color.recolor_image(icon .. ".svg", Theme_config.audio.fg))
|
||||
end
|
||||
)
|
||||
end)
|
||||
|
||||
-- Signals
|
||||
Hover_signal(audio_widget)
|
||||
|
||||
audio_widget:connect_signal(
|
||||
"button::press",
|
||||
function()
|
||||
capi.awesome.emit_signal("volume_controller::toggle", s)
|
||||
capi.awesome.emit_signal("volume_controller::toggle:keygrabber")
|
||||
end
|
||||
)
|
||||
|
||||
return audio_widget
|
||||
end
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
---------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
@@ -13,7 +12,7 @@ local rubato = require("src.lib.rubato")
|
||||
|
||||
require("src.tools.helpers.cpu_freq")
|
||||
require("src.tools.helpers.cpu_temp")
|
||||
--!Has to be disabled until rewritten to perform better require("src.tools.helpers.cpu_usage")
|
||||
require("src.tools.helpers.cpu_usage")
|
||||
|
||||
local capi = {
|
||||
awesome = awesome,
|
||||
@@ -22,7 +21,7 @@ local capi = {
|
||||
local icon_dir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/cpu/"
|
||||
|
||||
--TODO: Add tooltip with more CPU and per core information
|
||||
return function(widget, _)
|
||||
return function(widget)
|
||||
|
||||
local cpu_usage_widget = wibox.widget {
|
||||
{
|
||||
@@ -153,12 +152,9 @@ return function(widget, _)
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
capi.awesome.connect_signal(
|
||||
"update::cpu_usage",
|
||||
function(usage)
|
||||
cpu_usage_widget.container.cpu_layout.label.text = usage .. "%"
|
||||
end
|
||||
)
|
||||
capi.awesome.connect_signal("update::cpu_usage", function(usage)
|
||||
cpu_usage_widget.container.cpu_layout.label.text = usage .. "%"
|
||||
end)
|
||||
|
||||
local r_timed_cpu_bg = rubato.timed { duration = 2.5 }
|
||||
local g_timed_cpu_bg = rubato.timed { duration = 2.5 }
|
||||
@@ -180,42 +176,33 @@ return function(widget, _)
|
||||
r_timed_cpu_bg.target, g_timed_cpu_bg.target, b_timed_cpu_bg.target = color.utils.hex_to_rgba(newbg)
|
||||
end
|
||||
|
||||
capi.awesome.connect_signal(
|
||||
"update::cpu_temp",
|
||||
function(temp)
|
||||
local temp_icon
|
||||
local temp_color
|
||||
capi.awesome.connect_signal("update::cpu_temp", function(temp)
|
||||
local temp_icon
|
||||
local temp_color
|
||||
|
||||
if temp < 50 then
|
||||
temp_color = Theme_config.cpu_temp.bg_low
|
||||
temp_icon = icon_dir .. "thermometer-low.svg"
|
||||
elseif temp >= 50 and temp < 80 then
|
||||
temp_color = Theme_config.cpu_temp.bg_mid
|
||||
temp_icon = icon_dir .. "thermometer.svg"
|
||||
elseif temp >= 80 then
|
||||
temp_color = Theme_config.cpu_temp.bg_high
|
||||
temp_icon = icon_dir .. "thermometer-high.svg"
|
||||
end
|
||||
cpu_temp.container.cpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon)
|
||||
set_bg(temp_color)
|
||||
cpu_temp.container.cpu_layout.label.text = math.floor(temp) .. "°C"
|
||||
capi.awesome.emit_signal("update::cpu_temp_widget", temp, temp_icon)
|
||||
if temp < 50 then
|
||||
temp_color = Theme_config.cpu_temp.bg_low
|
||||
temp_icon = icon_dir .. "thermometer-low.svg"
|
||||
elseif temp >= 50 and temp < 80 then
|
||||
temp_color = Theme_config.cpu_temp.bg_mid
|
||||
temp_icon = icon_dir .. "thermometer.svg"
|
||||
elseif temp >= 80 then
|
||||
temp_color = Theme_config.cpu_temp.bg_high
|
||||
temp_icon = icon_dir .. "thermometer-high.svg"
|
||||
end
|
||||
)
|
||||
cpu_temp.container.cpu_layout.icon_margin.icon_layout.icon:set_image(temp_icon)
|
||||
set_bg(temp_color)
|
||||
cpu_temp.container.cpu_layout.label.text = math.floor(temp) .. "°C"
|
||||
capi.awesome.emit_signal("update::cpu_temp_widget", temp, temp_icon)
|
||||
end)
|
||||
|
||||
capi.awesome.connect_signal(
|
||||
"update::cpu_freq_average",
|
||||
function(average)
|
||||
cpu_clock.container.cpu_layout.label.text = average .. "Mhz"
|
||||
end
|
||||
)
|
||||
capi.awesome.connect_signal("update::cpu_freq_average", function(average)
|
||||
cpu_clock.container.cpu_layout.label.text = average .. "Mhz"
|
||||
end)
|
||||
|
||||
capi.awesome.connect_signal(
|
||||
"update::cpu_freq_core",
|
||||
function(freq)
|
||||
cpu_clock.container.cpu_layout.label.text = freq .. "Mhz"
|
||||
end
|
||||
)
|
||||
capi.awesome.connect_signal("update::cpu_freq_core", function(freq)
|
||||
cpu_clock.container.cpu_layout.label.text = freq .. "Mhz"
|
||||
end)
|
||||
|
||||
Hover_signal(cpu_temp)
|
||||
Hover_signal(cpu_usage_widget)
|
||||
|
||||
@@ -3,25 +3,32 @@
|
||||
----------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local abutton = require("awful.button")
|
||||
local alayout = require("awful.layout")
|
||||
local awidget = require("awful.widget")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local gtable = require("gears.table")
|
||||
local wibox = require("wibox")
|
||||
|
||||
--#region Layout icons
|
||||
local layout_path = Theme_path .. "../assets/layout/"
|
||||
|
||||
Theme.layout_floating = layout_path .. "floating.svg"
|
||||
Theme.layout_tile = layout_path .. "tile.svg"
|
||||
Theme.layout_dwindle = layout_path .. "dwindle.svg"
|
||||
Theme.layout_fairh = layout_path .. "fairh.svg"
|
||||
Theme.layout_fairv = layout_path .. "fairv.svg"
|
||||
Theme.layout_fullscreen = layout_path .. "fullscreen.svg"
|
||||
Theme.layout_max = layout_path .. "max.svg"
|
||||
Theme.layout_cornerne = layout_path .. "cornerne.svg"
|
||||
Theme.layout_cornernw = layout_path .. "cornernw.svg"
|
||||
Theme.layout_cornerse = layout_path .. "cornerse.svg"
|
||||
Theme.layout_cornersw = layout_path .. "cornersw.svg"
|
||||
Theme.layout_cornerne = layout_path .. "cornerne.png"
|
||||
Theme.layout_cornernw = layout_path .. "cornernw.png"
|
||||
Theme.layout_cornerse = layout_path .. "cornerse.png"
|
||||
Theme.layout_cornersw = layout_path .. "cornersw.png"
|
||||
Theme.layout_dwindle = layout_path .. "dwindle.png"
|
||||
Theme.layout_fairh = layout_path .. "fairh.png"
|
||||
Theme.layout_fairv = layout_path .. "fairv.png"
|
||||
Theme.layout_floating = layout_path .. "floating.png"
|
||||
Theme.layout_fullscreen = layout_path .. "fullscreen.png"
|
||||
Theme.layout_magnifier = layout_path .. "magnifier.png"
|
||||
Theme.layout_max = layout_path .. "max.png"
|
||||
Theme.layout_spiral = layout_path .. "spiral.png"
|
||||
Theme.layout_tile = layout_path .. "tile.png"
|
||||
Theme.layout_tilebottom = layout_path .. "tilebottom.png"
|
||||
Theme.layout_tileleft = layout_path .. "tileleft.png"
|
||||
Theme.layout_tiletop = layout_path .. "tiletop.png"
|
||||
--#endregion
|
||||
|
||||
-- Returns the layoutbox widget
|
||||
@@ -29,32 +36,40 @@ return function()
|
||||
local layout = wibox.widget {
|
||||
{
|
||||
{
|
||||
awful.widget.layoutbox(),
|
||||
id = "icon_layout",
|
||||
widget = wibox.container.place
|
||||
{
|
||||
awidget.layoutbox(),
|
||||
widget = wibox.container.place,
|
||||
halign = "center",
|
||||
valign = "center"
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
id = "icon_margin",
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
forced_width = dpi(40),
|
||||
widget = wibox.container.margin
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(40)
|
||||
},
|
||||
bg = Theme_config.layout_list.bg,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(6))
|
||||
end,
|
||||
shape = Theme_config.layout_list.shape,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
-- Signals
|
||||
Hover_signal(layout)
|
||||
|
||||
layout:connect_signal(
|
||||
"button::press",
|
||||
function()
|
||||
awful.layout.inc(-1)
|
||||
end
|
||||
)
|
||||
layout:buttons(gtable.join(
|
||||
abutton({}, 1, function()
|
||||
alayout.inc(1)
|
||||
end),
|
||||
abutton({}, 3, function()
|
||||
alayout.inc(-1)
|
||||
end),
|
||||
abutton({}, 4, function()
|
||||
alayout.inc(1)
|
||||
end),
|
||||
abutton({}, 5, function()
|
||||
alayout.inc(-1)
|
||||
end)
|
||||
))
|
||||
|
||||
return layout
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user