[wiki] [sites] Created "Kanji" patch/component, providing functionality to display Japanese Kanji for corresponding day of the week || Madison Lynch

From: <git_AT_suckless.org>
Date: Fri, 02 Dec 2022 01:29:00 +0100

commit 81e63ca76aa751168955acf11d1c355c54cecb2a
Author: Madison Lynch <madi_AT_mxdi.xyz>
Date: Thu Dec 1 16:23:03 2022 -0800

    Created "Kanji" patch/component, providing functionality to display Japanese Kanji for corresponding day of the week

diff --git a/tools.suckless.org/slstatus/patches/kanji/index.md b/tools.suckless.org/slstatus/patches/kanji/index.md
new file mode 100644
index 00000000..3e3908b3
--- /dev/null
+++ b/tools.suckless.org/slstatus/patches/kanji/index.md
_AT_@ -0,0 +1,17 @@
+kanji
+=====
+
+Description
+-----------
+This patch implements functionality to display the Japanese Kanji character cooresponding with the current day of the week.
+
+Move `kanji.c` into the `components/` directory. Give make the `clean` argument when compiling.
+
+Download
+--------
+* [slstatus-kanji.diff](slstatus-kanji.diff)
+* [kanji.c](kanji.c)
+
+Author
+------
+* Madison Lynch <madi_AT_mxdi.xyz>
diff --git a/tools.suckless.org/slstatus/patches/kanji/kanji.c b/tools.suckless.org/slstatus/patches/kanji/kanji.c
new file mode 100644
index 00000000..0e8cb2b0
--- /dev/null
+++ b/tools.suckless.org/slstatus/patches/kanji/kanji.c
_AT_@ -0,0 +1,26 @@
+#include <time.h>
+
+const char *
+kanji() {
+ time_t t=time(NULL);
+ struct tm tm=*localtime(&t);
+ static int map[]={0,3,2,5,0,3,5,1,4,6,2,4};
+ int m=tm.tm_mon+1,y=tm.tm_year+1900;
+ y-=m<3;
+ int weekDay=(y+y/4-y/100+y/400+map[m-1]+tm.tm_mday)%7;
+ if(weekDay==1) {
+ return "月";
+ } else if(weekDay==2) {
+ return "火";
+ } else if(weekDay==3) {
+ return "水";
+ } else if(weekDay==4) {
+ return "木";
+ } else if(weekDay==5) {
+ return "金";
+ } else if(weekDay ==6) {
+ return "土";
+ } else {
+ return "日";
+ }
+}
diff --git a/tools.suckless.org/slstatus/patches/kanji/slstatus-kanji.diff b/tools.suckless.org/slstatus/patches/kanji/slstatus-kanji.diff
new file mode 100644
index 00000000..bfced008
--- /dev/null
+++ b/tools.suckless.org/slstatus/patches/kanji/slstatus-kanji.diff
_AT_@ -0,0 +1,40 @@
+--- b/config.def.h
++++ a/config.def.h
+_AT_@ -30,6 +30,7 @@
+ * hostname hostname NULL
+ * ipv4 IPv4 address interface name (eth0)
+ * ipv6 IPv6 address interface name (eth0)
++ * kanji japanese day of week kanji NULL
+ * kernel_release `uname -r` NULL
+ * keyboard_indicators caps/num lock indicators format string (c?n?)
+ * see keyboard_indicators.c
+--- a/Makefile
++++ b/Makefile
+_AT_@ -14,6 +14,7 @@
+ components/entropy\
+ components/hostname\
+ components/ip\
++ components/kanji\
+ components/kernel_release\
+ components/keyboard_indicators\
+ components/keymap\
+_AT_@ -31,7 +32,7 @@
+
+ all: slstatus
+
+-$(COM:=.o): config.mk $(REQ:=.h) slstatus.h
++$(COM:=.o): config.mk $(REQ:=.h)
+ slstatus.o: slstatus.c slstatus.h arg.h config.h config.mk $(REQ:=.h)
+
+ .c.o:
+--- a/slstatus.h
++++ b/slstatus.h
+_AT_@ -31,6 +31,9 @@
+ const char *ipv4(const char *interface);
+ const char *ipv6(const char *interface);
+
++/* kanji */
++const char *kanji(const char *unused);
++
+ /* kernel_release */
+ const char *kernel_release(const char *unused);
Received on Fri Dec 02 2022 - 01:29:00 CET

This archive was generated by hypermail 2.3.0 : Fri Dec 02 2022 - 01:36:40 CET