converted all colors to theme_config.lua; fixed and added some bugs; rewrote some stuff and added some

This commit is contained in:
Kievits Rene
2022-06-27 01:08:45 +02:00
parent 0ccd38f03a
commit b2e22fdf8a
44 changed files with 1520 additions and 767 deletions

View File

@@ -0,0 +1,135 @@
local awful = require("awful")
local gears = require("gears")
local dbus_proxy = require("dbus_proxy")
local lgi = require("lgi")
local naughty = require("naughty")
return function()
local function get_device_info(object_path)
if object_path ~= nil and object_path:match("/org/bluez/hci0/dev") then
local device = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = "org.bluez",
interface = "org.bluez.Device1",
path = object_path
}
local battery = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = "org.bluez",
interface = "org.bluez.Battery1",
path = object_path
}
local device_properties = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = "org.bluez",
interface = "org.freedesktop.DBus.Properties",
path = object_path
}
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)
end, "PropertiesChanged")
awesome.emit_signal("bluetooth::device_changed", device, battery)
end
end
end
awful.spawn.easy_async_with_shell(
"lsusb | grep Bluetooth",
function(stdout)
stdout = stdout:gsub("\n", "")
if stdout ~= "" or stdout == nil then
local ObjectManager = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = "org.bluez",
interface = "org.freedesktop.DBus.ObjectManager",
path = "/"
}
local Adapter = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = "org.bluez",
interface = "org.bluez.Adapter1",
path = "/org/bluez/hci0"
}
local AdapterProperties = dbus_proxy.Proxy:new {
bus = dbus_proxy.Bus.SYSTEM,
name = "org.bluez",
interface = "org.freedesktop.DBus.Properties",
path = "/org/bluez/hci0"
}
ObjectManager:connect_signal(
function(interface)
get_device_info(interface)
end,
"InterfacesAdded"
)
ObjectManager:connect_signal(
function(interface)
awesome.emit_signal("device_removed", interface)
end,
"InterfacesRemoved"
)
Adapter:connect_signal(
function(data)
if data.Powered ~= nil then
awesome.emit_signal("state", data.Powered)
end
end,
"PropertiesChanged"
)
awesome.connect_signal(
"bluetooth::scan",
function()
Adapter:StartDiscovery()
end
)
AdapterProperties:connect_signal(
function(data)
if data.Powered ~= nil then
if data.Powered then
Adapter:StartDiscovery()
end
end
end,
"PropertiesChanged"
)
awesome.connect_signal("toggle_bluetooth",
function()
local is_powered = Adapter.Powered
Adapter:Set(
"org.bluez.Adapter1",
"Powered",
lgi.GLib.Variant("b", not is_powered)
)
Adapter.Powered = { signature = "b", value = not is_powered }
awesome.emit_signal("state", Adapter.Powered)
end)
gears.timer.delayed_call(
function()
local objects = ObjectManager:GetManagedObjects()
for object_path, _ in pairs(objects) do
get_device_info(object_path)
end
awesome.emit_signal("state", Adapter.Powered)
end
)
end
end
)
end

View File

@@ -0,0 +1,77 @@
local awful = require("awful")
awful.spawn.with_line_callback(
[[bash -c "LC_ALL=C pactl subscribe"]],
{
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")
end
-- Device added/removed
if line:match("on server") then
awesome.emit_signal("audio::device_changed")
awesome.emit_signal("microphone::device_changed")
end
end,
output_done = function()
-- Kill the pulseaudio subscribe command to prevent it from spawning multiple instances
awful.spawn.with_shell("pkill pactl && pkill grep")
end
}
)
awesome.connect_signal(
"exit",
function()
awful.spawn.with_shell("pkill pactl && pkill grep")
end
)
awesome.connect_signal(
"audio::volume_changed",
function()
awful.spawn.easy_async_with_shell(
"./.config/awesome/src/scripts/vol.sh mute",
function(stdout)
local muted = false
if stdout:match("yes") then
muted = true
end
awful.spawn.easy_async_with_shell(
"./.config/awesome/src/scripts/vol.sh volume",
function(stdout2)
awesome.emit_signal("audio::get", muted, stdout2:gsub("%%", ""):gsub("\n", "") or 0)
end
)
end
)
end
)
awesome.connect_signal(
"microphone::volume_changed",
function()
awful.spawn.easy_async_with_shell(
"./.config/awesome/src/scripts/mic.sh mute",
function(stdout)
local muted = false
if stdout:match("yes") then
muted = true
end
awful.spawn.easy_async_with_shell(
"./.config/awesome/src/scripts/mic.sh volume",
function(stdout2)
awesome.emit_signal("microphone::get", muted, stdout2:gsub("%%", ""):gsub("\n", "") or 0)
end
)
end
)
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")

View File

@@ -0,0 +1,25 @@
local awful = require("awful")
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 = math.floor(BACKLIGHT_SEPS)
end
)
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")
end
)
end
)

View File

@@ -4,3 +4,5 @@ require("src.tools.helpers.cpu_freq")
require("src.tools.helpers.ram")
require("src.tools.helpers.gpu_usage")
require("src.tools.helpers.gpu_temp")
require("src.tools.helpers.audio")
--require("src.tools.helpers.backlight")

View File

@@ -19,13 +19,13 @@ local function get_basedir()
if gears.filesystem.dir_readable(dir) then table.insert(dirs, dir) end
for _, value in ipairs(GLib.get_system_data_dirs()) do
dir = GLib.build_filenamev({ value, ".icons" })
dir = GLib.build_filenamev({ value, "icons" })
if gears.filesystem.dir_readable(dir) then table.insert(dirs, dir) end
end
local need_usr_share_pixmaps = true
for _, value in ipairs(GLib.get_system_data_dirs()) do
dir = GLib.build_filenamev({ value, ".icons" })
dir = GLib.build_filenamev({ value, "icons" })
if gears.filesystem.dir_readable(dir) then table.insert(dirs, dir) end
if dir == "/usr/share/pixmaps" then
need_usr_share_pixmaps = false
@@ -38,8 +38,6 @@ local function get_basedir()
table.insert(dirs, dir)
end
table.insert(dirs, "/usr/share/icons")
return dirs
end
@@ -186,6 +184,9 @@ local function find_icon_helper(self, icon, size)
if filename then return filename end
for _, parent in ipairs(self.theme_index:get_inherits()) do
if parent == "hicolor" then
return
end
filename = find_icon_helper(xdg_icon_lookup(parent, self.base_directories), icon, size)
if filename then return filename end
end
@@ -199,10 +200,10 @@ local iconcache = {}
---@param size any
---@return string path_to_icon
function xdg_icon_lookup:find_icon(icon, size)
if iconcache[icon] then
return iconcache[icon]
end
size = size or 64
if icon_cache[icon] == "" then return nil end
if iconcache[icon] then return iconcache[icon] end
if not icon or icon == "" then return nil end
local filename = find_icon_helper(self, icon, size)
@@ -223,10 +224,8 @@ function xdg_icon_lookup:find_icon(icon, size)
return filename
end
local fallback = gears.color.recolor_image(require("awful").util.getdir("config") .. "src/assets/icons/fallback.svg",
"#ffffff")
iconcache[icon] = fallback
return fallback
iconcache[icon] = ""
return nil
end
xdg_icon_lookup.mt.__call = function(_, ...)