yes, I'm very commit lazy
This commit is contained in:
@@ -3,15 +3,14 @@
|
||||
--------------------------------
|
||||
|
||||
-- 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 gtable = require("gears.table")
|
||||
local naughty = require("naughty")
|
||||
local wibox = require("wibox")
|
||||
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 gtable = require('gears.table')
|
||||
local wibox = require('wibox')
|
||||
|
||||
local capi = {
|
||||
awesome = awesome,
|
||||
@@ -19,51 +18,79 @@ local capi = {
|
||||
}
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = gears.filesystem.get_configuration_dir() .. "src/assets/icons/network/"
|
||||
local icondir = gears.filesystem.get_configuration_dir() .. 'src/assets/icons/network/'
|
||||
|
||||
local nm_widget = require("src.modules.network_controller.init")
|
||||
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({
|
||||
local w = base.make_widget_from_value {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'wifi_icon',
|
||||
image = gears.color.recolor_image(icondir .. "no-internet" .. ".svg", Theme_config.network.fg),
|
||||
image = gears.color.recolor_image(icondir .. 'no-internet.svg', Theme_config.network.fg),
|
||||
widget = wibox.widget.imagebox,
|
||||
resize = false
|
||||
resize = false,
|
||||
},
|
||||
{
|
||||
id = "wifi_strength",
|
||||
id = 'wifi_strength',
|
||||
visible = true,
|
||||
widget = wibox.widget.textbox
|
||||
widget = wibox.widget.textbox,
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
},
|
||||
left = dpi(8),
|
||||
right = dpi(8),
|
||||
widget = wibox.container.margin
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
widget = wibox.container.place,
|
||||
halign = "center",
|
||||
valign = "center"
|
||||
halign = 'center',
|
||||
valign = 'center',
|
||||
},
|
||||
bg = Theme_config.network.bg,
|
||||
fg = Theme_config.network.fg,
|
||||
shape = Theme_config.network.shape,
|
||||
widget = wibox.container.background
|
||||
})
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
Hover_signal(w)
|
||||
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),
|
||||
}
|
||||
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 }
|
||||
|
||||
local network_controler_popup = apopup {
|
||||
@@ -82,25 +109,6 @@ function network.new(args)
|
||||
end)
|
||||
))
|
||||
|
||||
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)
|
||||
|
||||
nm:connect_signal("NM::Bitrate", function(_, bitrate)
|
||||
print(bitrate)
|
||||
end)
|
||||
|
||||
atooltip {
|
||||
objects = { w },
|
||||
mode = "outside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10),
|
||||
text = "Connected to " .. "" .. " with " .. "" .. " signal strength"
|
||||
}
|
||||
|
||||
return w
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user