Kasper24 / KwesomeDE

A desktop environment made in AwesomeWM
329 stars 18 forks source link

Use users's profile icon over default theme installed? #7

Closed Ryex closed 1 year ago

Ryex commented 1 year ago
diff --git a/ui/theme.lua b/ui/theme.lua
index 69480b2..f7caeb2 100644
--- a/ui/theme.lua
+++ b/ui/theme.lua
@@ -382,10 +382,31 @@ local function icons()
     end
 end

+local function pfp(default)
+    local gears = require("gears")
+    local pfp_paths = {
+       os.getenv("HOME") .. "/.face",
+       "/var/lib/AccountService/icons/" .. os.getenv("USER")
+    }
+    local face = default
+    for _, path in pairs(pfp_paths) do
+        local f = io.open(path)
+        if f then
+           f:close()
+           local img = gears.surface.load_uncached(path)
+           if img ~= nil then
+                   face = path
+                   break
+           end
+        end
+    end
+    return face
+end
+
 local function assets()
     local assets_folder = filesystem.filesystem.get_awesome_config_dir("ui/assets")

-    theme.profile_icon = assets_folder .. "profile.png"
+    theme.profile_icon = pfp(assets_folder .. "profile.png")
     theme.mountain_background = assets_folder .. "mountain.png"
     theme.overview = assets_folder .. "overview.png"
Kasper24 commented 1 year ago

I'm not sure about this. Maybe a better option would be to make it configurable via the theme manager and welcome app?

Ryex commented 1 year ago

That would be nice, but IMO it would still be preferable to at least have an option to use an icon the user has already configured.

Kasper24 commented 1 year ago

I would have the default settings value set to ~/.face