some fixes
This commit is contained in:
@@ -45,3 +45,5 @@ require('src.bindings.bind_to_tags')
|
|||||||
require('src.modules') {}
|
require('src.modules') {}
|
||||||
require('src.tools.auto_starter') {}
|
require('src.tools.auto_starter') {}
|
||||||
--require('src.core.setup')()
|
--require('src.core.setup')()
|
||||||
|
|
||||||
|
require('src.tools.network')()
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
local table = table
|
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
|
local table = table
|
||||||
|
|
||||||
-- Awesome libs
|
-- Awesome libs
|
||||||
local akeygrabber = require('awful.keygrabber')
|
|
||||||
local akey = require('awful.key')
|
|
||||||
local gtable = require('gears.table')
|
|
||||||
local atag = require('awful.tag')
|
|
||||||
local aclient = require('awful.client')
|
local aclient = require('awful.client')
|
||||||
local aspawn = require('awful.spawn')
|
local akey = require('awful.key')
|
||||||
|
local akeygrabber = require('awful.keygrabber')
|
||||||
local alayout = require('awful.layout')
|
local alayout = require('awful.layout')
|
||||||
local ascreen = require('awful.screen')
|
local ascreen = require('awful.screen')
|
||||||
|
local aspawn = require('awful.spawn')
|
||||||
|
local atag = require('awful.tag')
|
||||||
|
local gfilesystem = require('gears.filesystem')
|
||||||
|
local gtable = require('gears.table')
|
||||||
local hotkeys_popup = require('awful.hotkeys_popup')
|
local hotkeys_popup = require('awful.hotkeys_popup')
|
||||||
local ruled = require('ruled')
|
local ruled = require('ruled')
|
||||||
|
|
||||||
-- Local libs
|
-- Local libs
|
||||||
local config = require('src.tools.config')
|
|
||||||
local audio_helper = require('src.tools.helpers.audio')
|
local audio_helper = require('src.tools.helpers.audio')
|
||||||
local backlight_helper = require('src.tools.helpers.backlight')
|
local backlight_helper = require('src.tools.helpers.backlight')
|
||||||
local beautiful = require('beautiful')
|
local beautiful = require('beautiful')
|
||||||
|
local config = require('src.tools.config')
|
||||||
local kb_helper = require('src.tools.helpers.kb_helper')
|
local kb_helper = require('src.tools.helpers.kb_helper')
|
||||||
local window_switcher = require('src.modules.window_switcher')
|
local window_switcher = require('src.modules.window_switcher')
|
||||||
|
|
||||||
@@ -314,7 +315,7 @@ return gtable.join(
|
|||||||
capi.mousegrabber.run(
|
capi.mousegrabber.run(
|
||||||
function(m)
|
function(m)
|
||||||
if m.buttons[1] then
|
if m.buttons[1] then
|
||||||
local data = config.read_json('/home/crylia/.config/awesome/src/config/floating.json')
|
local data = config.read_json(gfilesystem.get_configuration_dir() .. 'src/config/floating.json')
|
||||||
if type(data) ~= 'table' then return end
|
if type(data) ~= 'table' then return end
|
||||||
|
|
||||||
local c = capi.mouse.current_client
|
local c = capi.mouse.current_client
|
||||||
@@ -345,7 +346,7 @@ return gtable.join(
|
|||||||
}
|
}
|
||||||
c.floating = true
|
c.floating = true
|
||||||
|
|
||||||
config.write_json('/home/crylia/.config/awesome/src/config/floating.json', data)
|
config.write_json(gfilesystem.get_configuration_dir() .. 'src/config/floating.json', data)
|
||||||
capi.mousegrabber.stop()
|
capi.mousegrabber.stop()
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@@ -361,7 +362,7 @@ return gtable.join(
|
|||||||
capi.mousegrabber.run(
|
capi.mousegrabber.run(
|
||||||
function(m)
|
function(m)
|
||||||
if m.buttons[1] then
|
if m.buttons[1] then
|
||||||
local data = config.read_json('/home/crylia/.config/awesome/src/config/floating.json')
|
local data = config.read_json(gfilesystem.get_configuration_dir() .. 'src/config/floating.json')
|
||||||
local c = capi.mouse.current_client
|
local c = capi.mouse.current_client
|
||||||
if not c then return end
|
if not c then return end
|
||||||
|
|
||||||
@@ -387,7 +388,7 @@ return gtable.join(
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config.write_json('/home/crylia/.config/awesome/src/config/floating.json', data)
|
config.write_json(gfilesystem.get_configuration_dir() .. 'src/config/floating.json', data)
|
||||||
capi.mousegrabber.stop()
|
capi.mousegrabber.stop()
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local setmetatable = setmetatable
|
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
|
||||||
-- Awesome Libs
|
-- Awesome Libs
|
||||||
local aclient = require('awful.client')
|
local aclient = require('awful.client')
|
||||||
@@ -7,6 +7,7 @@ local aplacement = require('awful.placement')
|
|||||||
local ascreen = require('awful.screen')
|
local ascreen = require('awful.screen')
|
||||||
local beautiful = require('beautiful')
|
local beautiful = require('beautiful')
|
||||||
local dpi = beautiful.xresources.apply_dpi
|
local dpi = beautiful.xresources.apply_dpi
|
||||||
|
local gfilesystem = require('gears.filesystem')
|
||||||
local ruled = require('ruled')
|
local ruled = require('ruled')
|
||||||
|
|
||||||
local config = require('src.tools.config')
|
local config = require('src.tools.config')
|
||||||
@@ -64,18 +65,6 @@ if not instance then
|
|||||||
minimized = true,
|
minimized = true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ruled.client.append_rule {
|
|
||||||
rule_any = {
|
|
||||||
class = {
|
|
||||||
'discord',
|
|
||||||
'spotify',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
properties = {
|
|
||||||
tag = '1',
|
|
||||||
screen = 2,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
ruled.client.append_rule {
|
ruled.client.append_rule {
|
||||||
rule_any = {
|
rule_any = {
|
||||||
@@ -97,7 +86,7 @@ if not instance then
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
local data = config.read_json('/home/crylia/.config/awesome/src/config/floating.json')
|
local data = config.read_json(gfilesystem.get_configuration_dir() .. 'src/config/floating.json')
|
||||||
for _, c in ipairs(data) do
|
for _, c in ipairs(data) do
|
||||||
ruled.client.append_rule {
|
ruled.client.append_rule {
|
||||||
rule = { class = c.WM_CLASS, instance = c.WM_INSTANCE },
|
rule = { class = c.WM_CLASS, instance = c.WM_INSTANCE },
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ local function overlay_color(col, overlay, opacity)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function bg_hover(args)
|
local function bg_hover(args)
|
||||||
args = args or {}
|
--[[ args = args or {}
|
||||||
local old_cursor, old_wibox
|
local old_cursor, old_wibox
|
||||||
|
|
||||||
local _, r, g, b, a = args.widget.bg:get_rgba()
|
local _, r, g, b, a = args.widget.bg:get_rgba()
|
||||||
@@ -117,7 +117,7 @@ local function bg_hover(args)
|
|||||||
|
|
||||||
args.widget:connect_signal('property::bg', function(_, newbg)
|
args.widget:connect_signal('property::bg', function(_, newbg)
|
||||||
r, g, b, a = hex_to_rgba(newbg)
|
r, g, b, a = hex_to_rgba(newbg)
|
||||||
end)
|
end) ]]
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ local function fg_hover(args)
|
--[[ local function fg_hover(args)
|
||||||
|
|||||||
132
awesome/src/tools/network/device.lua
Normal file
132
awesome/src/tools/network/device.lua
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
local lgi = require('lgi')
|
||||||
|
local NM = lgi.NM
|
||||||
|
local dbus_proxy = require('src.lib.lua-dbus_proxy.src.dbus_proxy')
|
||||||
|
local gtable = require('gears.table')
|
||||||
|
local gobject = require('gears.object')
|
||||||
|
|
||||||
|
local device = gobject {}
|
||||||
|
local WIRELESS = gobject {}
|
||||||
|
|
||||||
|
|
||||||
|
device.DeviceType = {
|
||||||
|
ETHERNET = 1,
|
||||||
|
WIFI = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
device.DeviceState = {
|
||||||
|
UNKNOWN = 0,
|
||||||
|
UNMANAGED = 10,
|
||||||
|
UNAVAILABLE = 20,
|
||||||
|
DISCONNECTED = 30,
|
||||||
|
PREPARE = 40,
|
||||||
|
CONFIG = 50,
|
||||||
|
NEED_AUTH = 60,
|
||||||
|
IP_CONFIG = 70,
|
||||||
|
IP_CHECK = 80,
|
||||||
|
SECONDARIES = 90,
|
||||||
|
ACTIVATED = 100,
|
||||||
|
DEACTIVATING = 110,
|
||||||
|
FAILED = 120,
|
||||||
|
}
|
||||||
|
|
||||||
|
function WIRELESS:GetAllAccessPoints()
|
||||||
|
return self.NetworkManagerDeviceWireless:GetAllAccessPoints()
|
||||||
|
end
|
||||||
|
|
||||||
|
function WIRELESS:RequestScan()
|
||||||
|
--TODO: Are options needed? What do they do?
|
||||||
|
self.NetworkManagerDeviceWireless:RequestScan {}
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(device, {
|
||||||
|
__call = function(self, device_path)
|
||||||
|
self.NetworkManagerDevice = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = 'org.freedesktop.NetworkManager',
|
||||||
|
interface = 'org.freedesktop.NetworkManager.Device',
|
||||||
|
path = device_path,
|
||||||
|
}
|
||||||
|
|
||||||
|
self.NetworkManagerDevice:connect_signal(function(_, new_state, reason)
|
||||||
|
self:emit_signal('NetworkManagerDevice::StateChanged', new_state, reason)
|
||||||
|
end, 'StateChanged')
|
||||||
|
|
||||||
|
if self.NetworkManagerDevice.DeviceType == self.DeviceType.WIFI then
|
||||||
|
|
||||||
|
gtable.crush(self, WIRELESS)
|
||||||
|
|
||||||
|
self.NetworkManagerDeviceWireless = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = 'org.freedesktop.NetworkManager',
|
||||||
|
interface = 'org.freedesktop.NetworkManager.Device.Wireless',
|
||||||
|
path = device_path,
|
||||||
|
}
|
||||||
|
self.NetworkManagerDeviceWirelessProperties = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = 'org.freedesktop.NetworkManager',
|
||||||
|
interface = 'org.freedesktop.DBus.Properties',
|
||||||
|
path = device_path,
|
||||||
|
}
|
||||||
|
|
||||||
|
self.NetworkManagerDeviceWirelessProperties:connect_signal(function(_, _, data)
|
||||||
|
if data.Birate then
|
||||||
|
self:emit_signal('NetworkManagerDeviceWireless::Bitrate', data.Bitrate)
|
||||||
|
end
|
||||||
|
if data.ActiveAccessPoint then
|
||||||
|
self.emit_signal('NetworkManagerDeviceWireless::ActiveAccessPoint', data.ActiveAccessPoint)
|
||||||
|
end
|
||||||
|
end, 'PropertiesChanged')
|
||||||
|
|
||||||
|
self.NetworkManagerDeviceWireless:connect_signal(function(_, path)
|
||||||
|
self:emit_signal('NetworkManagerDeviceWireless::AccessPointAdded', path)
|
||||||
|
end, 'AccessPointAdded')
|
||||||
|
|
||||||
|
self.NetworkManagerDeviceWireless:connect_signal(function(_, path)
|
||||||
|
self:emit_signal('NetworkManagerDeviceWireless::AccessPointRemoved', path)
|
||||||
|
end, 'AccessPointRemoved')
|
||||||
|
|
||||||
|
elseif self.NetworkManagerDevice.DeviceType == self.DeviceType.ETHERNET then
|
||||||
|
|
||||||
|
self.NetworkManagerDeviceWired = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = 'org.freedesktop.NetworkManager',
|
||||||
|
interface = 'org.freedesktop.NetworkManager.Device.Wired',
|
||||||
|
path = device_path,
|
||||||
|
}
|
||||||
|
|
||||||
|
self:emit_signal('NetworkManagerDeviceWired::Speed', self._private.NetworkManagerDeviceWired.Speed)
|
||||||
|
|
||||||
|
self.NetworkManagerDeviceWiredProperties = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = 'org.freedesktop.NetworkManager',
|
||||||
|
interface = 'org.freedesktop.DBus.Properties',
|
||||||
|
path = device_path,
|
||||||
|
}
|
||||||
|
|
||||||
|
self.NetworkManagerDeviceWiredProperties:connect_signal(function(_, _, data)
|
||||||
|
if data.Carrier then
|
||||||
|
self:emit_signal('NetworkManagerDeviceWired::Carrier', data.Carrier)
|
||||||
|
end
|
||||||
|
end, 'PropertiesChanged')
|
||||||
|
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end,
|
||||||
|
__index = function(self, key)
|
||||||
|
if key == 'DeviceType' then
|
||||||
|
return self.NetworkManagerDevice.DeviceType
|
||||||
|
elseif key == 'State' then
|
||||||
|
return self.NetworkManagerDevice.State
|
||||||
|
elseif key == 'StateReason' then
|
||||||
|
return self.NetworkManagerDevice.StateReason
|
||||||
|
elseif key == 'Bitrate' then
|
||||||
|
if self.NetworkManagerDeviceWireless then
|
||||||
|
return self.NetworkManagerDeviceWireless.Bitrate
|
||||||
|
end
|
||||||
|
elseif key == 'Managed' then
|
||||||
|
return self.NetworkManagerDevice.Managed
|
||||||
|
elseif key == 'ActiveConnection' then
|
||||||
|
return self.NetworkManagerDevice.ActiveConnection
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
128
awesome/src/tools/network/init.lua
Normal file
128
awesome/src/tools/network/init.lua
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
local lgi = require('lgi')
|
||||||
|
local gobject = require('gears.object')
|
||||||
|
|
||||||
|
local dbus_proxy = require('src.lib.lua-dbus_proxy.src.dbus_proxy')
|
||||||
|
|
||||||
|
local nmdevice = require('src.tools.network.device')
|
||||||
|
|
||||||
|
local network = gobject {}
|
||||||
|
|
||||||
|
network.NMState = {
|
||||||
|
UNKNOWN = 0,
|
||||||
|
ASLEEP = 10,
|
||||||
|
DISCONNECTED = 20,
|
||||||
|
DISCONNECTING = 30,
|
||||||
|
CONNECTING = 40,
|
||||||
|
CONNECTED_LOCAL = 50,
|
||||||
|
CONNECTED_SITE = 60,
|
||||||
|
CONNECTED_GLOBAL = 70,
|
||||||
|
}
|
||||||
|
|
||||||
|
network.DeviceType = {
|
||||||
|
ETHERNET = 1,
|
||||||
|
WIFI = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
network.DeviceState = {
|
||||||
|
UNKNOWN = 0,
|
||||||
|
UNMANAGED = 10,
|
||||||
|
UNAVAILABLE = 20,
|
||||||
|
DISCONNECTED = 30,
|
||||||
|
PREPARE = 40,
|
||||||
|
CONFIG = 50,
|
||||||
|
NEED_AUTH = 60,
|
||||||
|
IP_CONFIG = 70,
|
||||||
|
IP_CHECK = 80,
|
||||||
|
SECONDARIES = 90,
|
||||||
|
ACTIVATED = 100,
|
||||||
|
DEACTIVATING = 110,
|
||||||
|
FAILED = 120,
|
||||||
|
}
|
||||||
|
|
||||||
|
function network:toggle_network()
|
||||||
|
self._private.NetworkManager:Set('org.freedesktop.NetworkManager', 'NetworkingEnabled', lgi.GLib.Variant('b', not self.NetworkingEnabled))
|
||||||
|
end
|
||||||
|
|
||||||
|
function network:get_active_device()
|
||||||
|
for path, device in pairs(self.Devices) do
|
||||||
|
print(device.ActiveConnection, path)
|
||||||
|
if device.State == self.DeviceState.ACTIVATED then
|
||||||
|
print(device, path)
|
||||||
|
else
|
||||||
|
print('no active device')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function network:get_devices()
|
||||||
|
local devices = self.NetworkManager:GetDevices() or {}
|
||||||
|
self.Devices = {}
|
||||||
|
for _, device in ipairs(devices) do
|
||||||
|
self.Devices[device] = nmdevice(device)
|
||||||
|
self.Devices[device]:connect_signal('NetworkManagerDevice::StateChanged', function(_, s, r)
|
||||||
|
print(device, s, r)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function network:toggle_wifi()
|
||||||
|
if not self.NetworkingEnabled then
|
||||||
|
self:toggle_network()
|
||||||
|
end
|
||||||
|
self._private.NetworkManager:Set('org.freedesktop.NetworkManager', 'WirelessEnabled', lgi.GLib.Variant('b', not self.NetworkingEnabled))
|
||||||
|
end
|
||||||
|
|
||||||
|
local instance = nil
|
||||||
|
if not instance then
|
||||||
|
instance = setmetatable(network, {
|
||||||
|
__call = function(self)
|
||||||
|
self.NetworkManager = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = 'org.freedesktop.NetworkManager',
|
||||||
|
interface = 'org.freedesktop.NetworkManager',
|
||||||
|
path = '/org/freedesktop/NetworkManager',
|
||||||
|
}
|
||||||
|
|
||||||
|
self.NetworkManagerProperties = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = 'org.freedesktop.NetworkManager',
|
||||||
|
interface = 'org.freedesktop.DBus.Properties',
|
||||||
|
path = '/org/freedesktop/NetworkManager',
|
||||||
|
}
|
||||||
|
|
||||||
|
self.NetworkManagerSettings = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = 'org.freedesktop.NetworkManager',
|
||||||
|
interface = 'org.freedesktop.NetworkManager.Settings',
|
||||||
|
path = '/org/freedesktop/NetworkManager/Settings',
|
||||||
|
}
|
||||||
|
|
||||||
|
self.NetworkManager:connect_signal(function(_, device_path)
|
||||||
|
if device_path then
|
||||||
|
self:emit_signal('NetworkManager::DeviceAdded', device_path)
|
||||||
|
end
|
||||||
|
end, 'DeviceAdded')
|
||||||
|
|
||||||
|
self.NetworkManager:connect_signal(function(_, device_path)
|
||||||
|
if device_path then
|
||||||
|
self:emit_signal('NetworkManager::DeviceRemoved', device_path)
|
||||||
|
end
|
||||||
|
end, 'DeviceRemoved')
|
||||||
|
|
||||||
|
self.NetworkManagerProperties:connect_signal(function(_, _, data)
|
||||||
|
if data.WirelessEnabled ~= nil then
|
||||||
|
self.WirelessEnabled = data.WirelessEnabled
|
||||||
|
self:emit_signal('NetworkManager::WirelessEnabled', data.WirelessEnabled)
|
||||||
|
end
|
||||||
|
if data.NetworkingEnabled ~= nil then
|
||||||
|
self.NetworkingEnabled = data.NetworkingEnabled
|
||||||
|
self:emit_signal('NetworkManager::NetworkingEnabled', data.NetworkingEnabled)
|
||||||
|
end
|
||||||
|
end, 'PropertiesChanged')
|
||||||
|
|
||||||
|
self:get_devices()
|
||||||
|
self:get_active_device()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
return instance
|
||||||
Reference in New Issue
Block a user