modfetch/modules/desktop.c
jacekpoz d24c1d3767
big refactor of pretty much everything
I still need to make the Makefile better as it's pretty shit right now
but it's alright for now I think
2024-02-11 23:23:50 +01:00

40 lines
760 B
C

/* DESKTOP - desktop environment / window manager / compositor module for modfetch
*
* author: jacekpoz
* 09 Feb 2024
*/
#include <mod.h>
#include <stdio.h>
#include <stdlib.h>
static const semver _version = {
.major = 0,
.minor = 1,
.patch = 0,
};
semver version(void) { return _version; }
const char *name(void) { return "desktop"; }
uint8_t init(semver api_ver, char **config) {
if (!sveq(api_ver, API_VERSION)) {
return MFERR_APIVER;
}
(void)config;
return 0;
}
const char *get(void) {
char *ret;
if (asprintf(&ret, "Desktop: %s", getenv("XDG_CURRENT_DESKTOP")) < 0) {
fprintf(stderr, "error: failed formatting (this shouldn't happen)");
exit(EXIT_FAILURE);
}
return ret;
}