summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoRo <dos21h@gmail.com>2020-04-05 16:31:20 +0100
committerZoRo <dos21h@gmail.com>2020-04-05 16:31:20 +0100
commitde58c2e89c6d38ae21e12b83902defa171b0b635 (patch)
tree632d661b8f3eb686bfd1788e7148044ef1fe8431
downloaddwmstatus-pixel-master.tar.gz
dwmstatus-pixel-master.zip
Updated font ascii/utf8HEADmaster
-rw-r--r--Kconfig38
-rw-r--r--Makefile44
-rw-r--r--README.md37
-rw-r--r--debug/Kconfig24
-rw-r--r--debug/debug.h66
-rw-r--r--dwmstatus.c121
-rw-r--r--dwmstatus.h36
-rw-r--r--kconf2h/kconf2h.c50
-rw-r--r--kconf2h/kconf2h.h10
-rw-r--r--kconf2h/kconf2h_parser.c327
-rw-r--r--kconfig.h13
-rw-r--r--status/Kconfig31
-rw-r--r--status/batt.c144
-rw-r--r--status/cpu.c77
-rw-r--r--status/date.c39
-rw-r--r--status/make.mk5
-rw-r--r--status/temp.c74
-rw-r--r--status/time.c59
18 files changed, 1195 insertions, 0 deletions
diff --git a/Kconfig b/Kconfig
new file mode 100644
index 0000000..7f69c12
--- /dev/null
+++ b/Kconfig
@@ -0,0 +1,38 @@
+source "debug/Kconfig"
+source "status/Kconfig"
+
+choice
+ prompt "Formating mode"
+ help
+ Choose different formating modes for
+
+ config STATUS_FMT_NONE
+ bool "No formating"
+
+ config STATUS_FMT_COLOR
+ bool "Simple escape sequence formating"
+
+ config STATUS_FMT_PANGO
+ bool "Set formating for pango"
+
+endchoice
+
+choice
+ prompt "ASCII/UTF8"
+
+ config STATUS_ASCII
+ bool "ASCII text"
+
+ config STATUS_UTF8
+ bool "UTF8 icons"
+
+endchoice
+
+choice
+ prompt "Debug"
+ config DEBUG_NONE
+ bool "No debug"
+ config DEBUG_MODE
+ bool "ASSERT type debuging"
+endchoice
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1b3ac07
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+CC=clang
+CFLAGS=-I.
+LDFLAGS=-lX11
+SRC= dwmstatus.c status/time.c status/date.c status/temp.c status/batt.c status/cpu.c
+OBJ= ${SRC:.c=.o}
+
+
+#include status/make.mk
+
+
+.c.o:
+ @echo CC $<
+ @${CC} ${CFLAGS} -o $@ -c $<
+
+dwmstatus: ${OBJ}
+ @echo CC -o $@
+ @${CC} -o $@ ${OBJ} ${LDFLAGS}
+
+
+kconfig2h:
+ $(CC) -c kconf2h/kconf2h_parser.c
+ $(CC) kconf2h/kconf2h.c kconf2h_parser.o -o kconf2h/kconf2h
+
+menuconfig: kconfig2h
+ ./mconf Kconfig
+ kconf2h/kconf2h .config kconfig.h
+
+leak:
+ valgrind --leak-check=full --time-stamp=yes --track-origins=yes --log-file=log.txt ./dwmstatus
+
+pack: dwmstatus
+ strip ./dwmstatus
+ upx ./dwmstatus
+
+clean:
+ rm -rf dwmstatus
+ rm -rf *.o
+ rm -rf status/*.o
+
+test:
+ DISPLAY=:1.0
+ xinit ./dwm $* -- :1
+
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b1593fd
--- /dev/null
+++ b/README.md
@@ -0,0 +1,37 @@
+dwmstatus-fancy
+===============
+
+INTRO
+=====
+
+dwmstatus with additions
+configurable with linux kernel kconfig
+with coloring if you use dwm+pango patch
+
+Install
+=======
+cp font/icons.fft /use/share/fonts/FFT
+fc-cache
+
+Statuses
+========
+
+ temperature
+
+ time
+
+ date
+
+ cpu
+
+ battery status
+
+Plans
+=====
+
+In future planning some notification text could be showed, from
+UNIX socket, then plugins daemons can send to dwmstatus some
+info.
+
+More statuses that could be added is : network interfaces and ip's,
+network usage, uptime, harddrive usage
diff --git a/debug/Kconfig b/debug/Kconfig
new file mode 100644
index 0000000..21dae6d
--- /dev/null
+++ b/debug/Kconfig
@@ -0,0 +1,24 @@
+menuconfig DEBUG
+ bool "Enable debug output"
+ option debug
+
+if DEBUG
+config DEBUG_PRINT_DEBUG
+ bool "Print debug"
+ default y
+
+config DEBUG_COLORIZE
+ bool "Colorize output"
+ default n
+ depends on DEBUG_PRINT_DEBUG
+
+config DEBUG_PRINT_LINENUM
+ bool "Print line number in debug"
+ default n
+ depends on DEBUG_PRINT_DEBUG
+
+config DEBUG_PRINT_FILENAME
+ bool "Print file name in debug"
+ default n
+ depends on DEBUG_PRINT_DEBUG
+endif
diff --git a/debug/debug.h b/debug/debug.h
new file mode 100644
index 0000000..b030fbe
--- /dev/null
+++ b/debug/debug.h
@@ -0,0 +1,66 @@
+#ifndef __RB_DEBUG_UTILS_H
+#define __RB_DEBUG_UTILS_H
+
+
+//what about kprintf?
+
+//config options
+#define PRINTF printf
+//#define COLORIZE
+//#define PRINT_LINENUM
+//#define PRINT_FILENAME
+//#define PRINT_DEBUG
+
+
+//use color
+#ifdef CONFIG_DEBUG_COLORIZE
+ #define D_COLOR "1;32m"
+ #define D_COLOR_S "\033[" D_COLOR
+ #define D_COLOR_E "\033[0m"
+ #define E_COLOR "1;31m"
+ #define E_COLOR_S "\033[" E_COLOR
+ #define E_COLOR_E "\033[0m"
+#else
+ #define D_COLOR
+ #define D_COLOR_S
+ #define D_COLOR_E
+ #define E_COLOR
+ #define E_COLOR_S
+ #define E_COLOR_E
+#endif
+
+//print debug line
+#ifdef CONFIG_DEBUG_PRINT_LINENUM
+ #define PRINT_LINE_F "LINE:%d "
+ #define PRINT_LINE_D __LINE__
+#else
+ #define PRINT_LINE_F ""
+ #define PRINT_LINE_D ""
+#endif
+
+//print
+#ifdef CONFIG_DEBUG_PRINT_FILENAME
+ #define PRINT_FILE_F "FILE:%s "
+ #define PRINT_FILE_D __FILE__
+#else
+ #define PRINT_FILE_F ""
+ #define PRINT_FILE_D ""
+#endif
+
+//print debug string
+#ifdef CONFIG_DEBUG_PRINT_DEBUG
+ #define PRINT_DEBUG_F "Debug: "
+#else
+ #define PRINT_DEBUG_F ""
+#endif
+
+#define PRINT( format, args ... ) PRINTF( D_COLOR_S PRINT_DEBUG_F \
+ PRINT_FILE_F PRINT_LINE_F format D_COLOR_E, PRINT_FILE_D, \
+ PRINT_LINE_D, ##args);
+
+#define ERROR( format, args ... ) PRINTF( E_COLOR_S PRINT_DEBUG_F \
+ PRINT_FILE_F PRINT_LINE_F format E_COLOR_E, PRINT_FILE_D, \
+ PRINT_LINE_D, ##args);
+
+
+#endif
diff --git a/dwmstatus.c b/dwmstatus.c
new file mode 100644
index 0000000..1cb707d
--- /dev/null
+++ b/dwmstatus.c
@@ -0,0 +1,121 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <X11/Xlib.h>
+
+#include "kconfig.h"
+#include "dwmstatus.h"
+
+static Display *dpy;
+
+
+int
+stradd( bbuf *a, bbuf *b )
+{
+ int i=0,j=0;
+ for ( i=0;
+ i<a->size-1, a->str[i]!='\0';
+ i++){}
+
+ for (j=0;
+ (i+j)<a->size-1, j<b->size-1;
+ j++)
+ {
+ a->str[i+j] = b->str[j];
+ }
+ return 0;
+}
+
+void
+setstatus(char *str)
+{
+ XStoreName(dpy, DefaultRootWindow(dpy), str);
+ XSync(dpy, False);
+}
+
+int main( int argc, char **argv )
+{
+ int cmd_status=0;
+
+ int i=0;
+ for (i=1; i<argc; i++ )
+ {
+ if ( strncmp( argv[i], "-t", 2 ) == 0 )
+ cmd_status = 1;
+ if ( strncmp( argv[i], "-h", 2) == 0)
+ {
+ printf("Help\n-t : run in terminal mode\n");
+ return 0;
+ }
+ }
+
+#ifdef CONFIG_STATUS_UTF8
+ setlocale( LC_CTYPE, "" );
+#endif
+ //char *status=NULL;
+ bbuf status; memset( &status, 0, sizeof(status) );
+ bbuf time; memset( &time, 0, sizeof(time) );
+ bbuf date; memset( &date, 0, sizeof(date) );
+ bbuf temp; memset( &temp, 0, sizeof(temp) );
+ bbuf cpu; memset( &cpu, 0, sizeof(cpu) );
+ bbuf batt; memset( &batt, 0, sizeof(batt) );
+
+ if (status.size == 0)
+ {
+ status.size = 1024;
+ status.str = malloc( status.size );
+ memset( status.str, 0, status.size );
+ }
+
+ //if cannot open display maybe we are in terminal but we ignore it
+ //while there was no direct command to workin in terminal we dont
+ //run programm in terminal mode
+ if (!(dpy = XOpenDisplay(NULL)))
+ {
+ printf("cannot open display.\n");
+ return -1;
+ }
+
+ for (;;sleep(1))
+ {
+ status.str[0]=0;
+
+ #ifdef CONFIG_STATUS_BATTERY
+ print_batt( &batt );
+ stradd( &status, &batt );
+ #endif
+
+ #ifdef CONFIG_STATUS_CPU
+ print_cpu( &cpu );
+ stradd( &status, &cpu );
+ #endif
+
+ #ifdef CONFIG_STATUS_TEMP
+ print_temp( &temp );
+ stradd( &status, &temp );
+ #endif
+
+ #ifdef CONFIG_STATUS_TIME
+ print_time( &time );
+ stradd( &status, &time );
+ #endif
+
+ #ifdef CONFIG_STATUS_DATE
+ print_date( &date );
+ stradd( &status, &date );
+ #endif
+
+ if ( cmd_status == 1)
+ {
+ wprintf(L"%s\n", status.str);
+ }
+ else
+ {
+ setstatus(status.str);
+ }
+ }
+
+ XCloseDisplay(dpy);
+
+ return 0;
+}
diff --git a/dwmstatus.h b/dwmstatus.h
new file mode 100644
index 0000000..23a2951
--- /dev/null
+++ b/dwmstatus.h
@@ -0,0 +1,36 @@
+#ifndef __DWMSTATUS_H
+#define __DWMSTATUS_H
+
+#include "kconfig.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <time.h>
+#include <errno.h>
+
+#ifdef CONFIG_STATUS_UTF8
+#include <locale.h>
+#include <wchar.h>
+#endif
+
+#ifdef CONFIG_DEBUG_MODE
+#include <assert.h>
+#define ASSERT assert
+#else
+#define ASSERT(X)
+#endif
+
+typedef struct bbuf
+{
+ int size;
+ char *str;
+} bbuf;
+
+int print_date( bbuf* );
+int print_time( bbuf* );
+int print_temp( bbuf* );
+int print_batt( bbuf* );
+int print_cpu( bbuf* );
+
+#endif
diff --git a/kconf2h/kconf2h.c b/kconf2h/kconf2h.c
new file mode 100644
index 0000000..91ef6c7
--- /dev/null
+++ b/kconf2h/kconf2h.c
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/stat.h>
+
+#include "kconf2h.h"
+
+int main( int argc, char **argv )
+{
+ FILE *fin = NULL;
+ FILE *fout = NULL;
+ struct stat st;
+
+ char *buf=NULL;
+ if ( argc == 3 )
+ {
+ fin = fopen( argv[1], "r+" );
+ fout = fopen( argv[2], "w+" );
+ fseek( fin, 0, SEEK_SET );
+ if ( fin && fout )
+ {
+ if ( stat( argv[1], &st ) )
+ {
+ goto error_exit;
+ }
+ buf = malloc( st.st_size ); memset( buf, 0, st.st_size );
+ size_t r_size = fread( buf, 1, st.st_size, fin );
+ if ( r_size > 0 )
+ {
+ int ret = parse_kconf2h( buf, fout );
+ printf("Kconfig file parsed %d %d bytes\n", ret, r_size );
+ } else
+ {
+ printf("ERR: while reading file %s [%d]\n", argv[1], r_size);
+ }
+error_exit:
+ if ( buf ) free( buf );
+ fclose( fin );
+ fclose( fout );
+ } else
+ {
+ printf("ERR: Cannot open file\n");
+ }
+ } else
+ {
+ printf("ERR: usage ./kconf2h [conffile] [outputheader]\n");
+ return -1;
+ }
+ return 0;
+}
diff --git a/kconf2h/kconf2h.h b/kconf2h/kconf2h.h
new file mode 100644
index 0000000..165d4cc
--- /dev/null
+++ b/kconf2h/kconf2h.h
@@ -0,0 +1,10 @@
+#ifndef __KCONF2H_H
+#define __KCONF2H_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int parse_kconf2h( const char*, FILE* );
+
+#endif
diff --git a/kconf2h/kconf2h_parser.c b/kconf2h/kconf2h_parser.c
new file mode 100644
index 0000000..5269c14
--- /dev/null
+++ b/kconf2h/kconf2h_parser.c
@@ -0,0 +1,327 @@
+
+#line 1 "kconf2h_parser.ragel"
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "kconf2h.h"
+
+#define TYPE_YM 1
+#define TYPE_HEX 2
+#define TYPE_STR 3
+#define TYPE_DEC 4
+
+char *new_string( const char *start, const char *end )
+{
+ int str_s = end-start+1;
+ char *new_str=malloc( str_s+1 );
+ memcpy( new_str, start, str_s );
+ if ( new_str != NULL )
+ new_str[str_s]=0x0;
+ return new_str;
+}
+
+int o_head_def( FILE *f, int type, const char *s_define, const char *e_define,
+ const char *s_value, const char *e_value )
+{
+ if ( f != NULL )
+ {
+ if ( (s_define != NULL) && (e_define != NULL) && (s_define <= e_define) &&
+ (s_value != NULL) && ( e_value != NULL ) && ( s_value <= e_value ))
+ {
+ char *def = new_string( s_define, e_define );
+ char *val = NULL;
+ //printf( "%s\n", def );
+ fprintf( f, "#define %s", def );
+ free( def );
+
+ if ( type != TYPE_YM )
+ {
+ val = new_string( s_value, e_value );
+ fprintf( f, " %s", val );
+ free( val );
+ }
+ /*
+ switch ( type )
+ {
+ case TYPE_HEX:
+ fprintf( f, " %s", val );
+ break;
+ case TYPE_STR:
+ fprintf( f, " %s", val );
+ break;
+ case TYPE_DEC:
+ fprintf( f, " %s", val );
+ break;
+ default:
+ printf("Unknown Kconfig type %d\n", type);
+ }
+ */
+
+ fprintf( f, "\n" );
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+#line 71 "kconf2h_parser.c"
+static const char _k2h_actions[] = {
+ 0, 1, 0, 1, 2, 1, 7, 1,
+ 11, 2, 9, 1, 4, 3, 8, 10,
+ 11, 4, 4, 8, 10, 11, 4, 5,
+ 8, 10, 11, 4, 6, 8, 10, 11
+
+};
+
+static const char _k2h_key_offsets[] = {
+ 0, 0, 3, 6, 7, 8, 9, 10,
+ 11, 12, 17, 23, 30, 33, 37, 39,
+ 42, 46, 52, 59, 60
+};
+
+static const char _k2h_trans_keys[] = {
+ 10, 35, 67, 10, 32, 126, 79, 78,
+ 70, 73, 71, 95, 95, 48, 57, 65,
+ 90, 61, 95, 48, 57, 65, 90, 34,
+ 45, 48, 109, 121, 49, 57, 34, 32,
+ 126, 10, 34, 32, 126, 48, 57, 10,
+ 48, 57, 10, 120, 48, 57, 48, 57,
+ 65, 70, 97, 102, 10, 48, 57, 65,
+ 70, 97, 102, 10, 10, 35, 67, 0
+};
+
+static const char _k2h_single_lengths[] = {
+ 0, 3, 1, 1, 1, 1, 1, 1,
+ 1, 1, 2, 5, 1, 2, 0, 1,
+ 2, 0, 1, 1, 3
+};
+
+static const char _k2h_range_lengths[] = {
+ 0, 0, 1, 0, 0, 0, 0, 0,
+ 0, 2, 2, 1, 1, 1, 1, 1,
+ 1, 3, 3, 0, 0
+};
+
+static const char _k2h_index_offsets[] = {
+ 0, 0, 4, 7, 9, 11, 13, 15,
+ 17, 19, 23, 28, 35, 38, 42, 44,
+ 47, 51, 55, 60, 62
+};
+
+static const char _k2h_indicies[] = {
+ 0, 2, 3, 1, 0, 4, 1, 5,
+ 1, 6, 1, 7, 1, 8, 1, 9,
+ 1, 10, 1, 11, 11, 11, 1, 12,
+ 11, 11, 11, 1, 13, 14, 15, 17,
+ 17, 16, 1, 19, 18, 1, 20, 19,
+ 18, 1, 21, 1, 22, 21, 1, 22,
+ 23, 21, 1, 24, 24, 24, 1, 25,
+ 24, 24, 24, 1, 26, 1, 0, 2,
+ 3, 1, 0
+};
+
+static const char _k2h_trans_targs[] = {
+ 20, 0, 2, 3, 2, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 14, 16,
+ 15, 19, 12, 13, 20, 15, 20, 17,
+ 18, 20, 20
+};
+
+static const char _k2h_trans_actions[] = {
+ 7, 0, 1, 9, 0, 0, 0, 0,
+ 0, 0, 0, 0, 3, 5, 5, 5,
+ 5, 5, 0, 0, 22, 0, 17, 0,
+ 0, 27, 12
+};
+
+static const int k2h_start = 1;
+static const int k2h_first_final = 20;
+static const int k2h_error = 0;
+
+static const int k2h_en_main = 1;
+
+
+#line 87 "kconf2h_parser.ragel"
+
+
+int parse_kconf2h( const char *str, FILE *outf )
+{
+
+
+
+ static uint8_t cs;
+ const int stacksize = 10;
+ int res=0, *top=0, *stack=NULL;
+ stack = malloc( sizeof(stack)*stacksize );
+ char *p=(char *)str, *pe = (char *)str + strlen( str ), *eof=NULL;
+
+ /*
+ variables used in state machine
+ */
+ char *token_s=NULL, *token_e=NULL;
+ char *value_s=NULL, *value_e=NULL;
+ int token_type=0;
+ fprintf( outf, "#ifndef __KCONFIG_H\n" );
+ fprintf( outf, "#define __KCONFIG_H\n" );
+
+
+#line 172 "kconf2h_parser.c"
+ {
+ cs = k2h_start;
+ }
+
+#line 110 "kconf2h_parser.ragel"
+
+#line 179 "kconf2h_parser.c"
+ {
+ int _klen;
+ unsigned int _trans;
+ const char *_acts;
+ unsigned int _nacts;
+ const char *_keys;
+
+ if ( p == pe )
+ goto _test_eof;
+ if ( cs == 0 )
+ goto _out;
+_resume:
+ _keys = _k2h_trans_keys + _k2h_key_offsets[cs];
+ _trans = _k2h_index_offsets[cs];
+
+ _klen = _k2h_single_lengths[cs];
+ if ( _klen > 0 ) {
+ const char *_lower = _keys;
+ const char *_mid;
+ const char *_upper = _keys + _klen - 1;
+ while (1) {
+ if ( _upper < _lower )
+ break;
+
+ _mid = _lower + ((_upper-_lower) >> 1);
+ if ( (*p) < *_mid )
+ _upper = _mid - 1;
+ else if ( (*p) > *_mid )
+ _lower = _mid + 1;
+ else {
+ _trans += (unsigned int)(_mid - _keys);
+ goto _match;
+ }
+ }
+ _keys += _klen;
+ _trans += _klen;
+ }
+
+ _klen = _k2h_range_lengths[cs];
+ if ( _klen > 0 ) {
+ const char *_lower = _keys;
+ const char *_mid;
+ const char *_upper = _keys + (_klen<<1) - 2;
+ while (1) {
+ if ( _upper < _lower )
+ break;
+
+ _mid = _lower + (((_upper-_lower) >> 1) & ~1);
+ if ( (*p) < _mid[0] )
+ _upper = _mid - 2;
+ else if ( (*p) > _mid[1] )
+ _lower = _mid + 2;
+ else {
+ _trans += (unsigned int)((_mid - _keys)>>1);
+ goto _match;
+ }
+ }
+ _trans += _klen;
+ }
+
+_match:
+ _trans = _k2h_indicies[_trans];
+ cs = _k2h_trans_targs[_trans];
+
+ if ( _k2h_trans_actions[_trans] == 0 )
+ goto _again;
+
+ _acts = _k2h_actions + _k2h_trans_actions[_trans];
+ _nacts = (unsigned int) *_acts++;
+ while ( _nacts-- > 0 )
+ {
+ switch ( *_acts++ )
+ {
+ case 0:
+#line 72 "kconf2h_parser.ragel"
+ {}
+ break;
+ case 1:
+#line 73 "kconf2h_parser.ragel"
+ {token_s = p;}
+ break;
+ case 2:
+#line 73 "kconf2h_parser.ragel"
+ {token_e = p-1;}
+ break;
+ case 3:
+#line 76 "kconf2h_parser.ragel"
+ {token_type=TYPE_YM;}
+ break;
+ case 4:
+#line 77 "kconf2h_parser.ragel"
+ {token_type=TYPE_DEC;}
+ break;
+ case 5:
+#line 78 "kconf2h_parser.ragel"
+ {token_type=TYPE_STR;}
+ break;
+ case 6:
+#line 79 "kconf2h_parser.ragel"
+ {token_type=TYPE_HEX;}
+ break;
+ case 7:
+#line 79 "kconf2h_parser.ragel"
+ {value_s = p;}
+ break;
+ case 8:
+#line 79 "kconf2h_parser.ragel"
+ {value_e = p-1;}
+ break;
+ case 9:
+#line 80 "kconf2h_parser.ragel"
+ {}
+ break;
+ case 10:
+#line 80 "kconf2h_parser.ragel"
+ { o_head_def( outf, token_type, token_s, token_e, value_s, value_e ); }
+ break;
+ case 11:
+#line 82 "kconf2h_parser.ragel"
+ {}
+ break;
+#line 301 "kconf2h_parser.c"
+ }
+ }
+
+_again:
+ if ( cs == 0 )
+ goto _out;
+ if ( ++p != pe )
+ goto _resume;
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 111 "kconf2h_parser.ragel"
+
+ if ( cs == k2h_error )
+ {
+ printf("ERR state [%d] pos[%d]:[%s]\n", res, p-str, p);
+ res = -1;
+ }
+
+ fprintf( outf, "#endif\n" );
+
+ return res;
+}
+
+
+
diff --git a/kconfig.h b/kconfig.h
new file mode 100644
index 0000000..47c6ced
--- /dev/null
+++ b/kconfig.h
@@ -0,0 +1,13 @@
+#ifndef __KCONFIG_H
+#define __KCONFIG_H
+#define CONFIG_STATUS
+#define CONFIG_STATUS_TIME
+#define CONFIG_STATUS_DATE
+#define CONFIG_STATUS_LOAD_AVERAGE
+#define CONFIG_STATUS_BATTERY
+#define CONFIG_STATUS_TEMP
+#define CONFIG_STATUS_CPU
+#define CONFIG_STATUS_FMT_NONE
+#define CONFIG_STATUS_UTF8
+#define CONFIG_DEBUG_NONE
+#endif
diff --git a/status/Kconfig b/status/Kconfig
new file mode 100644
index 0000000..4b1dbda
--- /dev/null
+++ b/status/Kconfig
@@ -0,0 +1,31 @@
+menuconfig STATUS
+ bool "Choose statuses"
+ option status
+
+if STATUS
+config STATUS_TIME
+ bool "Show current time"
+ default n
+
+config STATUS_DATE
+ bool "Show current date"
+ default n
+
+config STATUS_LOAD_AVERAGE
+ bool "Average system load"
+ default n
+
+config STATUS_BATTERY
+ bool "Battery or AC?"
+ default n
+
+config STATUS_TEMP
+ bool "Show temperature"
+ default n
+
+config STATUS_CPU
+ bool "Show current CPU usage"
+ default n
+
+endif
+
diff --git a/status/batt.c b/status/batt.c
new file mode 100644
index 0000000..f6e36b1
--- /dev/null
+++ b/status/batt.c
@@ -0,0 +1,144 @@
+#include "kconfig.h"
+#include "dwmstatus.h"
+#include "debug/debug.h"
+
+
+#define BAT_PATH "/sys/class/power_supply/BAT0"
+#define AC_PATH "/sys/class/power_supply/AC"
+
+/*
+char utf8_batt_charging[] = { 0xef, 0x88, 0x91 };
+char utf8_batt_charged_0[] = { 0xef, 0x88, 0x92 };
+char utf8_batt_charged_20[] = { 0xef, 0x88, 0x95 };
+char utf8_batt_charged_70[] = { 0xef, 0x88, 0x94 };
+char utf8_batt_charged_100[] = { 0xef, 0x88, 0x93 };
+*/
+
+char utf8_batt_charging[] = { 0xef, 0x96, 0x83 }; //ef 96 83
+
+char utf8_batt_charged_0[] = { 0xef, 0x89, 0x84 }; //ef 89 84
+char utf8_batt_charged_20[] = { 0xef, 0x89, 0x83 }; //ef 89 83
+char utf8_batt_charged_70[] = { 0xef, 0x89, 0x8e }; //ef 89 8e
+char utf8_batt_charged_100[] = { 0xef, 0x95, 0xba }; //ef 95 ba
+
+
+int print_batt( bbuf *buf )
+{
+ ASSERT( buf != NULL );
+
+ if ( buf->size < 1 )
+ {
+ buf->size = 1024;
+ buf->str = malloc( buf->size );
+ }
+
+ int c1_s=0; //CALC OFFSET INSIDE STATUS_UTF8
+
+ int ac_state=-1;
+ FILE *fac = fopen( AC_PATH "/online", "r" );
+
+ ASSERT(fac != NULL );
+ if ( fac != NULL )
+ {
+ //printf("1\n");
+ fscanf( fac, "%d", &ac_state );
+ //printf("1\n");
+ fclose( fac );
+ } else
+ {
+ printf("%s\n",strerror(errno));
+ }
+
+ //printf("1\n");
+ //printf("%d\n",ac_state);
+
+ int bat_cap=-1;
+ FILE *fbat = fopen( BAT_PATH "/capacity", "r" );
+ ASSERT( fbat != NULL );
+
+ if ( fbat != NULL )
+ {
+ fscanf( fbat, "%d", &bat_cap );
+ fclose( fbat );
+ } else
+ {
+ printf("%s\n", strerror(errno));
+ }
+
+ //we expect that everything is nice
+ ASSERT(bat_cap >= 0);
+ ASSERT(bat_cap <= 100);
+ ASSERT(ac_state <= 1);
+ ASSERT(ac_state >= 0);
+
+#ifdef CONFIG_STATUS_UTF8
+ if ( ac_state )
+ {
+ c1_s = sizeof( utf8_batt_charging );
+ memcpy( buf->str, utf8_batt_charging, c1_s );
+ snprintf( buf->str+c1_s, buf->size-1-c1_s, " %02d ", bat_cap );
+ } else
+ {
+ if ( bat_cap < 20)
+ {
+ c1_s = sizeof( utf8_batt_charged_0 );
+ memcpy( buf->str, utf8_batt_charged_0, c1_s );
+ } else if ( bat_cap < 70 )
+ {
+ c1_s = sizeof( utf8_batt_charged_20 );
+ memcpy( buf->str, utf8_batt_charged_20, c1_s );
+ } else if ( bat_cap < 98 )
+ {
+ c1_s = sizeof( utf8_batt_charged_70 );
+ memcpy( buf->str, utf8_batt_charged_70, c1_s );
+ }
+ else
+ {
+ c1_s = sizeof( utf8_batt_charged_100 );
+ memcpy( buf->str, utf8_batt_charged_100, c1_s );
+ }
+
+ }
+#else
+
+#endif
+
+//PUT COLORING INTO WORK
+#ifdef CONFIG_STATUS_FMT_PANGO
+ //seperate by colors
+ // RED - few secs left - <10%
+ // ORANGE - better to prepare - 10-30%
+ // GREEN - looks ok - >30%
+ if ( bat_cap < 10 && bat_cap >= 0 )
+ {
+ #ifdef CONFIG_STATUS_UTF8
+ snprintf(buf->str+c1_s, buf->size-1-c1_s, " <span color=\"#ff6633\">%02d</span> ", bat_cap );
+ #else
+ snprintf( buf->str, buf->size-1, "AC:%d BAT:<span color=\"#ff6633\">%02d</span> ", ac_state, bat_cap );
+ #endif
+ } else if ( bat_cap < 30 )
+ {
+ #ifdef CONFIG_STATUS_UTF8
+ snprintf(buf->str+c1_s, buf->size-1-c1_s, " <span color=\"#ffcc33\">%02d</span> ", bat_cap );
+ #else
+ snprintf( buf->str, buf->size-1, "AC:%d BAT:<span color=\"#ffcc33\">%02d</span> ", ac_state, bat_cap );
+ #endif
+ } else if ( bat_cap < 100 )
+ {
+ #ifdef CONFIG_STATUS_UTF8
+ snprintf(buf->str+c1_s, buf->size-1-c1_s, " <span color=\"#33ff66\">%02d</span> ", bat_cap );
+ #else
+ snprintf( buf->str, buf->size-1, "AC:%d BAT:<span color=\"#33ff66\">%02d</span> ", ac_state, bat_cap );
+ #endif
+ }
+#else
+ #ifdef CONFIG_STATUS_UTF8
+ snprintf(buf->str+c1_s, buf->size-1-c1_s, " !%02d ", bat_cap );
+ #else
+ snprintf( buf->str, buf->size-1, "AC:%d BAT:%02d ", ac_state, bat_cap );
+ #endif
+#endif
+
+ return 0;
+}
+
diff --git a/status/cpu.c b/status/cpu.c
new file mode 100644
index 0000000..5f203ee
--- /dev/null
+++ b/status/cpu.c
@@ -0,0 +1,77 @@
+#include "kconfig.h"
+#include "dwmstatus.h"
+
+static int prev_total = 0;
+static int prev_idle = 0;
+
+int print_cpu( bbuf *buf )
+{
+ ASSERT( buf != NULL );
+
+
+ int str_size=0;
+ int curr_user = 0, curr_nice = 0, curr_system = 0, curr_idle = 0, curr_total;
+ int diff_idle, diff_total, diff_usage;
+
+ if ( buf->size < 1 )
+ {
+ buf->size = 1024;
+ buf->str = malloc( buf->size );
+ }
+
+ FILE *f = fopen( "/proc/stat", "r" );
+ ASSERT(f != NULL );
+
+ fscanf( f, "cpu %d %d %d %d", &curr_user, &curr_nice, &curr_system, &curr_idle );
+ fclose( f );
+
+ ASSERT( curr_user > 0 );
+ ASSERT( curr_nice > 0 );
+ ASSERT( curr_system > 0 );
+ ASSERT( curr_idle > 0 );
+
+ //printf("%d %d %d %d\n", curr_user, curr_nice, curr_system, curr_idle );
+
+ curr_total = curr_user + curr_nice + curr_system + curr_idle;
+ diff_idle = curr_idle - prev_idle;
+ diff_total = curr_total - prev_total;
+ diff_usage = (diff_total ? (1000 * (diff_total - diff_idle)/diff_total + 5)/10 : 0);
+ prev_total = curr_total;
+ prev_idle = curr_idle;
+
+#ifdef CONFIG_STATUS_UTF8
+ //chip f64f, //ef ac 99
+ buf->str[0] = 0xef;
+ buf->str[1] = 0xac;
+ buf->str[2] = 0x99;
+ str_size = 3;
+ printf("asd1 [%s]\n", buf->str);
+#endif
+
+#ifdef CONFIG_STATUS_FMT_PANGO
+ //seperate by colors
+ // COLD - BLUE - < 20%
+ // WARM - GREEN 20-80%
+ // HOT - RED >80%
+ if ( diff_usage < 20 )
+ {
+ snprintf( buf->str, buf->size-1, "CPU:<span color=\"#3366ff\">%02d%%</span> ", diff_usage );
+ } else if( diff_usage > 80 )
+ {
+ snprintf( buf->str, buf->size-1, "CPU:<span color=\"#ff6633\">%02d%%</span> ", diff_usage );
+ } else
+ {
+ snprintf( buf->str, buf->size-1, "CPU:<span color=\"#33ff66\">%02d%%</span> ", diff_usage );
+ }
+#else
+ #ifdef CONFIG_STATUS_UTF8
+ snprintf( &buf->str[str_size], buf->size-1-str_size, "%02d%% ", diff_usage );
+ #else
+ snprintf( &buf->str[str_size], buf->size-1-str_size, "CPU:%02d%% ", diff_usage );
+ #endif
+
+#endif
+
+ return 0;
+}
+
diff --git a/status/date.c b/status/date.c
new file mode 100644
index 0000000..f06c61d
--- /dev/null
+++ b/status/date.c
@@ -0,0 +1,39 @@
+#include "kconfig.h"
+#include "dwmstatus.h"
+
+int print_date( bbuf *buf )
+{
+ ASSERT( buf != NULL );
+
+ int str_size=0;
+ if ( buf->size < 1 )
+ {
+ buf->size = 1024;
+ buf->str = malloc( buf->size );
+ ASSERT( buf->str != NULL );
+ }
+
+ time_t tim;
+ struct tm *timtm;
+
+ memset(buf->str, 0, buf->size);
+ time( &tim );
+ timtm = localtime( &tim );
+ if (timtm == NULL)
+ {
+ perror("localtime");
+ }
+
+#ifdef CONFIG_STATUS_UTF8
+ buf->str[0] = 0xef;
+ buf->str[1] = 0x81;
+ buf->str[2] = 0xb3;
+ str_size = 3;
+#endif
+
+
+ strftime(&buf->str[str_size], buf->size-1-str_size," %d%b%Y", timtm);
+
+ return 0;
+}
+
diff --git a/status/make.mk b/status/make.mk
new file mode 100644
index 0000000..ca2a0ac
--- /dev/null
+++ b/status/make.mk
@@ -0,0 +1,5 @@
+
+CUR_DIR=status
+NEW_SRC=date.c time.c
+SRC+=$(CUR_DIR)/time.c $(CUR_DIR)/date.c
+OBJ+=$(CUR_DIR)/time.o $(CUR_DIR)/date.o
diff --git a/status/temp.c b/status/temp.c
new file mode 100644
index 0000000..d35f6b3
--- /dev/null
+++ b/status/temp.c
@@ -0,0 +1,74 @@
+#include "kconfig.h"
+#include "dwmstatus.h"
+
+#define TEMP_PATH "/sys/class/thermal/thermal_zone0/temp"
+
+int print_temp( bbuf *buf)
+{
+ ASSERT( buf != NULL );
+
+ int str_size=0;
+ if ( buf->size < 1 )
+ {
+ buf->size = 1024;
+ buf->str = malloc( buf->size );
+ }
+
+ uint32_t temp=0;
+ FILE *f = fopen(TEMP_PATH,"r");
+
+ ASSERT( f != NULL );
+
+ fscanf( f, "%u\n", &temp );
+ temp /= 1000;
+ //printf("%u\n",temp);
+
+ fclose( f );
+
+ ASSERT( temp < 110 );
+
+#ifdef CONFIG_STATUS_UTF8
+ buf->str[0] = 0xef;
+ buf->str[1] = 0xa3;
+ buf->str[2] = 0x87;
+ str_size = 3;
+#endif
+
+#ifdef CONFIG_STATUS_FMT_PANGO
+ //seperate by color temp
+ // RED - very hot - >80
+ // GREEN - normal temp - 50-80
+ // BLUE - cold - <50
+ if ( temp < 50 )
+ {
+ #ifdef CONFIG_STATUS_UTF8
+ snprintf( &buf->str[str_size], buf->size-1-str_size, "<span color=\"#3366ff\">%u</span>C ", temp );
+ #else
+ snprintf( &buf->str[str_size], buf->size-1-str_size, "TEMP:<span color=\"#3366ff\">%u</span>C ", temp );
+ #endif
+ } else if ( temp < 80 )
+ {
+ #ifdef CONFIG_STATUS_UTF8
+ snprintf( &buf->str[str_size], buf->size-1-str_size, "<span color=\"#33ff66\">%u</span>C ", temp );
+ #else
+ snprintf( &buf->str[str_size], buf->size-1-str_size, "TEMP:<span color=\"#33ff66\">%u</span>C ", temp );
+ #endif
+ } else
+ {
+ #ifdef CONFIG_STATUS_UTF8
+ snprintf( &buf->str[str_size], buf->size-1-str_size, "<span color=\"#ff6633\">%u</span>C ", temp );
+ #else
+ snprintf( &buf->str[str_size], buf->size-1-str_size, "TEMP:<span color=\"#ff6633\">%u</span>C ", temp );
+ #endif
+ }
+#else
+ #ifdef CONFIG_STATUS_UTF8
+ snprintf( &buf->str[str_size], buf->size-1-str_size, "%uC ", temp );
+ #else
+ snprintf( &buf->str[str_size], buf->size-1-str_size, "TEMP:%uC ", temp );
+ #endif
+ //snprintf( buf->str, buf->size-1, "\xc2\xae%uC ", temp/1000 );
+#endif
+
+ return 0;
+}
diff --git a/status/time.c b/status/time.c
new file mode 100644
index 0000000..f02e2bf
--- /dev/null
+++ b/status/time.c
@@ -0,0 +1,59 @@
+
+#include "kconfig.h"
+#include "dwmstatus.h"
+
+int print_time( bbuf *buf )
+{
+ ASSERT( buf != NULL );
+
+ int str_size=0;
+
+ if ( buf->size < 1 )
+ {
+ buf->size = 1024;
+ buf->str = malloc( buf->size );
+ }
+
+ time_t tim;
+ struct tm *timtm;
+
+ memset(buf->str, 0, buf->size);
+ //settz(tzname);
+ time( &tim );
+ timtm = localtime( &tim );
+ if (timtm == NULL)
+ {
+ perror("localtime");
+ //exit(1);
+ }
+#ifdef CONFIG_STATUS_UTF8
+ /*
+ buf->str[0] = 0x20;
+ buf->str[1] = 0xef;
+ buf->str[2] = 0x8d;
+ buf->str[3] = 0xae;
+ str_size = 2;
+ */
+ //nerd f64f, //ef 99 8f
+ buf->str[0] = 0xef;
+ buf->str[1] = 0x99;
+ buf->str[2] = 0x8f;
+ str_size = 3;
+ printf("asd1 [%s]\n", buf->str);
+#endif
+
+ //printf("%s",asctime(timtm));
+ strftime(&buf->str[str_size], buf->size-1-str_size,"%H:%M ", timtm);
+ //if (!strftime(buf->str, buf->size-1, "%H:%M", timtm))
+ //{
+ // fprintf(stderr, "strftime == 0\n");
+ //exit(1);
+ //}
+
+
+ printf("asd1 [%s]\n", buf->str);
+ //wprintf(L"asd2 [%ls]\n", buf->str);
+ return 0;
+}
+
+