Big rewrite part 1
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
------------------------------
|
||||
-- This is the audio widget --
|
||||
------------------------------
|
||||
local setmetatable = setmetatable
|
||||
local tonumber = tonumber
|
||||
|
||||
-- Awesome Libs
|
||||
local abutton = require('awful.button')
|
||||
local apopup = require('awful.popup')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gtable = require('gears.table')
|
||||
local gtimer = require('gears.timer')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Local libs
|
||||
@@ -25,13 +27,17 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
local ac_popup = apopup {
|
||||
widget = audio_controller,
|
||||
ontop = true,
|
||||
visible = false,
|
||||
visible = true,
|
||||
screen = screen,
|
||||
border_color = Theme_config.bluetooth_controller.container_border_color,
|
||||
border_width = Theme_config.bluetooth_controller.container_border_width,
|
||||
bg = Theme_config.bluetooth_controller.container_bg,
|
||||
border_color = beautiful.colorscheme.border_color,
|
||||
border_width = dpi(2),
|
||||
bg = beautiful.colorscheme.bg,
|
||||
}
|
||||
|
||||
gtimer.delayed_call(function()
|
||||
ac_popup.visible = false
|
||||
end)
|
||||
|
||||
local w = wibox.widget {
|
||||
{
|
||||
{
|
||||
@@ -63,14 +69,14 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.audio.bg,
|
||||
fg = Theme_config.audio.fg,
|
||||
shape = Theme_config.audio.shape,
|
||||
bg = beautiful.colorscheme.bg_yellow,
|
||||
fg = beautiful.colorscheme.fg_dark,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
buttons = { gtable.join(
|
||||
abutton({}, 1, function()
|
||||
local geo = capi.mouse.coords()
|
||||
ac_popup.y = dpi(65)
|
||||
ac_popup.y = dpi(70)
|
||||
ac_popup.x = geo.x - ac_popup.width / 2
|
||||
ac_popup.visible = not ac_popup.visible
|
||||
end)
|
||||
@@ -84,7 +90,6 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
local audio_spacing = w:get_children_by_id('audio_layout')[1]
|
||||
audio_helper:connect_signal('sink::get', function(_, muted, volume)
|
||||
volume = tonumber(volume)
|
||||
assert(type(volume) == 'number' and type(muted) == 'boolean', 'Invalid arguments')
|
||||
|
||||
if w.volume == volume and w.muted == muted then return end
|
||||
w.volume = volume
|
||||
@@ -92,7 +97,7 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
|
||||
if muted then
|
||||
audio_label.visible = false
|
||||
audio_icon:set_image(gcolor.recolor_image(icondir .. 'volume-mute' .. '.svg', Theme_config.audio.fg))
|
||||
audio_icon:set_image(gcolor.recolor_image(icondir .. 'volume-mute' .. '.svg', beautiful.colorscheme.fg_dark))
|
||||
else
|
||||
if not volume then return end
|
||||
w.container:set_right(10)
|
||||
@@ -111,7 +116,7 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
icon = icon .. '-high'
|
||||
end
|
||||
audio_label:set_text(volume .. '%')
|
||||
audio_icon:set_image(gcolor.recolor_image(icon .. '.svg', Theme_config.audio.fg))
|
||||
audio_icon:set_image(gcolor.recolor_image(icon .. '.svg', beautiful.colorscheme.fg_dark))
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
--------------------------------
|
||||
-- This is the battery widget --
|
||||
--------------------------------
|
||||
local ipairs = ipairs
|
||||
local mfloor = math.floor
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require('awful')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local gears = require('gears')
|
||||
local aspawn = require('awful.spawn')
|
||||
local atooltip = require('awful.tooltip')
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gsurface = require('gears.surface')
|
||||
local gtimer = require('gears.timer')
|
||||
local lgi = require('lgi')
|
||||
local naughty = require('naughty')
|
||||
local nnotification = require('naughty.notification')
|
||||
local upower_glib = lgi.require('UPowerGlib')
|
||||
local wibox = require('wibox')
|
||||
|
||||
@@ -19,228 +24,205 @@ local capi = {
|
||||
}
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = gears.filesystem.get_configuration_dir() .. 'src/assets/icons/battery/'
|
||||
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/battery/'
|
||||
|
||||
---Returns the battery widget
|
||||
---@return wibox.widget
|
||||
return function(battery_kind)
|
||||
|
||||
-- Battery wibox.widget
|
||||
local battery_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
local instance = nil
|
||||
if not instance then
|
||||
instance = setmetatable({}, {
|
||||
__call = function(_, battery_kind)
|
||||
local battery_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'icon',
|
||||
image = gears.color.recolor_image(icondir .. 'battery-unknown.svg', Theme_config.battery.fg),
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
resize = false,
|
||||
{
|
||||
{
|
||||
id = 'icon',
|
||||
image = gcolor.recolor_image(icondir .. 'battery-unknown.svg', beautiful.colorscheme.fg_dark),
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
resize = false,
|
||||
},
|
||||
id = 'icon_layout',
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
id = 'icon_margin',
|
||||
top = dpi(2),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
id = 'icon_layout',
|
||||
widget = wibox.container.place,
|
||||
spacing = dpi(10),
|
||||
{
|
||||
visible = false,
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
id = 'label',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
id = 'battery_layout',
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
id = 'icon_margin',
|
||||
top = dpi(2),
|
||||
id = 'container',
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
spacing = dpi(10),
|
||||
{
|
||||
visible = false,
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
id = 'label',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
id = 'battery_layout',
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
id = 'container',
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.battery.bg,
|
||||
fg = Theme_config.battery.fg,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(6))
|
||||
bg = beautiful.colorscheme.bg_purple,
|
||||
fg = beautiful.colorscheme.fg_dark,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
hover.bg_hover { widget = battery_widget }
|
||||
|
||||
battery_widget:connect_signal('button::press', function()
|
||||
aspawn(beautiful.user_config.energy_manager)
|
||||
end)
|
||||
|
||||
local function get_device_path()
|
||||
local paths = upower_glib.Client():get_devices()
|
||||
local path_table = {}
|
||||
for _, path in ipairs(paths) do
|
||||
table.insert(path_table, path:get_object_path())
|
||||
end
|
||||
return path_table
|
||||
end
|
||||
|
||||
local function get_device_from_path(path)
|
||||
local devices = upower_glib.Client():get_devices()
|
||||
|
||||
for _, device in ipairs(devices) do
|
||||
if device:get_object_path() == path then
|
||||
return device
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local tooltip = atooltip {
|
||||
objects = { battery_widget },
|
||||
mode = 'inside',
|
||||
preferred_alignments = 'middle',
|
||||
margins = dpi(10),
|
||||
}
|
||||
|
||||
---Sets the battery information for the widget
|
||||
---@param device UPowerGlib.Device battery
|
||||
local function set_battery(device)
|
||||
local battery_percentage = mfloor(device.percentage + 0.5)
|
||||
local battery_status = upower_glib.DeviceState[device.state]:lower()
|
||||
local battery_temp = device.temperature
|
||||
|
||||
local battery_time = 1
|
||||
|
||||
if device.time_to_empty ~= 0 then
|
||||
battery_time = device.time_to_empty
|
||||
else
|
||||
battery_time = device.time_to_full
|
||||
end
|
||||
|
||||
local battery_string = mfloor(battery_time / 3600) .. 'h, ' .. mfloor((battery_time / 60) % 60) .. 'm'
|
||||
|
||||
if battery_temp == 0.0 then
|
||||
battery_temp = 'NaN'
|
||||
else
|
||||
battery_temp = mfloor(battery_temp + 0.5) .. '°C'
|
||||
end
|
||||
|
||||
if not battery_percentage then
|
||||
return
|
||||
end
|
||||
|
||||
battery_widget:get_children_by_id('battery_layout')[1].spacing = dpi(5)
|
||||
battery_widget:get_children_by_id('label')[1].visible = true
|
||||
battery_widget:get_children_by_id('label')[1].text = battery_percentage .. '%'
|
||||
|
||||
tooltip.markup = "<span foreground='" .. beautiful.colorscheme.bg_teal .. "'>Battery Status:</span> <span foreground='" .. beautiful.colorscheme.fg .. "'>"
|
||||
.. battery_status .. "</span>\n<span foreground='" .. beautiful.colorscheme.bg_teal .. "'>Remaining time:</span> <span foreground='" .. beautiful.colorscheme.fg .. "'>"
|
||||
.. battery_string .. "</span>\n<span foreground='" .. beautiful.colorscheme.bg_teal .. "'>Temperature:</span> <span foreground='" .. beautiful.colorscheme.fg .. "'>"
|
||||
.. battery_temp .. '</span>'
|
||||
|
||||
local icon = 'battery'
|
||||
|
||||
if battery_status == 'fully-charged' or battery_status == 'charging' and battery_percentage == 100 then
|
||||
icon = icon .. '-' .. 'charging.svg'
|
||||
nnotification {
|
||||
title = 'Battery notification',
|
||||
message = 'Battery is fully charged',
|
||||
icon = icondir .. icon,
|
||||
timeout = 5,
|
||||
}
|
||||
battery_widget:get_children_by_id('icon')[1].image = gsurface.load_uncached(gcolor.recolor_image(icondir
|
||||
.. icon, beautiful.colorscheme.fg_dark))
|
||||
return
|
||||
elseif battery_percentage > 0 and battery_percentage < 10 and battery_status == 'discharging' then
|
||||
icon = icon .. '-' .. 'alert.svg'
|
||||
nnotification {
|
||||
title = 'Battery warning',
|
||||
message = 'Battery is running low!\n' .. battery_percentage .. '% left',
|
||||
urgency = 'critical',
|
||||
icon = icondir .. icon,
|
||||
timeout = 60,
|
||||
}
|
||||
battery_widget:get_children_by_id('icon')[1].image = gsurface.load_uncached(gcolor.recolor_image(icondir
|
||||
.. icon, beautiful.colorscheme.fg_dark))
|
||||
return
|
||||
end
|
||||
|
||||
if battery_percentage > 0 and battery_percentage < 10 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. 'outline'
|
||||
elseif battery_percentage >= 10 and battery_percentage < 20 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '10'
|
||||
elseif battery_percentage >= 20 and battery_percentage < 30 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '20'
|
||||
elseif battery_percentage >= 30 and battery_percentage < 40 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '30'
|
||||
elseif battery_percentage >= 40 and battery_percentage < 50 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '40'
|
||||
elseif battery_percentage >= 50 and battery_percentage < 60 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '50'
|
||||
elseif battery_percentage >= 60 and battery_percentage < 70 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '60'
|
||||
elseif battery_percentage >= 70 and battery_percentage < 80 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '70'
|
||||
elseif battery_percentage >= 80 and battery_percentage < 90 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '80'
|
||||
elseif battery_percentage >= 90 and battery_percentage < 100 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '90'
|
||||
end
|
||||
|
||||
battery_widget:get_children_by_id('icon')[1].image = gsurface.load_uncached(gcolor.recolor_image(icondir ..
|
||||
icon .. '.svg', beautiful.colorscheme.fg_dark))
|
||||
capi.awesome.emit_signal('update::battery_widget', battery_percentage, icondir .. icon .. '.svg')
|
||||
end
|
||||
|
||||
local function attach_to_device(path)
|
||||
local device_path = beautiful.user_config.battery_path or path or ''
|
||||
|
||||
battery_widget.device = get_device_from_path(device_path) or upower_glib.Client():get_display_device()
|
||||
|
||||
battery_widget.device.on_notify = function(device)
|
||||
battery_widget:emit_signal('upower::update', device)
|
||||
end
|
||||
|
||||
if upower_glib.DeviceKind[battery_widget.device.kind] == battery_kind then
|
||||
set_battery(battery_widget.device)
|
||||
end
|
||||
|
||||
gtimer.delayed_call(battery_widget.emit_signal, battery_widget, 'upower::update', battery_widget.device)
|
||||
end
|
||||
|
||||
for _, device in ipairs(get_device_path()) do
|
||||
attach_to_device(device)
|
||||
end
|
||||
|
||||
battery_widget:connect_signal('upower::update', function(_, device)
|
||||
if upower_glib.DeviceKind[battery_widget.device.kind] == battery_kind then
|
||||
set_battery(device)
|
||||
end
|
||||
end)
|
||||
|
||||
return battery_widget
|
||||
end,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
-- Color change on mouse over
|
||||
hover.bg_hover { widget = battery_widget }
|
||||
|
||||
-- Open an energy manager on click
|
||||
battery_widget:connect_signal(
|
||||
'button::press',
|
||||
function()
|
||||
awful.spawn(User_config.energy_manager)
|
||||
end
|
||||
)
|
||||
|
||||
---Gets every enery device path
|
||||
---@return table string battery device paths
|
||||
local function get_device_path()
|
||||
local paths = upower_glib.Client():get_devices()
|
||||
local path_table = {}
|
||||
for _, path in ipairs(paths) do
|
||||
table.insert(path_table, path:get_object_path())
|
||||
end
|
||||
return path_table
|
||||
end
|
||||
|
||||
---Takes a path and returns the glib object
|
||||
---@param path string battery device path
|
||||
---@return UPowerGlib.Device | nil battery battery device object
|
||||
local function get_device_from_path(path)
|
||||
local devices = upower_glib.Client():get_devices()
|
||||
|
||||
for _, device in ipairs(devices) do
|
||||
if device:get_object_path() == path then
|
||||
return device
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local tooltip = awful.tooltip {
|
||||
objects = { battery_widget },
|
||||
mode = 'inside',
|
||||
preferred_alignments = 'middle',
|
||||
margins = dpi(10),
|
||||
}
|
||||
|
||||
---Sets the battery information for the widget
|
||||
---@param device UPowerGlib.Device battery
|
||||
local function set_battery(device)
|
||||
local battery_percentage = math.floor(device.percentage + 0.5)
|
||||
local battery_status = upower_glib.DeviceState[device.state]:lower()
|
||||
local battery_temp = device.temperature
|
||||
|
||||
local battery_time = 1
|
||||
|
||||
if device.time_to_empty ~= 0 then
|
||||
battery_time = device.time_to_empty
|
||||
else
|
||||
battery_time = device.time_to_full
|
||||
end
|
||||
|
||||
local battery_string = math.floor(battery_time / 3600) .. 'h, ' .. math.floor((battery_time / 60) % 60) .. 'm'
|
||||
|
||||
if battery_temp == 0.0 then
|
||||
battery_temp = 'NaN'
|
||||
else
|
||||
battery_temp = math.floor(battery_temp + 0.5) .. '°C'
|
||||
end
|
||||
|
||||
if not battery_percentage then
|
||||
return
|
||||
end
|
||||
|
||||
battery_widget:get_children_by_id('battery_layout')[1].spacing = dpi(5)
|
||||
battery_widget:get_children_by_id('label')[1].visible = true
|
||||
battery_widget:get_children_by_id('label')[1].text = battery_percentage .. '%'
|
||||
|
||||
tooltip.markup = "<span foreground='#64ffda'>Battery Status:</span> <span foreground='#90caf9'>"
|
||||
.. battery_status .. "</span>\n<span foreground='#64ffda'>Remaining time:</span> <span foreground='#90caf9'>"
|
||||
.. battery_string .. "</span>\n<span foreground='#64ffda'>Temperature:</span> <span foreground='#90caf9'>"
|
||||
.. battery_temp .. '</span>'
|
||||
|
||||
local icon = 'battery'
|
||||
|
||||
if battery_status == 'fully-charged' or battery_status == 'charging' and battery_percentage == 100 then
|
||||
icon = icon .. '-' .. 'charging.svg'
|
||||
naughty.notification {
|
||||
title = 'Battery notification',
|
||||
message = 'Battery is fully charged',
|
||||
icon = icondir .. icon,
|
||||
timeout = 5,
|
||||
}
|
||||
battery_widget:get_children_by_id('icon')[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir
|
||||
.. icon, Theme_config.battery.fg))
|
||||
return
|
||||
elseif battery_percentage > 0 and battery_percentage < 10 and battery_status == 'discharging' then
|
||||
icon = icon .. '-' .. 'alert.svg'
|
||||
naughty.notification {
|
||||
title = 'Battery warning',
|
||||
message = 'Battery is running low!\n' .. battery_percentage .. '% left',
|
||||
urgency = 'critical',
|
||||
icon = icondir .. icon,
|
||||
timeout = 60,
|
||||
}
|
||||
battery_widget:get_children_by_id('icon')[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir
|
||||
.. icon, Theme_config.battery.fg))
|
||||
return
|
||||
end
|
||||
|
||||
if battery_percentage > 0 and battery_percentage < 10 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. 'outline'
|
||||
elseif battery_percentage >= 10 and battery_percentage < 20 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '10'
|
||||
elseif battery_percentage >= 20 and battery_percentage < 30 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '20'
|
||||
elseif battery_percentage >= 30 and battery_percentage < 40 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '30'
|
||||
elseif battery_percentage >= 40 and battery_percentage < 50 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '40'
|
||||
elseif battery_percentage >= 50 and battery_percentage < 60 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '50'
|
||||
elseif battery_percentage >= 60 and battery_percentage < 70 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '60'
|
||||
elseif battery_percentage >= 70 and battery_percentage < 80 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '70'
|
||||
elseif battery_percentage >= 80 and battery_percentage < 90 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '80'
|
||||
elseif battery_percentage >= 90 and battery_percentage < 100 then
|
||||
icon = icon .. '-' .. battery_status .. '-' .. '90'
|
||||
end
|
||||
|
||||
battery_widget:get_children_by_id('icon')[1].image = gears.surface.load_uncached(gears.color.recolor_image(icondir ..
|
||||
icon .. '.svg', Theme_config.battery.fg))
|
||||
capi.awesome.emit_signal('update::battery_widget', battery_percentage, icondir .. icon .. '.svg')
|
||||
|
||||
end
|
||||
|
||||
---This function attaches a device path to the dbus interface
|
||||
---It will only display on a widget if the user specified a device kind
|
||||
---This device will then be filtered out and sent information to the widget itself
|
||||
---The rest will only report in the background to other widgets e.g. Bluetooth devices
|
||||
---Will report to the bluetooth widget.
|
||||
---@param path string device path /org/freedesktop/...
|
||||
local function attach_to_device(path)
|
||||
local device_path = User_config.battery_path or path or ''
|
||||
|
||||
battery_widget.device = get_device_from_path(device_path) or upower_glib.Client():get_display_device()
|
||||
|
||||
battery_widget.device.on_notify = function(device)
|
||||
battery_widget:emit_signal('upower::update', device)
|
||||
end
|
||||
|
||||
-- Check which device kind the user wants to display
|
||||
-- If there are multiple then the first is used
|
||||
if upower_glib.DeviceKind[battery_widget.device.kind] == battery_kind then
|
||||
set_battery(battery_widget.device)
|
||||
end
|
||||
|
||||
-- The delayed call will fire every time awesome finishes its main event loop
|
||||
gears.timer.delayed_call(battery_widget.emit_signal, battery_widget, 'upower::update', battery_widget.device)
|
||||
end
|
||||
|
||||
for _, device in ipairs(get_device_path()) do
|
||||
attach_to_device(device)
|
||||
end
|
||||
|
||||
battery_widget:connect_signal(
|
||||
'upower::update',
|
||||
function(_, device)
|
||||
if upower_glib.DeviceKind[battery_widget.device.kind] == battery_kind then
|
||||
set_battery(device)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
return battery_widget
|
||||
})
|
||||
end
|
||||
return instance
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
----------------------------------
|
||||
-- This is the bluetooth widget --
|
||||
----------------------------------
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome libs
|
||||
local awful = require('awful')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local gears = require('gears')
|
||||
local apopup = require('awful.popup')
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gtimer = require('gears.timer')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Own libs
|
||||
local bt_module = require('src.modules.bluetooth.init')
|
||||
local bt_module = require('src.modules.bluetooth')
|
||||
local hover = require('src.tools.hover')
|
||||
|
||||
local capi = {
|
||||
@@ -18,78 +19,75 @@ local capi = {
|
||||
}
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = gears.filesystem.get_configuration_dir() .. 'src/assets/icons/bluetooth/'
|
||||
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/bluetooth/'
|
||||
|
||||
-- Returns the bluetooth widget
|
||||
return function(s)
|
||||
|
||||
-- Get the bluetooth module
|
||||
local bt_widget = bt_module { screen = s }
|
||||
-- Create the bluetooth widget
|
||||
local bluetooth_widget = wibox.widget {
|
||||
{
|
||||
return setmetatable({}, {
|
||||
__call = function(_, s)
|
||||
-- Get the bluetooth module
|
||||
local bt_widget = bt_module { screen = s }
|
||||
-- Create the bluetooth widget
|
||||
local bluetooth_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
id = 'icon',
|
||||
image = gears.color.recolor_image(icondir .. 'bluetooth-off.svg', Theme_config.bluetooth.fg),
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
resize = false,
|
||||
{
|
||||
id = 'icon',
|
||||
image = gcolor.recolor_image(icondir .. 'bluetooth-off.svg', beautiful.colorscheme.bg),
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
resize = false,
|
||||
},
|
||||
id = 'icon_layout',
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
id = 'icon_layout',
|
||||
widget = wibox.container.place,
|
||||
id = 'icon_margin',
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
id = 'icon_margin',
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.bluetooth.bg,
|
||||
fg = Theme_config.bluetooth.fg,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(6))
|
||||
end,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
bg = beautiful.colorscheme.bg_blue,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
hover.bg_hover { widget = bluetooth_widget }
|
||||
hover.bg_hover { widget = bluetooth_widget }
|
||||
|
||||
-- Create the awful.popup container for the module
|
||||
local bluetooth_container = apopup {
|
||||
widget = bt_widget,
|
||||
ontop = true,
|
||||
stretch = false,
|
||||
visible = true,
|
||||
screen = s,
|
||||
border_color = beautiful.colorscheme.border_color,
|
||||
border_width = dpi(2),
|
||||
bg = beautiful.colorscheme.bg,
|
||||
}
|
||||
|
||||
gtimer.delayed_call(function()
|
||||
bluetooth_container.visible = false
|
||||
end)
|
||||
|
||||
-- When the status changes update the icon
|
||||
bt_widget:connect_signal('bluetooth::status', function(status)
|
||||
bluetooth_widget:get_children_by_id('icon')[1].image = gcolor.recolor_image(status._private.Adapter1.Powered and
|
||||
icondir .. 'bluetooth-on.svg' or icondir .. 'bluetooth-off.svg', beautiful.colorscheme.bg)
|
||||
end)
|
||||
|
||||
-- On left click toggle the bluetooth container else toggle the bluetooth on/off
|
||||
bluetooth_widget:connect_signal('button::press', function(_, _, _, key)
|
||||
if key == 1 then
|
||||
local geo = capi.mouse.current_wibox:geometry()
|
||||
bluetooth_container.x = capi.mouse.coords().x - (bluetooth_container:geometry().width / 2)
|
||||
bluetooth_container.y = dpi(70)
|
||||
bluetooth_container.visible = not bluetooth_container.visible
|
||||
else
|
||||
capi.awesome.emit_signal('toggle_bluetooth')
|
||||
end
|
||||
end)
|
||||
|
||||
-- If bt_widget is nil then there is no bluetooth adapter and there shouldn't be done
|
||||
-- anything besides returning the widget without any logic behind
|
||||
if not bt_widget then
|
||||
return bluetooth_widget
|
||||
end
|
||||
|
||||
-- Create the awful.popup container for the module
|
||||
local bluetooth_container = awful.popup {
|
||||
widget = bt_widget,
|
||||
ontop = true,
|
||||
stretch = false,
|
||||
visible = false,
|
||||
screen = s,
|
||||
border_color = Theme_config.bluetooth_controller.container_border_color,
|
||||
border_width = Theme_config.bluetooth_controller.container_border_width,
|
||||
bg = Theme_config.bluetooth_controller.container_bg,
|
||||
}
|
||||
|
||||
-- When the status changes update the icon
|
||||
bt_widget:connect_signal('bluetooth::status', function(status)
|
||||
bluetooth_widget:get_children_by_id('icon')[1].image = gears.color.recolor_image(status._private.Adapter1.Powered and
|
||||
icondir .. 'bluetooth-on.svg' or icondir .. 'bluetooth-off.svg', Theme_config.bluetooth.fg)
|
||||
end)
|
||||
|
||||
-- On left click toggle the bluetooth container else toggle the bluetooth on/off
|
||||
bluetooth_widget:connect_signal('button::press', function(_, _, _, key)
|
||||
if key == 1 then
|
||||
local geo = capi.mouse.current_wibox:geometry()
|
||||
bluetooth_container.x = geo.x
|
||||
bluetooth_container.y = geo.y + dpi(55)
|
||||
bluetooth_container.visible = not bluetooth_container.visible
|
||||
else
|
||||
capi.awesome.emit_signal('toggle_bluetooth')
|
||||
end
|
||||
end)
|
||||
|
||||
return bluetooth_widget
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
------------------------------
|
||||
-- This is the clock widget --
|
||||
------------------------------
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome Libs
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local wibox = require('wibox')
|
||||
@@ -15,43 +14,47 @@ local hover = require('src.tools.hover')
|
||||
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/clock/'
|
||||
|
||||
-- Returns the clock widget
|
||||
return setmetatable({}, { __call = function()
|
||||
local clock_widget = wibox.widget {
|
||||
{
|
||||
local instance = nil
|
||||
if not instance then
|
||||
instance = setmetatable({}, { __call = function()
|
||||
local clock_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
image = gcolor.recolor_image(icondir .. 'clock.svg', Theme_config.clock.fg),
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
resize = true,
|
||||
{
|
||||
image = gcolor.recolor_image(icondir .. 'clock.svg', beautiful.colorscheme.bg),
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
resize = true,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
{
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
format = '%H:%M',
|
||||
widget = wibox.widget.textclock,
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
{
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
format = '%H:%M',
|
||||
widget = wibox.widget.textclock,
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.clock.bg,
|
||||
fg = Theme_config.clock.fg,
|
||||
shape = Theme_config.clock.shape,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
bg = beautiful.colorscheme.bg_yellow,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
hover.bg_hover { widget = clock_widget }
|
||||
hover.bg_hover { widget = clock_widget }
|
||||
|
||||
return clock_widget
|
||||
end, })
|
||||
return clock_widget
|
||||
end, })
|
||||
end
|
||||
return instance
|
||||
|
||||
@@ -1,236 +1,211 @@
|
||||
---------------------------------
|
||||
-- This is the CPU Info widget --
|
||||
---------------------------------
|
||||
local mfloor = math.floor
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome Libs
|
||||
local base = require('wibox.widget.base')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gtable = require('gears.table')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Third Party Libs
|
||||
local color = require('src.lib.color')
|
||||
local rubato = require('src.lib.rubato')
|
||||
local hover = require('src.tools.hover')
|
||||
local rubato = require('src.lib.rubato')
|
||||
|
||||
local icon_dir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/cpu/'
|
||||
|
||||
local cpu_info = {}
|
||||
local instance = nil
|
||||
if not instance then
|
||||
instance = setmetatable({}, { __call = function(_, widget)
|
||||
if widget == 'temp' then
|
||||
local cpu_temp_helper = require('src.tools.helpers.cpu_temp')
|
||||
|
||||
local function cpu_temp_new()
|
||||
local cpu_temp_helper = require('src.tools.helpers.cpu_temp')
|
||||
|
||||
local w = base.make_widget_from_value(wibox.widget {
|
||||
{
|
||||
{
|
||||
local w = base.make_widget_from_value(wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'thermometer.svg', Theme_config.cpu_temp.fg),
|
||||
resize = true,
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'thermometer.svg', beautiful.colorscheme.bg),
|
||||
resize = true,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
},
|
||||
{
|
||||
id = 'text_role',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
{
|
||||
id = 'text_role',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.cpu_temp.bg,
|
||||
fg = Theme_config.cpu_temp.fg,
|
||||
shape = Theme_config.cpu_temp.shape,
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
bg = beautiful.colorscheme.bg_green,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
|
||||
assert(w, 'Failed to create widget')
|
||||
local r = rubato.timed { duration = 2.5 }
|
||||
local g = rubato.timed { duration = 2.5 }
|
||||
local b = rubato.timed { duration = 2.5 }
|
||||
|
||||
gtable.crush(w, cpu_info, true)
|
||||
r.pos, g.pos, b.pos = color.utils.hex_to_rgba(beautiful.colorscheme.bg_green)
|
||||
|
||||
local r = rubato.timed { duration = 2.5 }
|
||||
local g = rubato.timed { duration = 2.5 }
|
||||
local b = rubato.timed { duration = 2.5 }
|
||||
-- Subscribable function to have rubato set the bg/fg color
|
||||
local function update_bg()
|
||||
w:set_bg('#' .. color.utils.rgba_to_hex { r.pos, g.pos, b.pos })
|
||||
end
|
||||
|
||||
r.pos, g.pos, b.pos = color.utils.hex_to_rgba(Theme_config.cpu_temp.bg_low)
|
||||
r:subscribe(update_bg)
|
||||
g:subscribe(update_bg)
|
||||
b:subscribe(update_bg)
|
||||
|
||||
-- Subscribable function to have rubato set the bg/fg color
|
||||
local function update_bg()
|
||||
w:set_bg('#' .. color.utils.rgba_to_hex { r.pos, g.pos, b.pos })
|
||||
end
|
||||
-- Both functions to set a color, if called they take a new color
|
||||
local function set_bg(newbg)
|
||||
r.target, g.target, b.target = color.utils.hex_to_rgba(newbg)
|
||||
end
|
||||
|
||||
r:subscribe(update_bg)
|
||||
g:subscribe(update_bg)
|
||||
b:subscribe(update_bg)
|
||||
cpu_temp_helper:connect_signal('update::cpu_temp', function(_, temp)
|
||||
local temp_icon
|
||||
local temp_color
|
||||
|
||||
-- Both functions to set a color, if called they take a new color
|
||||
local function set_bg(newbg)
|
||||
r.target, g.target, b.target = color.utils.hex_to_rgba(newbg)
|
||||
end
|
||||
if temp < 50 then
|
||||
temp_color = beautiful.colorscheme.bg_green
|
||||
temp_icon = icon_dir .. 'thermometer-low.svg'
|
||||
elseif temp >= 50 and temp < 80 then
|
||||
temp_color = beautiful.colorscheme.bg_yellow
|
||||
temp_icon = icon_dir .. 'thermometer.svg'
|
||||
elseif temp >= 80 then
|
||||
temp_color = beautiful.colorscheme.bg_red
|
||||
temp_icon = icon_dir .. 'thermometer-high.svg'
|
||||
end
|
||||
w:get_children_by_id('icon_role')[1].image = temp_icon
|
||||
set_bg(temp_color)
|
||||
w:get_children_by_id('text_role')[1].text = mfloor(temp) .. '°C'
|
||||
end)
|
||||
|
||||
cpu_temp_helper:connect_signal('update::cpu_temp', function(_, temp)
|
||||
local temp_icon
|
||||
local temp_color
|
||||
return w
|
||||
elseif widget == 'usage' then
|
||||
local cpu_usage_helper = require('src.tools.helpers.cpu_usage')
|
||||
|
||||
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'
|
||||
local w = base.make_widget_from_value(wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'cpu.svg', beautiful.colorscheme.bg),
|
||||
resize = true,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
},
|
||||
{
|
||||
id = 'text_role',
|
||||
text = '0%',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = beautiful.colorscheme.bg_blue,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
|
||||
hover.bg_hover { widget = w }
|
||||
|
||||
cpu_usage_helper:connect_signal('update::cpu_usage', function(_, usage)
|
||||
w:get_children_by_id('text_role')[1].text = usage .. '%'
|
||||
end)
|
||||
|
||||
return w
|
||||
elseif widget == 'freq' then
|
||||
local cpu_freq_helper = require('src.tools.helpers.cpu_freq')
|
||||
|
||||
local w = base.make_widget_from_value(wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'cpu.svg', beautiful.colorscheme.bg),
|
||||
resize = true,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
},
|
||||
{
|
||||
id = 'text_role',
|
||||
text = '0Mhz',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = beautiful.colorscheme.bg_blue,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
|
||||
hover.bg_hover { widget = w }
|
||||
|
||||
cpu_freq_helper:connect_signal('update::cpu_freq_average', function(_, average)
|
||||
w:get_children_by_id('text_role')[1].text = average .. 'Mhz'
|
||||
end)
|
||||
|
||||
cpu_freq_helper:connect_signal('update::cpu_freq_core', function(_, freq)
|
||||
w:get_children_by_id('text_role')[1].text = freq .. 'Mhz'
|
||||
end)
|
||||
|
||||
return w
|
||||
end
|
||||
w:get_children_by_id('icon_role')[1].image = temp_icon
|
||||
set_bg(temp_color)
|
||||
w:get_children_by_id('text_role')[1].text = math.floor(temp) .. '°C'
|
||||
end)
|
||||
|
||||
return w
|
||||
end, })
|
||||
end
|
||||
|
||||
local function cpu_usage_new()
|
||||
local cpu_usage_helper = require('src.tools.helpers.cpu_usage')
|
||||
|
||||
local w = base.make_widget_from_value(wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'cpu.svg', Theme_config.cpu_usage.fg),
|
||||
resize = true,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
},
|
||||
{
|
||||
id = 'text_role',
|
||||
text = '0%',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.cpu_usage.bg,
|
||||
fg = Theme_config.cpu_usage.fg,
|
||||
shape = Theme_config.cpu_usage.shape,
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
|
||||
assert(w, 'failed to create widget')
|
||||
|
||||
hover.bg_hover { widget = w }
|
||||
|
||||
gtable.crush(w, cpu_info, true)
|
||||
|
||||
cpu_usage_helper:connect_signal('update::cpu_usage', function(_, usage)
|
||||
w:get_children_by_id('text_role')[1].text = usage .. '%'
|
||||
end)
|
||||
|
||||
return w
|
||||
end
|
||||
|
||||
local function cpu_freq_new()
|
||||
local cpu_freq_helper = require('src.tools.helpers.cpu_freq')
|
||||
|
||||
local w = base.make_widget_from_value(wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'cpu.svg', Theme_config.cpu_freq.fg),
|
||||
resize = true,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
},
|
||||
{
|
||||
id = 'text_role',
|
||||
text = '0Mhz',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.cpu_freq.bg,
|
||||
fg = Theme_config.cpu_freq.fg,
|
||||
shape = Theme_config.cpu_freq.shape,
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
|
||||
assert(w, 'failed to create widget')
|
||||
|
||||
hover.bg_hover { widget = w }
|
||||
|
||||
gtable.crush(w, cpu_info, true)
|
||||
|
||||
cpu_freq_helper:connect_signal('update::cpu_freq_average', function(_, average)
|
||||
w:get_children_by_id('text_role')[1].text = average .. 'Mhz'
|
||||
end)
|
||||
|
||||
cpu_freq_helper:connect_signal('update::cpu_freq_core', function(_, freq)
|
||||
w:get_children_by_id('text_role')[1].text = freq .. 'Mhz'
|
||||
end)
|
||||
|
||||
return w
|
||||
end
|
||||
|
||||
return setmetatable(cpu_info, { __call = function(_, widget)
|
||||
if widget == 'temp' then
|
||||
return cpu_temp_new()
|
||||
elseif widget == 'usage' then
|
||||
return cpu_usage_new()
|
||||
elseif widget == 'freq' then
|
||||
return cpu_freq_new()
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end, })
|
||||
return instance
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
-----------------------------
|
||||
-- This is the date widget --
|
||||
-----------------------------
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome Libs
|
||||
local apopup = require('awful.popup')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local wibox = require('wibox')
|
||||
local abutton = require('awful.button')
|
||||
local apopup = require('awful.popup')
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gtable = require('gears.table')
|
||||
local gcolor = require('gears.color')
|
||||
local gtimer = require('gears.timer')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Local libs
|
||||
local cal = require('src.modules.calendar.init') {}
|
||||
@@ -27,7 +27,7 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
{
|
||||
{
|
||||
{
|
||||
image = gcolor.recolor_image(icondir .. 'calendar.svg', Theme_config.date.fg),
|
||||
image = gcolor.recolor_image(icondir .. 'calendar.svg', beautiful.colorscheme.bg),
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
@@ -51,9 +51,9 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.date.bg,
|
||||
fg = Theme_config.date.fg,
|
||||
shape = Theme_config.date.shape,
|
||||
bg = beautiful.colorscheme.bg_teal,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
@@ -61,15 +61,20 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
widget = cal:get_widget(),
|
||||
screen = screen,
|
||||
ontop = true,
|
||||
visible = false,
|
||||
visible = true,
|
||||
}
|
||||
|
||||
-- Delayed call so the popup can eval its dimensions
|
||||
gtimer.delayed_call(function()
|
||||
calendar_popup.visible = false
|
||||
end)
|
||||
|
||||
hover.bg_hover { widget = date_widget }
|
||||
|
||||
date_widget:buttons { gtable.join(
|
||||
abutton({}, 1, function()
|
||||
local geo = capi.mouse.coords()
|
||||
calendar_popup.y = dpi(65)
|
||||
calendar_popup.y = dpi(70)
|
||||
if geo.x + (calendar_popup.width / 2) > capi.mouse.screen.geometry.width then
|
||||
calendar_popup.x = capi.mouse.screen.geometry.x + capi.mouse.screen.geometry.width - calendar_popup.width
|
||||
else
|
||||
|
||||
@@ -1,175 +1,169 @@
|
||||
---------------------------------
|
||||
-- This is the gpu Info widget --
|
||||
---------------------------------
|
||||
local mmax = math.max
|
||||
local setmetatable = setmetatable
|
||||
local tonumber = tonumber
|
||||
local tostring = tostring
|
||||
|
||||
-- Awesome Libs
|
||||
local base = require('wibox.widget.base')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Third Party Libs
|
||||
local color = require('src.lib.color')
|
||||
local rubato = require('src.lib.rubato')
|
||||
local hover = require('src.tools.hover')
|
||||
local rubato = require('src.lib.rubato')
|
||||
|
||||
local icon_dir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/cpu/'
|
||||
|
||||
local gpu_info = {}
|
||||
|
||||
local function gpu_temp_new()
|
||||
local gpu_temp_helper = require('src.tools.helpers.gpu_temp')
|
||||
local instance = nil
|
||||
if not instance then
|
||||
instance = setmetatable(gpu_info, { __call = function(_, widget)
|
||||
if widget == 'temp' then
|
||||
local gpu_temp_helper = require('src.tools.helpers.gpu_temp')
|
||||
|
||||
local w = base.make_widget_from_value(wibox.widget {
|
||||
{
|
||||
{
|
||||
local w = base.make_widget_from_value(wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'gpu.svg', Theme_config.gpu_temp.fg),
|
||||
resize = true,
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'gpu.svg', beautiful.colorscheme.bg),
|
||||
resize = true,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
},
|
||||
{
|
||||
id = 'text_role',
|
||||
text = '0°C',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
{
|
||||
id = 'text_role',
|
||||
text = '0°C',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.gpu_temp.bg,
|
||||
fg = Theme_config.gpu_temp.fg,
|
||||
shape = Theme_config.gpu_temp.shape,
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
bg = beautiful.colorscheme.bg_green,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
|
||||
assert(w, 'Widget not created')
|
||||
local r = rubato.timed { duration = 2.5 }
|
||||
local g = rubato.timed { duration = 2.5 }
|
||||
local b = rubato.timed { duration = 2.5 }
|
||||
|
||||
local r = rubato.timed { duration = 2.5 }
|
||||
local g = rubato.timed { duration = 2.5 }
|
||||
local b = rubato.timed { duration = 2.5 }
|
||||
r.pos, g.pos, b.pos = color.utils.hex_to_rgba(beautiful.colorscheme.bg_green)
|
||||
|
||||
r.pos, g.pos, b.pos = color.utils.hex_to_rgba(Theme_config.cpu_temp.bg_low)
|
||||
|
||||
-- Subscribable function to have rubato set the bg/fg color
|
||||
local function update_bg()
|
||||
w:set_bg('#' .. color.utils.rgba_to_hex { math.max(0, r.pos), math.max(0, g.pos),
|
||||
math.max(0, b.pos), })
|
||||
end
|
||||
|
||||
r:subscribe(update_bg)
|
||||
g:subscribe(update_bg)
|
||||
b:subscribe(update_bg)
|
||||
|
||||
-- Both functions to set a color, if called they take a new color
|
||||
local function set_bg(newbg)
|
||||
r.target, g.target, b.target = color.utils.hex_to_rgba(newbg)
|
||||
end
|
||||
|
||||
-- GPU Temperature
|
||||
gpu_temp_helper:connect_signal('update::gpu_temp', function(_, stdout)
|
||||
local temp_icon
|
||||
local temp_color
|
||||
local temp_num = tonumber(stdout) or 0
|
||||
if temp_num then
|
||||
if temp_num < 50 then
|
||||
temp_color = Theme_config.gpu_temp.bg_low
|
||||
temp_icon = icon_dir .. 'thermometer-low.svg'
|
||||
elseif temp_num >= 50 and temp_num < 80 then
|
||||
temp_color = Theme_config.gpu_temp.bg_mid
|
||||
temp_icon = icon_dir .. 'thermometer.svg'
|
||||
elseif temp_num >= 80 then
|
||||
temp_color = Theme_config.gpu_temp.bg_high
|
||||
temp_icon = icon_dir .. 'thermometer-high.svg'
|
||||
-- Subscribable function to have rubato set the bg/fg color
|
||||
local function update_bg()
|
||||
w:set_bg('#' .. color.utils.rgba_to_hex { mmax(0, r.pos), mmax(0, g.pos),
|
||||
mmax(0, b.pos), })
|
||||
end
|
||||
else
|
||||
temp_color = Theme_config.gpu_temp.bg_low
|
||||
temp_icon = icon_dir .. 'thermometer-low.svg'
|
||||
end
|
||||
w:get_children_by_id('icon_role')[1]:set_image(temp_icon)
|
||||
set_bg(temp_color)
|
||||
w:get_children_by_id('text_role')[1].text = tostring(temp_num) .. '°C'
|
||||
end)
|
||||
|
||||
return w
|
||||
end
|
||||
r:subscribe(update_bg)
|
||||
g:subscribe(update_bg)
|
||||
b:subscribe(update_bg)
|
||||
|
||||
local function gpu_usage_new()
|
||||
local gpu_usage_helper = require('src.tools.helpers.gpu_usage')
|
||||
-- Both functions to set a color, if called they take a new color
|
||||
local function set_bg(newbg)
|
||||
r.target, g.target, b.target = color.utils.hex_to_rgba(newbg)
|
||||
end
|
||||
|
||||
local w = base.make_widget_from_value(wibox.widget {
|
||||
{
|
||||
{
|
||||
-- GPU Temperature
|
||||
gpu_temp_helper:connect_signal('update::gpu_temp', function(_, stdout)
|
||||
local temp_icon
|
||||
local temp_color
|
||||
local temp_num = tonumber(stdout) or 0
|
||||
if temp_num then
|
||||
if temp_num < 50 then
|
||||
temp_color = beautiful.colorscheme.bg_green
|
||||
temp_icon = icon_dir .. 'thermometer-low.svg'
|
||||
elseif temp_num >= 50 and temp_num < 80 then
|
||||
temp_color = beautiful.colorscheme.bg_yellow
|
||||
temp_icon = icon_dir .. 'thermometer.svg'
|
||||
elseif temp_num >= 80 then
|
||||
temp_color = beautiful.colorscheme.bg_red
|
||||
temp_icon = icon_dir .. 'thermometer-high.svg'
|
||||
end
|
||||
else
|
||||
temp_color = beautiful.colorscheme.bg_green
|
||||
temp_icon = icon_dir .. 'thermometer-low.svg'
|
||||
end
|
||||
w:get_children_by_id('icon_role')[1]:set_image(temp_icon)
|
||||
set_bg(temp_color)
|
||||
w:get_children_by_id('text_role')[1].text = tostring(temp_num) .. '°C'
|
||||
end)
|
||||
|
||||
return w
|
||||
elseif widget == 'usage' then
|
||||
local gpu_usage_helper = require('src.tools.helpers.gpu_usage')
|
||||
|
||||
local w = base.make_widget_from_value(wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'gpu.svg', Theme_config.gpu_usage.fg),
|
||||
resize = true,
|
||||
{
|
||||
{
|
||||
id = 'icon_role',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'gpu.svg', beautiful.colorscheme.bg),
|
||||
resize = true,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
},
|
||||
{
|
||||
id = 'text_role',
|
||||
text = '0%',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(25),
|
||||
height = dpi(25),
|
||||
strategy = 'exact',
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
{
|
||||
id = 'text_role',
|
||||
text = '0%',
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.gpu_usage.bg,
|
||||
fg = Theme_config.gpu_usage.fg,
|
||||
shape = Theme_config.gpu_usage.shape,
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
bg = beautiful.colorscheme.bg_green,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
})
|
||||
|
||||
assert(w, 'Widget not created')
|
||||
hover.bg_hover { widget = w }
|
||||
|
||||
hover.bg_hover { widget = w }
|
||||
gpu_usage_helper:connect_signal('update::gpu_usage', function(_, stdout)
|
||||
w:get_children_by_id('text_role')[1].text = stdout:gsub('\n', '') .. '%'
|
||||
end)
|
||||
|
||||
gpu_usage_helper:connect_signal('update::gpu_usage', function(_, stdout)
|
||||
w:get_children_by_id('text_role')[1].text = stdout:gsub('\n', '') .. '%'
|
||||
end)
|
||||
|
||||
return w
|
||||
return w
|
||||
end
|
||||
end, })
|
||||
end
|
||||
|
||||
return setmetatable(gpu_info, { __call = function(_, widget)
|
||||
if widget == 'usage' then
|
||||
return gpu_usage_new()
|
||||
elseif widget == 'temp' then
|
||||
return gpu_temp_new()
|
||||
end
|
||||
end, })
|
||||
return instance
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
------------------------------
|
||||
-- This is the audio widget --
|
||||
------------------------------
|
||||
local pairs = pairs
|
||||
local setmetatable = setmetatable
|
||||
local tunpack = table.unpack
|
||||
|
||||
-- Awesome Libs
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local wibox = require('wibox')
|
||||
local abutton = require('awful.button')
|
||||
local apopup = require('awful.popup')
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gtable = require('gears.table')
|
||||
local abutton = require('awful.button')
|
||||
local apopup = require('awful.popup')
|
||||
local gtimer = require('gears.timer')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Local libs
|
||||
local kb_helper = require('src.tools.helpers.kb_helper')
|
||||
local hover = require('src.tools.hover')
|
||||
local kb_helper = require('src.tools.helpers.kb_helper')
|
||||
|
||||
local capi = {
|
||||
mouse = mouse,
|
||||
@@ -36,11 +38,11 @@ local function create_kb_layout_list()
|
||||
margins = dpi(10),
|
||||
},
|
||||
widget = wibox.container.background,
|
||||
bg = Theme_config.kblayout.bg_container,
|
||||
bg = beautiful.colorscheme.bg,
|
||||
}
|
||||
|
||||
local list = widget:get_children_by_id('list')[1]
|
||||
for _, keymap in pairs(User_config.kblayout) do
|
||||
for _, keymap in pairs(beautiful.user_config.kblayout) do
|
||||
-- TODO: Add more, too lazy rn
|
||||
local xkeyboard_country_code = {
|
||||
['af'] = { 'أفغانيش(Afghanistan)', 'AFG' }, -- Afghanistan
|
||||
@@ -136,23 +138,23 @@ local function create_kb_layout_list()
|
||||
['za'] = { '', 'ZAF' }, -- South Africa
|
||||
}
|
||||
|
||||
local longname, shortname = table.unpack(xkeyboard_country_code[keymap])
|
||||
local longname, shortname = tunpack(xkeyboard_country_code[keymap])
|
||||
|
||||
local kb_layout_item = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'shortname',
|
||||
markup = '<span foreground="' .. Theme_config.kblayout.item.fg_short .. '">' .. shortname .. '</span>',
|
||||
markup = '<span foreground="' .. beautiful.colorscheme.bg_purple .. '">' .. shortname .. '</span>',
|
||||
widget = wibox.widget.textbox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
},
|
||||
{
|
||||
id = 'longname',
|
||||
markup = '<span foreground="' .. Theme_config.kblayout.item.fg_long .. '">' .. longname .. '</span>',
|
||||
markup = '<span foreground="' .. beautiful.colorscheme.bg_red .. '">' .. longname .. '</span>',
|
||||
widget = wibox.widget.textbox,
|
||||
font = User_config.font.bold,
|
||||
font = beautiful.user_config.font.bold,
|
||||
},
|
||||
spacing = dpi(15),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
@@ -161,38 +163,38 @@ local function create_kb_layout_list()
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
id = 'hover',
|
||||
shape = Theme_config.kblayout.item.shape,
|
||||
border_width = Theme_config.kblayout.item.border_width,
|
||||
border_color = Theme_config.kblayout.item.border_color,
|
||||
bg = Theme_config.kblayout.item.bg,
|
||||
shape = beautiful.shape[6],
|
||||
border_width = dpi(2),
|
||||
border_color = beautiful.colorscheme.border_color,
|
||||
bg = beautiful.colorscheme.bg,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
kb_helper:connect_signal('KB::layout_changed', function(_, k)
|
||||
if keymap == k then
|
||||
kb_layout_item.bg = Theme_config.kblayout.item.bg_selected
|
||||
kb_layout_item.border_color = Theme_config.kblayout.item.bg_selected
|
||||
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_selected .. '">' .. shortname .. '</span>'
|
||||
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_selected .. '">' .. longname .. '</span>'
|
||||
kb_layout_item.bg = beautiful.colorscheme.bg_purple
|
||||
kb_layout_item.border_color = beautiful.colorscheme.bg_purple
|
||||
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. beautiful.colorscheme.bg .. '">' .. shortname .. '</span>'
|
||||
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. beautiful.colorscheme.bg .. '">' .. longname .. '</span>'
|
||||
else
|
||||
kb_layout_item.bg = Theme_config.kblayout.item.bg
|
||||
kb_layout_item.border_color = Theme_config.kblayout.item.border_color
|
||||
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_short .. '">' .. shortname .. '</span>'
|
||||
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_long .. '">' .. longname .. '</span>'
|
||||
kb_layout_item.bg = beautiful.colorscheme.bg
|
||||
kb_layout_item.border_color = beautiful.colorscheme.border_color
|
||||
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. beautiful.colorscheme.bg_purple .. '">' .. shortname .. '</span>'
|
||||
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. beautiful.colorscheme.bg_red .. '">' .. longname .. '</span>'
|
||||
end
|
||||
end)
|
||||
|
||||
kb_helper:get_layout_async(function(k)
|
||||
if keymap == k then
|
||||
kb_layout_item.bg = Theme_config.kblayout.item.bg_selected
|
||||
kb_layout_item.border_color = Theme_config.kblayout.item.bg_selected
|
||||
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_selected .. '">' .. shortname .. '</span>'
|
||||
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_selected .. '">' .. longname .. '</span>'
|
||||
kb_layout_item.bg = beautiful.colorscheme.bg_purple
|
||||
kb_layout_item.border_color = beautiful.colorscheme.bg_purple
|
||||
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. beautiful.colorscheme.bg .. '">' .. shortname .. '</span>'
|
||||
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. beautiful.colorscheme.bg .. '">' .. longname .. '</span>'
|
||||
else
|
||||
kb_layout_item.bg = Theme_config.kblayout.item.bg
|
||||
kb_layout_item.border_color = Theme_config.kblayout.item.border_color
|
||||
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_short .. '">' .. shortname .. '</span>'
|
||||
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. Theme_config.kblayout.item.fg_long .. '">' .. longname .. '</span>'
|
||||
kb_layout_item.bg = beautiful.colorscheme.bg
|
||||
kb_layout_item.border_color = beautiful.colorscheme.border_color
|
||||
kb_layout_item:get_children_by_id('shortname')[1].markup = '<span foreground="' .. beautiful.colorscheme.bg_purple .. '">' .. shortname .. '</span>'
|
||||
kb_layout_item:get_children_by_id('longname')[1].markup = '<span foreground="' .. beautiful.colorscheme.bg_red .. '">' .. longname .. '</span>'
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -201,7 +203,6 @@ local function create_kb_layout_list()
|
||||
kb_layout_item:buttons { gtable.join(
|
||||
abutton({}, 1, function()
|
||||
kb_helper:set_layout(keymap)
|
||||
--kb_layout_popup.visible = not kb_layout_popup.visible
|
||||
end)
|
||||
), }
|
||||
|
||||
@@ -221,7 +222,7 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
resize = true,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icondir .. 'keyboard.svg', Theme_config.kblayout.fg),
|
||||
image = gcolor.recolor_image(icondir .. 'keyboard.svg', beautiful.colorscheme.bg),
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
width = dpi(24),
|
||||
@@ -241,9 +242,9 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.kblayout.bg,
|
||||
fg = Theme_config.kblayout.fg,
|
||||
shape = Theme_config.kblayout.shape,
|
||||
bg = beautiful.colorscheme.bg_green,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
@@ -259,18 +260,24 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
|
||||
kb_layout_popup = apopup {
|
||||
widget = create_kb_layout_list(),
|
||||
border_color = Theme_config.kblayout.border_color,
|
||||
border_width = Theme_config.kblayout.border_width,
|
||||
border_color = beautiful.colorscheme.border_color,
|
||||
border_width = dpi(2),
|
||||
screen = screen,
|
||||
ontop = true,
|
||||
visible = false,
|
||||
bg = Theme_config.kblayout.bg_container,
|
||||
visible = true,
|
||||
bg = beautiful.colorscheme.bg,
|
||||
}
|
||||
|
||||
-- Delayed call to make the popup invisible,
|
||||
-- needed to give it time to evaluate its dimensions
|
||||
gtimer.delayed_call(function()
|
||||
kb_layout_popup.visible = false
|
||||
end)
|
||||
|
||||
kblayout_widget:buttons { gtable.join(
|
||||
abutton({}, 1, function()
|
||||
local geo = capi.mouse.coords()
|
||||
kb_layout_popup.y = dpi(65)
|
||||
kb_layout_popup.y = dpi(70)
|
||||
kb_layout_popup.x = geo.x - kb_layout_popup.width / 2
|
||||
kb_layout_popup.visible = not kb_layout_popup.visible
|
||||
end)
|
||||
|
||||
@@ -1,77 +1,56 @@
|
||||
----------------------------------
|
||||
-- This is the layoutbox widget --
|
||||
----------------------------------
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome Libs
|
||||
local abutton = require('awful.button')
|
||||
local alayout = require('awful.layout')
|
||||
local awidget = require('awful.widget')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gtable = require('gears.table')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Local libs
|
||||
local hover = require('src.tools.hover')
|
||||
|
||||
--#region Layout icons
|
||||
local layout_path = Theme_path .. '../assets/layout/'
|
||||
|
||||
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
|
||||
return function()
|
||||
local layout = wibox.widget {
|
||||
{
|
||||
return setmetatable({}, {
|
||||
__call = function(_, screen)
|
||||
local layout = wibox.widget {
|
||||
{
|
||||
{
|
||||
awidget.layoutbox(),
|
||||
widget = wibox.container.place,
|
||||
{
|
||||
awidget.layoutbox(),
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
widget = wibox.container.constraint,
|
||||
strategy = 'exact',
|
||||
width = dpi(40),
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
strategy = 'exact',
|
||||
width = dpi(40),
|
||||
},
|
||||
bg = Theme_config.layout_list.bg,
|
||||
shape = Theme_config.layout_list.shape,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
bg = beautiful.colorscheme.bg_blue,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
hover.bg_hover { widget = layout }
|
||||
hover.bg_hover { widget = layout }
|
||||
|
||||
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)
|
||||
))
|
||||
layout:buttons(gtable.join(
|
||||
abutton({}, 1, function()
|
||||
alayout.inc(1, screen)
|
||||
end),
|
||||
abutton({}, 3, function()
|
||||
alayout.inc(-1, screen)
|
||||
end),
|
||||
abutton({}, 4, function()
|
||||
alayout.inc(1, screen)
|
||||
end),
|
||||
abutton({}, 5, function()
|
||||
alayout.inc(-1, screen)
|
||||
end)
|
||||
))
|
||||
|
||||
return layout
|
||||
end
|
||||
return layout
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -1,119 +1,114 @@
|
||||
--------------------------------
|
||||
-- This is the network widget --
|
||||
--------------------------------
|
||||
local setmetatable = setmetatable
|
||||
local mfloor = math.floor
|
||||
|
||||
-- Awesome Libs
|
||||
local abutton = require('awful.button')
|
||||
local apopup = require('awful.popup')
|
||||
local atooltip = require('awful.tooltip')
|
||||
local base = require('wibox.widget.base')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local gears = require('gears')
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gtable = require('gears.table')
|
||||
local gtimer = require('gears.timer')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Local Libs
|
||||
local hover = require('src.tools.hover')
|
||||
local nm_widget = require('src.modules.network_controller')
|
||||
|
||||
local capi = {
|
||||
awesome = awesome,
|
||||
mouse = mouse,
|
||||
}
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = gears.filesystem.get_configuration_dir() .. 'src/assets/icons/network/'
|
||||
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/network/'
|
||||
|
||||
local nm_widget = require('src.modules.network_controller.init')
|
||||
local hover = require('src.tools.hover')
|
||||
|
||||
local network = { mt = {} }
|
||||
|
||||
function network.new(args)
|
||||
args = args or {}
|
||||
|
||||
local w = base.make_widget_from_value {
|
||||
{
|
||||
return setmetatable({}, {
|
||||
__call = function(_, screen)
|
||||
local w = base.make_widget_from_value {
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'wifi_icon',
|
||||
image = gears.color.recolor_image(icondir .. 'no-internet.svg', Theme_config.network.fg),
|
||||
widget = wibox.widget.imagebox,
|
||||
resize = false,
|
||||
{
|
||||
id = 'wifi_icon',
|
||||
image = gcolor.recolor_image(icondir .. 'no-internet.svg', beautiful.colorscheme.bg),
|
||||
widget = wibox.widget.imagebox,
|
||||
resize = false,
|
||||
},
|
||||
{
|
||||
id = 'wifi_strength',
|
||||
visible = true,
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
{
|
||||
id = 'wifi_strength',
|
||||
visible = true,
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
widget = wibox.container.place,
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
},
|
||||
bg = Theme_config.network.bg,
|
||||
fg = Theme_config.network.fg,
|
||||
shape = Theme_config.network.shape,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
assert(w, 'Failed to create widget')
|
||||
|
||||
hover.bg_hover { widget = w }
|
||||
|
||||
gtable.crush(w, network, true)
|
||||
|
||||
capi.awesome.connect_signal('NM::AccessPointStrength', function(strength)
|
||||
strength = math.floor(strength)
|
||||
w:get_children_by_id('wifi_strength')[1].text = strength .. '%'
|
||||
w:get_children_by_id('wifi_icon')[1].image = gears.color.recolor_image(icondir ..
|
||||
'wifi-strength-' .. math.floor(strength / 25) + 1 .. '.svg', Theme_config.network.fg)
|
||||
end)
|
||||
|
||||
capi.awesome.connect_signal('NM::EthernetStatus', function(connected, speed)
|
||||
local tt = atooltip {
|
||||
objects = { w },
|
||||
mode = 'outside',
|
||||
preferred_alignments = 'middle',
|
||||
margins = dpi(10),
|
||||
bg = beautiful.colorscheme.bg_red,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
if connected then
|
||||
w:get_children_by_id('wifi_icon')[1].image = gears.color.recolor_image(icondir .. 'ethernet.svg',
|
||||
Theme_config.network.fg)
|
||||
tt.text = 'Connected via Ethernet at ' .. math.floor(speed or 0) .. '/Mbps'
|
||||
else
|
||||
w:get_children_by_id('wifi_icon')[1].image = gears.color.recolor_image(icondir .. 'no-internet.svg',
|
||||
Theme_config.network.fg)
|
||||
tt.text = 'No connection found'
|
||||
end
|
||||
end)
|
||||
|
||||
local nm = nm_widget { screen = args.screen }
|
||||
hover.bg_hover { widget = w }
|
||||
|
||||
local network_controler_popup = apopup {
|
||||
widget = nm,
|
||||
visible = false,
|
||||
ontop = true,
|
||||
screen = args.screen,
|
||||
}
|
||||
|
||||
w:buttons(gtable.join(
|
||||
abutton({}, 1, function()
|
||||
--This gets the wrong wibox, get all wiboxed and find the correct widget
|
||||
network_controler_popup.x = capi.mouse.coords().x - (network_controler_popup:geometry().width / 2)
|
||||
network_controler_popup.y = dpi(65)
|
||||
network_controler_popup.visible = not network_controler_popup.visible
|
||||
capi.awesome.connect_signal('NM::AccessPointStrength', function(strength)
|
||||
strength = mfloor(strength)
|
||||
w:get_children_by_id('wifi_strength')[1].text = strength .. '%'
|
||||
w:get_children_by_id('wifi_icon')[1].image = gcolor.recolor_image(icondir ..
|
||||
'wifi-strength-' .. mfloor(strength / 25) + 1 .. '.svg', beautiful.colorscheme.bg)
|
||||
end)
|
||||
))
|
||||
|
||||
return w
|
||||
end
|
||||
capi.awesome.connect_signal('NM::EthernetStatus', function(connected, speed)
|
||||
local tt = atooltip {
|
||||
objects = { w },
|
||||
mode = 'outside',
|
||||
preferred_alignments = 'middle',
|
||||
margins = dpi(10),
|
||||
}
|
||||
if connected then
|
||||
w:get_children_by_id('wifi_icon')[1].image = gcolor.recolor_image(icondir .. 'ethernet.svg',
|
||||
beautiful.colorscheme.bg)
|
||||
tt.text = 'Connected via Ethernet at ' .. mfloor(speed or 0) .. '/Mbps'
|
||||
else
|
||||
w:get_children_by_id('wifi_icon')[1].image = gcolor.recolor_image(icondir .. 'no-internet.svg',
|
||||
beautiful.colorscheme.bg)
|
||||
tt.text = 'No connection found'
|
||||
end
|
||||
end)
|
||||
|
||||
function network.mt:__call(...)
|
||||
return network.new(...)
|
||||
end
|
||||
local nm = nm_widget { screen = screen }
|
||||
|
||||
return setmetatable(network, network.mt)
|
||||
local network_controler_popup = apopup {
|
||||
widget = nm,
|
||||
visible = true,
|
||||
ontop = true,
|
||||
screen = screen,
|
||||
}
|
||||
|
||||
gtimer.delayed_call(function()
|
||||
network_controler_popup.visible = false
|
||||
end)
|
||||
|
||||
w:buttons(gtable.join(
|
||||
abutton({}, 1, function()
|
||||
--This gets the wrong wibox, get all wiboxed and find the correct widget
|
||||
network_controler_popup.x = capi.mouse.coords().x - (network_controler_popup:geometry().width / 2)
|
||||
network_controler_popup.y = dpi(70)
|
||||
network_controler_popup.visible = not network_controler_popup.visible
|
||||
end)
|
||||
))
|
||||
|
||||
return w
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -1,51 +1,54 @@
|
||||
--------------------------------
|
||||
-- This is the power widget --
|
||||
--------------------------------
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome Libs
|
||||
local abutton = require('awful.button')
|
||||
local gtable = require('gears.table')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local wibox = require('wibox')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gtable = require('gears.table')
|
||||
local wibox = require('wibox')
|
||||
|
||||
-- Local libs
|
||||
local powermenu = require('src.modules.powermenu.init')
|
||||
local hover = require('src.tools.hover')
|
||||
local powermenu = require('src.modules.powermenu')
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/power/'
|
||||
|
||||
return setmetatable({}, { __call = function()
|
||||
local instance = nil
|
||||
if not instance then
|
||||
instance = setmetatable({}, { __call = function()
|
||||
|
||||
local power_widget = wibox.widget {
|
||||
{
|
||||
local power_widget = wibox.widget {
|
||||
{
|
||||
image = gcolor.recolor_image(icondir .. 'power.svg', Theme_config.power_button.fg),
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
resize = false,
|
||||
{
|
||||
image = gcolor.recolor_image(icondir .. 'power.svg', beautiful.colorscheme.bg),
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
resize = false,
|
||||
},
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.power_button.bg,
|
||||
fg = Theme_config.power_button.fg,
|
||||
shape = Theme_config.power_button.shape,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
bg = beautiful.colorscheme.bg_red,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
-- Signals
|
||||
hover.bg_hover { widget = power_widget }
|
||||
-- Signals
|
||||
hover.bg_hover { widget = power_widget }
|
||||
|
||||
power_widget:buttons { gtable.join(
|
||||
abutton({}, 1, function()
|
||||
powermenu:toggle()
|
||||
end)
|
||||
), }
|
||||
power_widget:buttons { gtable.join(
|
||||
abutton({}, 1, function()
|
||||
powermenu:toggle()
|
||||
end)
|
||||
), }
|
||||
|
||||
return power_widget
|
||||
end, })
|
||||
return power_widget
|
||||
end, })
|
||||
end
|
||||
return instance
|
||||
|
||||
@@ -1,70 +1,75 @@
|
||||
---------------------------------
|
||||
-- This is the RAM Info widget --
|
||||
---------------------------------
|
||||
local setmetatable = setmetatable
|
||||
local string = string
|
||||
local tostring = tostring
|
||||
|
||||
-- Awesome Libs
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gcolor = require('gears.color')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
local gshape = require('gears.shape')
|
||||
local wibox = require('wibox')
|
||||
|
||||
local ram_helper = require('src.tools.helpers.ram')
|
||||
-- Local Libs
|
||||
local hover = require('src.tools.hover')
|
||||
local ram_helper = require('src.tools.helpers.ram')
|
||||
|
||||
local icon_dir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/cpu/'
|
||||
|
||||
return function()
|
||||
local ram_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
local instance = nil
|
||||
if not instance then
|
||||
instance = setmetatable({}, {
|
||||
__call = function()
|
||||
local ram_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'icon',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'ram.svg', Theme_config.ram_info.fg),
|
||||
resize = false,
|
||||
{
|
||||
{
|
||||
id = 'icon',
|
||||
widget = wibox.widget.imagebox,
|
||||
valign = 'center',
|
||||
halign = 'center',
|
||||
image = gcolor.recolor_image(icon_dir .. 'ram.svg', beautiful.colorscheme.fg),
|
||||
resize = false,
|
||||
},
|
||||
id = 'icon_layout',
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
top = dpi(2),
|
||||
widget = wibox.container.margin,
|
||||
id = 'icon_margin',
|
||||
},
|
||||
id = 'icon_layout',
|
||||
widget = wibox.container.place,
|
||||
spacing = dpi(10),
|
||||
{
|
||||
id = 'label',
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
id = 'ram_layout',
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
top = dpi(2),
|
||||
id = 'container',
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
id = 'icon_margin',
|
||||
},
|
||||
spacing = dpi(10),
|
||||
{
|
||||
id = 'label',
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
id = 'ram_layout',
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
id = 'container',
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
bg = Theme_config.ram_info.bg,
|
||||
fg = Theme_config.ram_info.fg,
|
||||
shape = function(cr, width, height)
|
||||
gshape.rounded_rect(cr, width, height, dpi(6))
|
||||
bg = beautiful.colorscheme.bg_red,
|
||||
fg = beautiful.colorscheme.bg,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
hover.bg_hover { widget = ram_widget }
|
||||
|
||||
ram_helper:connect_signal('update::ram_widget', function(_, MemTotal, _, MemAvailable)
|
||||
local ram_string = tostring(string.format('%.1f', ((MemTotal - MemAvailable) / 1024 / 1024)) ..
|
||||
'/' .. string.format('%.1f', (MemTotal / 1024 / 1024)) .. 'GB'):gsub(',', '.')
|
||||
ram_widget.container.ram_layout.label.text = ram_string
|
||||
end)
|
||||
|
||||
return ram_widget
|
||||
end,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
hover.bg_hover { widget = ram_widget }
|
||||
|
||||
ram_helper:connect_signal('update::ram_widget', function(_, MemTotal, MemFree, MemAvailable)
|
||||
local ram_string = tostring(string.format('%.1f', ((MemTotal - MemAvailable) / 1024 / 1024)) ..
|
||||
'/' .. string.format('%.1f', (MemTotal / 1024 / 1024)) .. 'GB'):gsub(',', '.')
|
||||
ram_widget.container.ram_layout.label.text = ram_string
|
||||
end)
|
||||
|
||||
return ram_widget
|
||||
})
|
||||
end
|
||||
return instance
|
||||
|
||||
@@ -3,48 +3,72 @@
|
||||
--------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local wibox = require('wibox')
|
||||
local abutton = require('awful.button')
|
||||
local gfilesystem = require('gears.filesystem')
|
||||
|
||||
local capi = { awesome = awesome }
|
||||
local icondir = gfilesystem.get_configuration_dir() .. 'src/assets/icons/systray/'
|
||||
|
||||
-- Systray theme variables
|
||||
Theme.bg_systray = Theme_config.systray.bg
|
||||
Theme.systray_icon_spacing = dpi(10)
|
||||
local instance = nil
|
||||
if not instance then
|
||||
instance = setmetatable({}, {
|
||||
__call = function()
|
||||
local systray = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
widget = wibox.widget.imagebox,
|
||||
resize = true,
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
image = icondir .. 'chevron-right.svg',
|
||||
},
|
||||
height = dpi(28),
|
||||
width = dpi(28),
|
||||
widget = wibox.container.constraint,
|
||||
strategy = 'exact',
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
wibox.widget.systray(),
|
||||
id = 'systray_margin',
|
||||
margins = dpi(6),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
strategy = 'exact',
|
||||
widget = wibox.container.constraint,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
id = 'lay',
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
widget = wibox.container.background,
|
||||
shape = beautiful.shape[6],
|
||||
bg = beautiful.colorscheme.bg1,
|
||||
}
|
||||
|
||||
return function()
|
||||
local systray = wibox.widget {
|
||||
{
|
||||
{
|
||||
wibox.widget.systray(),
|
||||
id = 'systray_margin',
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
strategy = 'exact',
|
||||
widget = wibox.container.constraint,
|
||||
},
|
||||
widget = wibox.container.background,
|
||||
shape = Theme_config.systray.shape,
|
||||
bg = Theme_config.systray.bg
|
||||
}
|
||||
systray:buttons {
|
||||
abutton({}, 1, function()
|
||||
local c = systray:get_children_by_id('lay')[1].children[2]
|
||||
c.visible = not c.visible
|
||||
|
||||
local systray_margin = systray:get_children_by_id('systray_margin')[1]
|
||||
if not c.visible then
|
||||
systray:get_children_by_id('lay')[1].children[1].children[1].image = icondir .. 'chevron-left.svg'
|
||||
else
|
||||
systray:get_children_by_id('lay')[1].children[1].children[1].image = icondir .. 'chevron-right.svg'
|
||||
end
|
||||
end),
|
||||
}
|
||||
|
||||
-- Wait for an systray update
|
||||
capi.awesome.connect_signal('systray::update', function()
|
||||
-- Get the number of entries in the systray
|
||||
local num_entries = capi.awesome.systray()
|
||||
-- Set the icon size
|
||||
systray:get_children_by_id('systray_margin')[1].widget:set_base_size(dpi(24))
|
||||
|
||||
-- If its 0 remove the margins to hide the widget
|
||||
if num_entries == 0 then
|
||||
systray_margin:set_margins(0)
|
||||
else
|
||||
systray_margin:set_margins(dpi(6))
|
||||
end
|
||||
end)
|
||||
|
||||
-- Set the icon size
|
||||
systray_margin.widget:set_base_size(dpi(24))
|
||||
|
||||
return systray
|
||||
return systray
|
||||
end,
|
||||
})
|
||||
end
|
||||
return instance
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
--------------------------------
|
||||
-- This is the taglist widget --
|
||||
--------------------------------
|
||||
local ipairs = ipairs
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome Libs
|
||||
local abutton = require('awful.button')
|
||||
local ascreen = require('awful.screen')
|
||||
local atag = require('awful.tag')
|
||||
local awidget = require('awful.widget')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gtable = require('gears.table')
|
||||
local wibox = require('wibox')
|
||||
|
||||
@@ -16,7 +16,7 @@ local hover = require('src.tools.hover')
|
||||
|
||||
local capi = { client = client }
|
||||
|
||||
local modkey = User_config.modkey
|
||||
local modkey = beautiful.user_config.modkey
|
||||
|
||||
local tag_text = {
|
||||
[1] = '一',
|
||||
@@ -40,7 +40,6 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
widget:reset()
|
||||
-- Create a tag widget for each tag
|
||||
for _, tag in ipairs(tags) do
|
||||
|
||||
local tag_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
@@ -59,9 +58,9 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
right = dpi(10),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
fg = Theme_config.taglist.fg,
|
||||
bg = Theme_config.taglist.bg,
|
||||
shape = Theme_config.taglist.shape,
|
||||
fg = beautiful.colorscheme.fg,
|
||||
bg = beautiful.colorscheme.bg1,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
@@ -100,14 +99,14 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
|
||||
-- Change the taglist colors depending on the state of the tag
|
||||
if tag == ascreen.focused().selected_tag then
|
||||
tag_widget:set_bg(Theme_config.taglist.bg_focus)
|
||||
tag_widget:set_fg(Theme_config.taglist.fg_focus)
|
||||
tag_widget:set_bg(beautiful.colorscheme.fg)
|
||||
tag_widget:set_fg(beautiful.colorscheme.bg)
|
||||
elseif tag.urgent == true then
|
||||
tag_widget:set_bg(Theme_config.taglist.bg_urgent)
|
||||
tag_widget:set_fg(Theme_config.taglist.fg_urgent)
|
||||
tag_widget:set_bg(beautiful.colorscheme.bg_red)
|
||||
tag_widget:set_fg(beautiful.colorscheme.bg)
|
||||
else
|
||||
tag_widget:set_bg(Theme_config.taglist.bg)
|
||||
tag_widget:set_fg(Theme_config.taglist.fg)
|
||||
tag_widget:set_bg(beautiful.colorscheme.bg1)
|
||||
tag_widget:set_fg(beautiful.colorscheme.fg)
|
||||
end
|
||||
|
||||
-- Add the client icons to the tag widget
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---------------------------------
|
||||
-- This is the tasklist widget --
|
||||
---------------------------------
|
||||
local ipairs = ipairs
|
||||
local setmetatable = setmetatable
|
||||
|
||||
-- Awesome Libs
|
||||
local abutton = require('awful.button')
|
||||
local atooltip = require('awful.tooltip')
|
||||
local awidget = require('awful.widget')
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local beautiful = require('beautiful')
|
||||
local dpi = beautiful.xresources.apply_dpi
|
||||
local gtable = require('gears.table')
|
||||
local wibox = require('wibox')
|
||||
|
||||
@@ -54,9 +54,9 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
left = dpi(10),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
fg = Theme_config.tasklist.fg,
|
||||
bg = Theme_config.tasklist.bg,
|
||||
shape = Theme_config.tasklist.shape,
|
||||
fg = beautiful.colorscheme.fg,
|
||||
bg = beautiful.colorscheme.bg1,
|
||||
shape = beautiful.shape[6],
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
end)
|
||||
), }
|
||||
|
||||
local label = User_config.taskbar_use_name and client.name or client.class or ''
|
||||
local label = beautiful.user_config.taskbar_use_name and client.name or client.class or ''
|
||||
|
||||
-- If the client is focused, show the tooltip and add a label
|
||||
if client == capi.client.focus then
|
||||
@@ -93,10 +93,10 @@ return setmetatable({}, { __call = function(_, screen)
|
||||
delay_show = 1,
|
||||
}
|
||||
task_widget:get_children_by_id('text_role')[1].text = label:sub(1, 20)
|
||||
task_widget.bg = Theme_config.tasklist.bg_focus
|
||||
task_widget.fg = Theme_config.tasklist.fg_focus
|
||||
task_widget.bg = beautiful.colorscheme.fg
|
||||
task_widget.fg = beautiful.colorscheme.bg
|
||||
else
|
||||
task_widget.bg = Theme_config.tasklist.bg
|
||||
task_widget.bg = beautiful.colorscheme.bg1
|
||||
task_widget:get_children_by_id('text_role')[1].text = ''
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user