commit 81e63ca76aa751168955acf11d1c355c54cecb2a
Author: Madison Lynch <[email protected]>
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
@@ -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 <[email protected]>
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
@@ -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
@@ -0,0 +1,40 @@
+--- b/config.def.h
++++ a/config.def.h
+@@ -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
+@@ -14,6 +14,7 @@
+       components/entropy\
+       components/hostname\
+       components/ip\
++      components/kanji\
+       components/kernel_release\
+       components/keyboard_indicators\
+       components/keymap\
+@@ -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
+@@ -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);


Reply via email to