fix volume problems with bluez and add dbus folder
This commit is contained in:
52
awesome/src/dbus/bluetooth_dbus.lua
Normal file
52
awesome/src/dbus/bluetooth_dbus.lua
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
local dbus_proxy = require("dbus_proxy")
|
||||||
|
local naughty = require("naughty")
|
||||||
|
|
||||||
|
return function()
|
||||||
|
|
||||||
|
local function get_device_info(self, object_path)
|
||||||
|
if object_path ~= nil and object_path:match("/org/bluez/hci0/dev") then
|
||||||
|
local device_proxy = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = "org.bluez",
|
||||||
|
interface = "org.bluez.Device1",
|
||||||
|
path = object_path
|
||||||
|
}
|
||||||
|
|
||||||
|
local bat_proxy = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = "org.bluez",
|
||||||
|
interface = "org.bluez.Battery1",
|
||||||
|
path = object_path
|
||||||
|
}
|
||||||
|
|
||||||
|
local device_properties_proxy = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = "org.bluez",
|
||||||
|
interface = "org.freedesktop.DBus.Properties",
|
||||||
|
path = object_path
|
||||||
|
}
|
||||||
|
|
||||||
|
if device_proxy.Name ~= "" and device_proxy.Name ~= nil then
|
||||||
|
--[[ device_properties_proxy:connect_signal("PropertiesChanged", function()
|
||||||
|
awesome.emit_signal(object_path .. "_updated", device_proxy)
|
||||||
|
naughty.notify({ title = "hi" })
|
||||||
|
end) ]]
|
||||||
|
naughty.notify({ title = device_proxy.Name })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local ret = dbus_proxy.Proxy:new {
|
||||||
|
bus = dbus_proxy.Bus.SYSTEM,
|
||||||
|
name = "org.bluez",
|
||||||
|
interface = "org.freedesktop.Dbus.ObjectManager",
|
||||||
|
path = "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
local objects = ret:GetManagedObjects()
|
||||||
|
|
||||||
|
for object_path, _ in pairs(objects) do
|
||||||
|
get_device_info(ret, object_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -55,7 +55,9 @@ return function(s)
|
|||||||
device:connect_signal(
|
device:connect_signal(
|
||||||
"button::press",
|
"button::press",
|
||||||
function()
|
function()
|
||||||
awful.spawn.spawn("./.config/awesome/src/scripts/vol.sh set_sink " .. node)
|
if node then
|
||||||
|
awful.spawn.spawn("./.config/awesome/src/scripts/vol.sh set_sink " .. node)
|
||||||
|
end
|
||||||
|
|
||||||
awesome.emit_signal("update::background:vol", node)
|
awesome.emit_signal("update::background:vol", node)
|
||||||
end
|
end
|
||||||
@@ -185,7 +187,9 @@ return function(s)
|
|||||||
device:connect_signal(
|
device:connect_signal(
|
||||||
"button::press",
|
"button::press",
|
||||||
function()
|
function()
|
||||||
awful.spawn.spawn("./.config/awesome/src/scripts/mic.sh set_source " .. node)
|
if node then
|
||||||
|
awful.spawn.spawn("./.config/awesome/src/scripts/mic.sh set_source " .. node)
|
||||||
|
end
|
||||||
|
|
||||||
awesome.emit_signal("update::background:mic", node)
|
awesome.emit_signal("update::background:mic", node)
|
||||||
end
|
end
|
||||||
@@ -634,25 +638,26 @@ return function(s)
|
|||||||
-- Get all source devices
|
-- Get all source devices
|
||||||
local function get_source_devices()
|
local function get_source_devices()
|
||||||
awful.spawn.easy_async_with_shell(
|
awful.spawn.easy_async_with_shell(
|
||||||
[[ pactl list sinks | grep -E 'node.name|alsa.card_name' | awk '{gsub(/"/, ""); for(i = 3;i < NF;i++) printf $i " "; print $NF}' ]],
|
[[ pactl list sinks | grep -E 'node.name|device.description|alsa.card_name' | awk '{gsub(/"/, ""); for(i = 1;i < NF;i++) printf $i " "; print $NF}' ]],
|
||||||
|
|
||||||
function(stdout)
|
function(stdout)
|
||||||
local i, j = 1, 1
|
|
||||||
local device_list = { layout = wibox.layout.fixed.vertical }
|
local device_list = { layout = wibox.layout.fixed.vertical }
|
||||||
|
local was_alsa = false
|
||||||
local node_names, alsa_names = {}, {}
|
local node_names, alsa_names = {}, {}
|
||||||
for node_name in stdout:gmatch("[^\n]+") do
|
for val in stdout:gmatch("[^\n]+") do
|
||||||
if (i % 2) == 0 then
|
if val:match("alsa%.card_name") then
|
||||||
table.insert(node_names, node_name)
|
table.insert(alsa_names, val:match("alsa%.card_name%s=%s(.*)"))
|
||||||
|
was_alsa = true
|
||||||
|
elseif val:match("device%.description") and not was_alsa then
|
||||||
|
table.insert(alsa_names, val:match("device%.description%s=%s(.*)"))
|
||||||
|
was_alsa = false
|
||||||
|
else
|
||||||
|
was_alsa = false
|
||||||
end
|
end
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
for alsa_name in stdout:gmatch("[^\n]+") do
|
if val:match("node%.name") then
|
||||||
if (j % 2) == 1 then
|
table.insert(node_names, val:match("node%.name%s=%s(.*)"))
|
||||||
table.insert(alsa_names, alsa_name)
|
|
||||||
end
|
end
|
||||||
j = j + 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for k = 1, #alsa_names, 1 do
|
for k = 1, #alsa_names, 1 do
|
||||||
@@ -668,25 +673,27 @@ return function(s)
|
|||||||
-- Get all input devices
|
-- Get all input devices
|
||||||
local function get_input_devices()
|
local function get_input_devices()
|
||||||
awful.spawn.easy_async_with_shell(
|
awful.spawn.easy_async_with_shell(
|
||||||
[[ pactl list sources | grep -E "node.name|alsa.card_name" | awk '{gsub(/"/, ""); for(i = 3;i < NF;i++) printf $i " "; print $NF}' ]],
|
[[ pactl list sources | grep -E "node.name|device.description|alsa.card_name" | awk '{gsub(/"/, ""); for(i = 1;i < NF;i++) printf $i " "; print $NF}' ]],
|
||||||
|
|
||||||
function(stdout)
|
function(stdout)
|
||||||
local i, j = 1, 1
|
|
||||||
local device_list = { layout = wibox.layout.fixed.vertical }
|
local device_list = { layout = wibox.layout.fixed.vertical }
|
||||||
|
local was_alsa = false
|
||||||
local node_names, alsa_names = {}, {}
|
local node_names, alsa_names = {}, {}
|
||||||
for node_name in stdout:gmatch("[^\n]+") do
|
|
||||||
if (i % 2) == 0 then
|
|
||||||
table.insert(node_names, node_name)
|
|
||||||
end
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
for alsa_name in stdout:gmatch("[^\n]+") do
|
for val in stdout:gmatch("[^\n]+") do
|
||||||
if (j % 2) == 1 then
|
if val:match("alsa%.card_name") then
|
||||||
table.insert(alsa_names, alsa_name)
|
table.insert(alsa_names, val:match("alsa%.card_name%s=%s(.*)"))
|
||||||
|
was_alsa = true
|
||||||
|
elseif val:match("device%.description") and not was_alsa then
|
||||||
|
table.insert(alsa_names, val:match("device%.description%s=%s(.*)"))
|
||||||
|
was_alsa = false
|
||||||
|
else
|
||||||
|
was_alsa = false
|
||||||
|
end
|
||||||
|
|
||||||
|
if val:match("node%.name") then
|
||||||
|
table.insert(node_names, val:match("node%.name%s=%s(.*)"))
|
||||||
end
|
end
|
||||||
j = j + 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for k = 1, #alsa_names, 1 do
|
for k = 1, #alsa_names, 1 do
|
||||||
|
|||||||
Reference in New Issue
Block a user