summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/exofetch.c39
1 files changed, 3 insertions, 36 deletions
diff --git a/tools/exofetch.c b/tools/exofetch.c
index bc5548a..826464d 100644
--- a/tools/exofetch.c
+++ b/tools/exofetch.c
@@ -10,48 +10,16 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <locale.h>
-
-#define SHMNAME "/breathing_color_shm"
-
-typedef struct {
- uint32_t seq;
- char color[8];
-} ColorShm;
+#include "../accent.h"
static ColorShm *accentshm;
static char accentcol[8] = "#005577";
-static int
-openaccent(void)
-{
- int fd;
- if (accentshm)
- return 0;
- if ((fd = shm_open(SHMNAME, O_RDONLY, 0)) < 0)
- return -1;
- accentshm = mmap(NULL, sizeof(ColorShm), PROT_READ, MAP_SHARED, fd, 0);
- close(fd);
- if (accentshm == MAP_FAILED) {
- accentshm = NULL;
- return -1;
- }
- return 0;
-}
-
static void
updateaccent(void)
{
- uint32_t s1, s2;
- char tmp[8];
- if (!accentshm && openaccent() < 0)
- return;
- do {
- s1 = accentshm->seq;
- memcpy(tmp, accentshm->color, 8);
- s2 = accentshm->seq;
- } while (s1 != s2);
- if (tmp[0] == '#')
- memcpy(accentcol, tmp, 8);
+ if (!readaccent(&accentshm, accentcol))
+ memcpy(accentcol, "#005577", 8);
}
static void
@@ -127,7 +95,6 @@ int
main(void)
{
setlocale(LC_ALL, "");
- openaccent();
updateaccent();
int r, g, b;
hex2rgb(accentcol, &r, &g, &b);