rewrote a lot of stuff especially the bluetooth module. fixed some errors

This commit is contained in:
Rene Kievits
2022-09-21 21:10:17 +02:00
parent 3d8b240ef0
commit b5c6dc31f7
59 changed files with 1138 additions and 334 deletions

View File

@@ -2,7 +2,10 @@ local awful = require("awful")
local gears = require("gears")
local dbus_proxy = require("dbus_proxy")
local lgi = require("lgi")
local naughty = require("naughty")
local capi = {
awesome = awesome,
}
return function()
@@ -28,12 +31,13 @@ return function()
interface = "org.freedesktop.DBus.Properties",
path = object_path
}
awesome.emit_signal("bluetooth::scan")
if device.Name ~= nil or device.Alias ~= nil then
capi.awesome.emit_signal("bluetooth::scan")
if (device.Name ~= nil) or (device.Alias ~= nil) then
device_properties:connect_signal(function()
awesome.emit_signal("bluetooth::device_changed", device, battery)
capi.awesome.emit_signal("bluetooth::device_changed", device, battery)
end, "PropertiesChanged")
awesome.emit_signal("bluetooth::device_changed", device, battery)
capi.awesome.emit_signal("bluetooth::device_changed", device, battery)
end
end
end
@@ -73,7 +77,7 @@ return function()
ObjectManager:connect_signal(
function(interface)
awesome.emit_signal("device_removed", interface)
capi.awesome.emit_signal("device_removed", interface)
end,
"InterfacesRemoved"
)
@@ -81,13 +85,13 @@ return function()
Adapter:connect_signal(
function(data)
if data.Powered ~= nil then
awesome.emit_signal("state", data.Powered)
capi.awesome.emit_signal("state", data.Powered)
end
end,
"PropertiesChanged"
)
awesome.connect_signal(
capi.awesome.connect_signal(
"bluetooth::scan",
function()
Adapter:StartDiscovery()
@@ -105,7 +109,7 @@ return function()
"PropertiesChanged"
)
awesome.connect_signal("toggle_bluetooth",
capi.awesome.connect_signal("toggle_bluetooth",
function()
local is_powered = Adapter.Powered
Adapter:Set(
@@ -114,7 +118,7 @@ return function()
lgi.GLib.Variant("b", not is_powered)
)
Adapter.Powered = { signature = "b", value = not is_powered }
awesome.emit_signal("state", Adapter.Powered)
capi.awesome.emit_signal("state", Adapter.Powered)
end)
gears.timer.delayed_call(
@@ -125,7 +129,7 @@ return function()
get_device_info(object_path)
end
awesome.emit_signal("state", Adapter.Powered)
capi.awesome.emit_signal("state", Adapter.Powered)
end
)
end

View File

@@ -15,8 +15,9 @@ Gtk.IconTheme.set_custom_theme(gtk_theme, User_config.icon_theme)
---Gets the icon path from an AppInfo gicon.
---@param app Gio.AppInfo
---@return string path
---@return string|nil path
function Get_gicon_path(app)
if not app then return end
local icon_info = gtk_theme:lookup_by_gicon(app, 64, 0)
if icon_info then
local path = icon_info:get_filename()

View File

@@ -1,5 +1,9 @@
local awful = require("awful")
local capi = {
awesome = awesome,
}
--[[ local lgi = require("lgi")
local pulseaudio = require("lua_libpulse_glib")
local ppretty = require("pl.ppretty")
@@ -24,13 +28,13 @@ awful.spawn.with_line_callback(
stdout = function(line)
-- Volume changed
if line:match("on sink") or line:match("on source") then
awesome.emit_signal("audio::volume_changed")
awesome.emit_signal("microphone::volume_changed")
capi.awesome.emit_signal("audio::volume_changed")
capi.awesome.emit_signal("microphone::volume_changed")
end
-- Device added/removed
if line:match("on server") then
awesome.emit_signal("audio::device_changed")
awesome.emit_signal("microphone::device_changed")
capi.awesome.emit_signal("audio::device_changed")
capi.awesome.emit_signal("microphone::device_changed")
end
end,
output_done = function()
@@ -40,14 +44,14 @@ awful.spawn.with_line_callback(
}
)
awesome.connect_signal(
capi.awesome.connect_signal(
"exit",
function()
awful.spawn.with_shell("pkill pactl && pkill grep")
end
)
awesome.connect_signal(
capi.awesome.connect_signal(
"audio::volume_changed",
function()
awful.spawn.easy_async_with_shell(
@@ -66,7 +70,7 @@ awesome.connect_signal(
if stdout == "" or stdout == nil then
return
end
awesome.emit_signal("audio::get", muted, stdout2:gsub("%%", ""):gsub("\n", "") or 0)
capi.awesome.emit_signal("audio::get", muted, stdout2:gsub("%%", ""):gsub("\n", "") or 0)
end
)
end
@@ -74,7 +78,7 @@ awesome.connect_signal(
end
)
awesome.connect_signal(
capi.awesome.connect_signal(
"microphone::volume_changed",
function()
awful.spawn.easy_async_with_shell(
@@ -90,7 +94,7 @@ awesome.connect_signal(
if stdout2 == nil or stdout2 == "awful" then
return
end
awesome.emit_signal("microphone::get", muted, stdout2:gsub("%%", ""):gsub("\n", "") or 0)
capi.awesome.emit_signal("microphone::get", muted, stdout2:gsub("%%", ""):gsub("\n", "") or 0)
end
)
end
@@ -98,7 +102,7 @@ awesome.connect_signal(
end
)
awesome.emit_signal("audio::volume_changed")
awesome.emit_signal("microphone::volume_changed")
awesome.emit_signal("audio::device_changed")
awesome.emit_signal("microphone::device_changed")
capi.awesome.emit_signal("audio::volume_changed")
capi.awesome.emit_signal("microphone::volume_changed")
capi.awesome.emit_signal("audio::device_changed")
capi.awesome.emit_signal("microphone::device_changed")

View File

@@ -1,25 +1,32 @@
local awful = require("awful")
local capi = {
awesome = awesome,
}
BACKLIGHT_MAX_BRIGHTNESS = 0
BACKLIGHT_SEPS = 0
awful.spawn.easy_async_with_shell(
"pkexec xfpm-power-backlight-helper --get-max-brightness",
function(stdout)
BACKLIGHT_MAX_BRIGHTNESS = tonumber(stdout)
BACKLIGHT_SEPS = BACKLIGHT_MAX_BRIGHTNESS / 100
BACKLIGHT_SEPS = BACKLIGHT_MAX_BRIGHTNESS / 100 * 2
BACKLIGHT_SEPS = math.floor(BACKLIGHT_SEPS)
end
)
awesome.connect_signal(
capi.awesome.connect_signal(
"brightness::update",
function()
awful.spawn.easy_async_with_shell(
"pkexec xfpm-power-backlight-helper --get-brightness",
function(value)
awesome.emit_signal("brightness::get", math.floor((tonumber(value) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100))
awesome.emit_signal("brightness::rerun")
capi.awesome.emit_signal("brightness::get",
math.floor((tonumber(value) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100))
capi.awesome.emit_signal("brightness::rerun")
end
)
end
)
capi.awesome.emit_signal("brightness::update")

View File

@@ -1,6 +1,10 @@
local awful = require("awful")
local watch = awful.widget.watch
local capi = {
awesome = awesome,
}
watch(
[[ bash -c "cat /proc/cpuinfo | grep "MHz" | awk '{print int($4)}'" ]],
3,
@@ -18,9 +22,9 @@ watch(
average = average + cpu_freq[i]
end
average = math.floor(average / #cpu_freq)
awesome.emit_signal("update::cpu_freq_average", average)
capi.awesome.emit_signal("update::cpu_freq_average", average)
elseif User_config.clock_mode then
awesome.emit_signal("update::cpu_freq_core", cpu_freq[User_config.clock_mode])
capi.awesome.emit_signal("update::cpu_freq_core", cpu_freq[User_config.clock_mode])
end
end
)

View File

@@ -1,6 +1,10 @@
local awful = require("awful")
local watch = awful.widget.watch
local capi = {
awesome = awesome,
}
watch(
[[ bash -c "sensors | grep 'Package id 0:' | awk '{print $4}'" ]],
3,
@@ -11,14 +15,14 @@ watch(
"paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp)",
function(stdout2)
temp = math.floor((tonumber(stdout2:match("x86_pkg_temp(.%d+)")) / 1000) + 0.5)
awesome.emit_signal(
capi.awesome.emit_signal(
"update::cpu_temp",
temp
)
end
)
else
awesome.emit_signal(
capi.awesome.emit_signal(
"update::cpu_temp",
temp
)

View File

@@ -1,6 +1,10 @@
local awful = require("awful")
local watch = awful.widget.watch
local capi = {
awesome = awesome,
}
local total_prev = 0
local idle_prev = 0
@@ -18,7 +22,7 @@ watch(
local diff_total = total - total_prev
local diff_usage = math.floor(((1000 * (diff_total - diff_idle) / diff_total + 5) / 10) + 0.5)
awesome.emit_signal("update::cpu_usage", diff_usage)
capi.awesome.emit_signal("update::cpu_usage", diff_usage)
total_prev = total
idle_prev = idle

View File

@@ -1,10 +1,14 @@
local awful = require("awful")
local watch = awful.widget.watch
local capi = {
awesome = awesome,
}
watch(
[[ bash -c "nvidia-smi -q -d TEMPERATURE | grep 'GPU Current Temp' | awk '{print $5}'"]],
3,
function(_, stdout)
awesome.emit_signal("update::gpu_temp", stdout:match("%d+"):gsub("\n", ""))
capi.awesome.emit_signal("update::gpu_temp", stdout:match("%d+"):gsub("\n", ""))
end
)

View File

@@ -1,11 +1,15 @@
local awful = require("awful")
local watch = awful.widget.watch
local capi = {
awesome = awesome,
}
watch(
[[ bash -c "nvidia-smi -q -d UTILIZATION | grep Gpu | awk '{print $3}'"]],
3,
function(_, stdout)
stdout = stdout:match("%d+")
awesome.emit_signal("update::gpu_usage", stdout)
capi.awesome.emit_signal("update::gpu_usage", stdout)
end
)

View File

@@ -9,7 +9,6 @@ local awful = require("awful")
local gobject = require("gears.object")
local gtable = require("gears.table")
local gtimer = require("gears.timer")
local helpers = require("helpers")
local dbus_proxy = require("services.dbus_proxy")
local network = {}

View File

@@ -5,6 +5,10 @@ local gtable = require("gears.table")
local gtimer = require("gears.timer")
local gstring = require("gears.string")
local capi = {
awesome = awesome
}
local playerctl = { mt = {} }
playerctl._private = {}
@@ -76,7 +80,7 @@ local function emit_metadata_callback(self, title, artist, art_url, album, new,
if not art_url or art_url == "" then
else
awesome.emit_signal("playerctl::title_artist_album", title, artist, "", player_name)
capi.awesome.emit_signal("playerctl::title_artist_album", title, artist, "", player_name)
self:emit_signal("metadata", title, artist, "", album, new, player_name)
end
end
@@ -145,10 +149,10 @@ local function playback_status_callback(self, player, status)
if status == "PLAYING" then
self:emit_signal("playerctl::playback_status", true, player.player_name)
awesome.emit_signal("playerctl::playback_status", true, player.player_name)
capi.awesome.emit_signal("playerctl::playback_status", true, player.player_name)
else
self:emit_signal("playerctl::playback_status", false, player.player_name)
awesome.emit_signal("playerctl::playback_status", false, player.player_name)
capi.awesome.emit_signal("playerctl::playback_status", false, player.player_name)
end
end
end
@@ -308,7 +312,7 @@ local function start_manager(self)
_self._private.metadata_timer:stop()
_self._private.pos_timer:stop()
_self:emit_signal("playerctl::noplayers")
awesome.emit_signal("playerctl::noplayers")
capi.awesome.emit_signal("playerctl::noplayers")
elseif player == _self._private.active_player then
_self._private.active_player = self.players[1]
get_current_player(_self, _self._private.active_player)

View File

@@ -1,11 +1,15 @@
local awful = require("awful")
local watch = awful.widget.watch
local capi = {
awesome = awesome,
}
watch(
[[ bash -c "cat /proc/meminfo| grep Mem | awk '{print $2}'" ]],
3,
function(_, stdout)
local MemTotal, MemFree, MemAvailable = stdout:match("(%d+)\n(%d+)\n(%d+)\n")
awesome.emit_signal("update::ram_widget", MemTotal, MemFree, MemAvailable)
capi.awesome.emit_signal("update::ram_widget", MemTotal, MemFree, MemAvailable)
end
)