Skip to content

Commit 22031ac

Browse files
committed
10102218
1 parent 89c058f commit 22031ac

File tree

19 files changed

+284
-150
lines changed

19 files changed

+284
-150
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ it simply tracks your mouse and keyboard usage on your system by reading `/dev/i
3737
when they become idle for 2 min, the app considers your time as "waste time" and as you come back it will continue normally.
3838

3939
#### How to use it?
40-
You can directly use the `/build/clocker` binary file by copying it to the `/bin` system directory.
40+
You can directly use the `/build/clocker` binary file by copying it to the `/usr/bin` system directory.
4141
or make source easily by running `make && make install` in the root directory of the project (recommended).
42-
it will copy `clocker` to `/bin` and clocker updater to `/root/.clocker`.
42+
it will copy `clocker` and `clocker updater` to `/usr/bin`.
4343
for run clocker run:
4444
```
4545
$ sudo clocker

common/info.h renamed to common/defs.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,34 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with Clocker. If not, see <http://www.gnu.org/licenses/>.
1717

18-
#ifndef COMMON_INFO_H
19-
#define COMMON_INFO_H
18+
#ifndef COMMON_DEFS_H
19+
#define COMMON_DEFS_H
2020

2121
#include "../includes/common/inc.h"
2222

23-
Str clocker_banner = COLOR_TRANSPARENT"\n"\
23+
#define INIT_VERSION "0.2-beta.0"
24+
25+
#define CLOCKER_BANNER COLOR_TRANSPARENT"\n"\
2426
" █████████ ████ █████\n" \
2527
" ███░░░░░███░░███ ░░███\n" \
2628
" ███ ░░░ ░███ ██████ ██████ ░███ █████ ██████ ████████\n" \
2729
"░███ ░███ ███░░███ ███░░███ ░███░░███ ███░░███░░███░░███\n" \
2830
"░███ ░███ ░███ ░███░███ ░░░ ░██████░ ░███████ ░███ ░░░\n" \
2931
"░░███ ███ ░███ ░███ ░███░███ ███ ░███░░███ ░███░░░ ░███\n" \
3032
" ░░█████████ █████░░██████ ░░██████ ████ █████░░██████ █████\n" \
31-
" ░░░░░░░░░ ░░░░░ ░░░░░░ ░░░░░░ ░░░░ ░░░░░ ░░░░░░ ░░░░░\n"COLOR_RESET;
33+
" ░░░░░░░░░ ░░░░░ ░░░░░░ ░░░░░░ ░░░░ ░░░░░ ░░░░░░ ░░░░░\n"COLOR_RESET
34+
35+
36+
#define ERR_TXT(txt_) COLOR_RED txt_ COLOR_RESET
37+
#define WRN_TXT(txt_) COLOR_YELLOW txt_ COLOR_RESET
38+
#define OK_TXT(txt_) COLOR_GREEN txt_ COLOR_RESET
39+
#define INF_TXT(txt_) COLOR_B_CYAN txt_ COLOR_RESET
40+
41+
#define DNG_TXT(txt_) COLOR_B_RED txt_ COLOR_RESET
42+
#define ATT_TXT(txt_) COLOR_B_YELLOW txt_ COLOR_RESET
43+
44+
#define TRANSPARENT_TXT(txt_) COLOR_TRANSPARENT txt_ COLOR_RESET
45+
#define BOLD_TXT(txt_) COLOR_BOLD txt_ COLOR_RESET
46+
#define ITALIC_TXT(txt_) COLOR_ITALIC txt_ COLOR_RESET
3247

33-
#endif // COMMON_INFO_H
48+
#endif // COMMON_DEFS_H

headers/cmd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define HEADERS_CMD_H
2020

2121
#include "../includes/common/inc.h"
22+
#include "../headers/mutexed.h"
2223

2324
Hndl cmd_run(Hndl state);
2425

headers/listener.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define HEADERS_LISTENER_H
2020

2121
#include "../includes/common/inc.h"
22+
#include "../common/defs.h"
2223

2324
typedef UInt64 Listener;
2425

headers/sig_handler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020

