diff options
author | 諏訪子 <suwako@076.moe> | 2024-06-21 21:02:43 +0900 |
---|---|---|
committer | 諏訪子 <suwako@076.moe> | 2024-06-21 21:02:43 +0900 |
commit | 1b4a5a6bc4712468b4b5bfedc584f0e03728fe11 (patch) | |
tree | 370fe7fd266cd47304a2aa8380f4ae53e48c39d0 /src | |
parent | 96c5f9fdf06e7e1d944da3a1800cf9f7f00e8398 (diff) |
WM情報の追加
Diffstat (limited to 'src')
-rw-r--r-- | src/logo/colors.h | 4 | ||||
-rw-r--r-- | src/logo/freebsd.c | 4 | ||||
-rw-r--r-- | src/logo/linux.c | 4 | ||||
-rw-r--r-- | src/logo/netbsd.c | 4 | ||||
-rw-r--r-- | src/logo/openbsd.c | 4 | ||||
-rw-r--r-- | src/logo/sunos.c | 4 | ||||
-rw-r--r-- | src/resolution.c | 1 | ||||
-rw-r--r-- | src/wm.c | 37 | ||||
-rw-r--r-- | src/wm.h | 6 |
9 files changed, 66 insertions, 2 deletions
diff --git a/src/logo/colors.h b/src/logo/colors.h index 7d421f5..6d72d83 100644 --- a/src/logo/colors.h +++ b/src/logo/colors.h @@ -2,9 +2,9 @@ #define LOGO_COLORS_H #if defined(__OpenBSD__) || defined(__linux__) -#define MIN_SIZE 12 +#define MIN_SIZE 13 #else -#define MIN_SIZE 11 +#define MIN_SIZE 12 #endif #define LOGO_SIZE 24 diff --git a/src/logo/freebsd.c b/src/logo/freebsd.c index ec3926d..72ba962 100644 --- a/src/logo/freebsd.c +++ b/src/logo/freebsd.c @@ -1,6 +1,7 @@ #if defined(__FreeBSD__) #include "freebsd.h" #include "../resolution.h" +#include "../wm.h" #include <string.h> #include <stdlib.h> @@ -18,6 +19,9 @@ void getOS() { const char *res = display_resolution(); if (!res) minsize--; else free((void *)res); + const char *wm = display_wm(); + if (!wm) minsize--; + else free((void *)wm); LOGO[0] = WHITE "``` " RED "` " RESET; LOGO[1] = WHITE " ` `.....---..." RED "....--.``` -/ " RESET; diff --git a/src/logo/linux.c b/src/logo/linux.c index 6a58f7e..16931cc 100644 --- a/src/logo/linux.c +++ b/src/logo/linux.c @@ -1,6 +1,7 @@ #if defined(__linux__) #include "linux.h" #include "../resolution.h" +#include "../wm.h" #include <stdio.h> #include <string.h> @@ -17,6 +18,9 @@ void getDistro(const char *distroname) { const char *res = display_resolution(); if (!res) minsize--; else free((void *)res); + const char *wm = display_wm(); + if (!wm) minsize--; + else free((void *)wm); if (strncmp((char *)distroname, "alpine", strlen("alpine")) == 0) { color = MAGENTA; diff --git a/src/logo/netbsd.c b/src/logo/netbsd.c index 18066a5..72c8246 100644 --- a/src/logo/netbsd.c +++ b/src/logo/netbsd.c @@ -1,6 +1,7 @@ #if defined(__NetBSD__) #include "netbsd.h" #include "../resolution.h" +#include "../wm.h" #include <string.h> #include <stdlib.h> @@ -18,6 +19,9 @@ void getOS() { const char *res = display_resolution(); if (!res) minsize--; else free((void *)res); + const char *wm = display_wm(); + if (!wm) minsize--; + else free((void *)wm); LOGO[0] = MAGENTA " `-/oshdmNMNdhyo+:-` " RESET; LOGO[1] = WHITE "y" MAGENTA "/s+:-`` `.-:+oydNMMMMNhs/-`` " RESET; diff --git a/src/logo/openbsd.c b/src/logo/openbsd.c index fa59bba..8badce0 100644 --- a/src/logo/openbsd.c +++ b/src/logo/openbsd.c @@ -1,6 +1,7 @@ #if defined(__OpenBSD__) #include "openbsd.h" #include "../resolution.h" +#include "../wm.h" #include <string.h> #include <stdlib.h> @@ -18,6 +19,9 @@ void getOS() { const char *res = display_resolution(); if (!res) minsize--; else free((void *)res); + const char *wm = display_wm(); + if (!wm) minsize--; + else free((void *)wm); for (int i = 0; i < LOGO_SIZE; i++) { LOGO[i] = NULL; diff --git a/src/logo/sunos.c b/src/logo/sunos.c index de04d3a..d57825e 100644 --- a/src/logo/sunos.c +++ b/src/logo/sunos.c @@ -1,6 +1,7 @@ #if defined(__sun) #include "sunos.h" #include "../resolution.h" +#include "../wm.h" #include <string.h> #include <string.h> @@ -17,6 +18,9 @@ void getDistro(const char *distroname) { const char *res = display_resolution(); if (!res) minsize--; else free((void *)res); + const char *wm = display_wm(); + if (!wm) minsize--; + else free((void *)wm); if (strncmp((char *)distroname, "omnios", strlen("omnios")) == 0) { color = YELLOW; diff --git a/src/resolution.c b/src/resolution.c index 1438d48..2671a02 100644 --- a/src/resolution.c +++ b/src/resolution.c @@ -9,6 +9,7 @@ const char *display_resolution() { const char *display = run_command_s("echo $DISPLAY"); if (display == NULL || strlen(display) == 0) return NULL; + else free((void *)display); const char *isexist = run_command_s("which xrandr"); if ( diff --git a/src/wm.c b/src/wm.c new file mode 100644 index 0000000..9126755 --- /dev/null +++ b/src/wm.c @@ -0,0 +1,37 @@ +#include "wm.h" +#include "common.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +const char *display_wm() { +#if defined(__APPLE__) + return "Aqua"; +#else + const char *display = run_command_s("echo $DISPLAY"); + if (display == NULL || strlen(display) == 0) return NULL; + else free((void *)display); + + char cmd[512]; + const char *id = run_command_s("xprop -root -notype _NET_SUPPORTING_WM_CHECK | " + "awk '{print $5}'"); + + snprintf( + cmd, + sizeof(cmd), + "%s%s%s", + "xprop -id ", + id, + " -notype -len 100 -f _NET_WM_NAME 8t | awk '{print $3}' | head -1 | " + "sed 's/\"//g'" + ); + + free((void *)id); + + const char *wm = run_command_s(cmd); + + return wm; +#endif + return NULL; +} diff --git a/src/wm.h b/src/wm.h new file mode 100644 index 0000000..fea9a25 --- /dev/null +++ b/src/wm.h @@ -0,0 +1,6 @@ +#ifndef WM_H +#define WM_H + +const char *display_wm(); + +#endif |