1
0
mirror of https://github.com/jiriks74/presence.nvim synced 2024-11-23 20:37:50 +01:00

feat(Flatpak): Add flatpak socket path

Look for the Flatpak socket path before normal socket lookup
Properly fixes andweeb/presence.nvim#42
This commit is contained in:
Jiří Štefka 2023-09-25 21:12:21 +02:00
parent 87c857a56b
commit a451c6b309
Signed by: jiriks74
GPG Key ID: 1D5E30D3DB2264DE

@ -391,13 +391,24 @@ function Presence:get_discord_socket_path()
"TMPDIR", "TMPDIR",
} }
for i = 1, #env_vars do local xdg_path = os.getenv("XDG_RUNTIME_DIR")
local var = env_vars[i] if xdg_path then
local path = os.getenv(var) -- Append app/com.discordapp.Discord/ to the end of the path (make sure that / is at the end of xdg_path before appending)
if path then xdg_path = xdg_path and xdg_path:match("/$") and xdg_path.."app/com.discordapp.Discord" or xdg_path.."/app/com.discordapp.Discord"
self.log:debug(string.format("Using runtime path: %s", path)) self.log:debug(string.format("Using XDG runtime path: %s", xdg_path))
sock_path = path:match("/$") and path..sock_name or path.."/"..sock_name sock_path = xdg_path:match("/$") and xdg_path..sock_name or xdg_path.."/"..sock_name
break end
-- If the socket path is still nil, check other temp directories
if not sock_path then
for i = 1, #env_vars do
local var = env_vars[i]
local path = os.getenv(var)
if path then
self.log:debug(string.format("Using runtime path: %s", path))
sock_path = path:match("/$") and path..sock_name or path.."/"..sock_name
break
end
end end
end end
end end