2121
#include <signal.h>
2222
#include "../includes/common/inc.h"
23+
#include "../common/defs.h"
2324

2425
typedef sig_t Sig;
2526

26-
Sig sig_handler(Int32 signal);
27+
Void signal_handler(Int32 signal);
2728

2829
#endif // HEADERS_SIG_HANDLER_H

headers/env.h renamed to headers/thread_arg.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,46 @@
1919
#define HEADERS_ENV_H
2020

2121
#include "../includes/common/inc.h"
22+
#include "../headers/mutexed.h"
2223

24+
typedef enum {
25+
TM_Default,
26+
TM_Busy,
27+
TM_Paused
28+
}
29+
TimeMode;
2330

31+
typedef enum {
32+
TC_None,
33+
TC_End,
34+
TC_Report,
35+
TC_Pause,
36+
TC_Resume
37+
}
38+
TimeCommand;
39+
40+
typedef struct {
41+
Str version;
42+
Mutexed* mode;
43+
Mutexed* command;
44+
}
45+
TreadArg;
46+
47+
48+
INLINE Str time_mode_from(TimeMode mode) {
49+
switch (mode) {
50+
case TM_Default:
51+
return "default";
52+
53+
case TM_Busy:
54+
return "busy";
55+
56+
case TM_Paused:
57+
return WRN_TXT("paused");
58+
59+
default:
60+
return "";
61+
}
62+
}
2463

2564
#endif // HEADERS_ENV_H

headers/time_handler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define HEADERS_TIME_HANDLE_H
2020

2121
#include "../includes/common/inc.h"
22+
#include "../headers/thread_arg.h"
2223

2324
Hndl time_handle(Void* arg);
2425

headers/updater_checker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define HEADERS_UPDATECHRCKER_H
2222

2323
#include "../includes/common/inc.h"
24+
#include "../common/defs.h"
2425

2526
typedef enum {
2627
US_Error,

includes/prims/inc/debug.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
#define COLOR_CYAN "\x1b[36m"
4040
#define COLOR_RESET "\x1b[0m"
4141

42+
#define COLOR_B_RED "\x1b[91m"
43+
#define COLOR_B_GREEN "\x1b[92m"
44+
#define COLOR_B_YELLOW "\x1b[93m"
45+
#define COLOR_B_BLUE "\x1b[94m"
46+
#define COLOR_B_CYAN "\x1b[96m"
47+
4248
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
4349

4450
#define ERR_LBL "ERR"

makefile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,25 @@ clocker := ${current}/src/clocker.c
2929
updater := ${current}/src/updater.c
3030

3131
buildClocker := ${current}/build/clocker
32-
buildUpdater := ${current}/build/updater
32+
buildUpdater := ${current}/build/clocker-updater
3333

3434
all:
3535
@mkdir -p ${current}/build
36-
@gcc -w -g ${component} ${clocker} -o ${buildClocker} -lpthread
37-
@gcc -w -g ${updater} ${current}/src/components/update_checker.c -o ${buildUpdater} -lpthread
36+
@gcc -fcompare-debug-second -w -g ${component} ${clocker} -o ${buildClocker} -lpthread
37+
@gcc -fcompare-debug-second -w -g ${updater} ${current}/src/components/update_checker.c -o ${buildUpdater} -lpthread
3838

3939
install:
40-
@mkdir -p /root/.clocker
41-
@gcc -w -g ${component} ${clocker} -o /bin/clocker -lpthread
42-
@gcc -w -g ${updater} ${current}/src/components/update_checker.c -o /root/.clocker/clocker-updater -lpthread
40+
@mkdir -p /root/.config/clocker
41+
@cp ${buildClocker} /usr/bin
42+
@cp ${buildUpdater} /usr/bin
4343

4444
run:
4545
@sudo ${buildClocker}
4646

47+
clean:
48+
@rm -rf ${current}/build/
4749

4850
uninstall:
49-
@rm -rf /root/.clocker
50-
@rm /bin/clocker
51+
@rm -rf /root/.config/clocker
52+
@rm /usr/bin/clocker
53+
@rm /usr/bin/clocker-updater

0 commit comments

Comments
 (0)