LM: new module

This commit is contained in:
李通洲
2023-06-20 23:01:18 +08:00
parent a88f603e6d
commit 68feaa2800
18 changed files with 185 additions and 2 deletions
+23
View File
@@ -0,0 +1,23 @@
#include "lm.h"
#include "common/properties.h"
#define FF_SYSTEMD_SESSIONS_PATH "/var/run/systemd/sessions/"
const char* ffDetectLM(FFLMResult* result)
{
const char* sessionId = getenv("XDG_SESSION_ID");
if (!sessionId) return "$XDG_SESSION_ID is not set";
char path[64] = FF_SYSTEMD_SESSIONS_PATH;
strncpy(path + strlen(FF_SYSTEMD_SESSIONS_PATH), sessionId, sizeof(path) - strlen(FF_SYSTEMD_SESSIONS_PATH) - 1);
// The file reads `This is private data. Do not parse`.
// What does it mean? But let's ignore it for now.
if (!ffParsePropFileValues(path, 2, (FFpropquery[]) {
{"SERVICE=", &result->service},
{"TYPE=", &result->type},
}))
return "Failed to parse /run/systemd/sessions/$XDG_SESSION_ID";
return NULL;
}