mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
LM: new module
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef FF_INCLUDED_detection_lm_lm
|
||||
#define FF_INCLUDED_detection_lm_lm
|
||||
|
||||
#include "fastfetch.h"
|
||||
|
||||
typedef struct FFLMResult
|
||||
{
|
||||
FFstrbuf service;
|
||||
FFstrbuf type;
|
||||
// bool isDisplay;
|
||||
// bool remote;
|
||||
} FFLMResult;
|
||||
|
||||
const char* ffDetectLM(FFLMResult* result);
|
||||
|
||||
#endif
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "lm.h"
|
||||
|
||||
const char* ffDetectLM(FFLMResult* result)
|
||||
{
|
||||
return "Not supported on this platform";
|
||||
}
|
||||
Reference in New Issue
Block a user