slstatus-kanji.diff (1514B)
1 --- a/components/kanji.c 2 +++ b/components/kanji.c 3 @@ -0,0 +1,14 @@ 4 +/* Written by Madison Lynch <madi@mxdi.xyz> */ 5 +#include <time.h> 6 + 7 +const char * 8 +kanji(const char *unused) { 9 + char *kanji[] = {"日", "月", "火", "水", "木", "金", "土"}; 10 + time_t t=time(NULL); 11 + struct tm tm=*localtime(&t); 12 + int map[]={0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}, 13 + m=tm.tm_mon+1, 14 + y=tm.tm_year+1900-(m<3), 15 + wd=(y+y/4-y/100+y/400+map[m-1]+tm.tm_mday)%7; 16 + return kanji[wd]; 17 +} 18 19 --- a/config.def.h 20 +++ b/config.def.h 21 @@ -31,6 +31,7 @@ 22 * hostname hostname NULL 23 * ipv4 IPv4 address interface name (eth0) 24 * ipv6 IPv6 address interface name (eth0) 25 + * kanji japanese day of week kanji NULL 26 * kernel_release `uname -r` NULL 27 * keyboard_indicators caps/num lock indicators format string (c?n?) 28 * see keyboard_indicators.c 29 30 --- a/Makefile 31 +++ b/Makefile 32 @@ -14,6 +14,7 @@ 33 components/entropy\ 34 components/hostname\ 35 components/ip\ 36 + components/kanji\ 37 components/kernel_release\ 38 components/keyboard_indicators\ 39 components/keymap\ 40 41 --- a/slstatus.h 42 +++ b/slstatus.h 43 @@ -31,6 +31,9 @@ 44 const char *ipv4(const char *interface); 45 const char *ipv6(const char *interface); 46 47 +/* kanji */ 48 +const char *kanji(const char *unused); 49 + 50 /* kernel_release */ 51 const char *kernel_release(const char *unused);