1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633 | diff --git a/install.py b/install.py
new file mode 100644
index 0000000..532a4a4
--- /dev/null
+++ b/install.py
@@ -0,0 +1,105 @@
+import os
+
+
+def get_distro():
+ if os.path.isfile("/etc/os-release"):
+ with open("/etc/os-release") as f:
+ for line in f:
+ if line.startswith("ID="):
+ return line.strip().split("=")[1].strip('"')
+ elif os.system("command -v lsb_release > /dev/null 2>&1") == 0:
+ stream = os.popen("lsb_release -i")
+ result = stream.read().strip()
+ if result:
+ return result.split(":")[1].strip()
+ return "unknown"
+
+
+distro = get_distro()
+
+
+def install_pip():
+ exit_code = os.system("pip3 --version > /dev/null 2>&1")
+ if exit_code == 0:
+ print("Pip: Done")
+ else:
+ print("pip not found. Installing pip...")
+ if distro in ["ubuntu", "debian"]:
+ os.system("sudo apt-get update")
+ os.system("sudo apt-get install -y python3-pip > /dev/null 2>&1")
+ os.system("clear")
+ print("Pip: Done")
+ elif distro == "fedora":
+ os.system("sudo dnf install -y python3-pip > /dev/null 2>&1")
+ os.system("clear")
+ print("Pip: Done")
+ elif distro in ["centos", "rhel"]:
+ os.system("sudo yum install -y python3-pip > /dev/null 2>&1")
+ os.system("clear")
+ print("Pip: Done")
+ elif distro == "arch":
+ os.system("sudo pacman -S --noconfirm python-pip > /dev/null 2>&1")
+ os.system("clear")
+ print("Pip: Done")
+ elif distro == "void":
+ os.system("sudo xbps-install -y python3-pip > /dev/null 2>&1")
+ os.system("clear")
+ print("Pip: Done")
+ else:
+ print("Unsupported distribution. Please install pip manually.")
+ exit(1)
+
+
+def install_system_deps():
+ if distro in ["ubuntu", "debian"]:
+ os.system("sudo apt-get update > /dev/null 2>&1")
+ os.system("sudo apt-get install -y tk > /dev/null 2>&1")
+ print("Dependencies: Done")
+ elif distro == "fedora":
+ os.system("sudo dnf install -y tk > /dev/null 2>&1")
+ print("Dependencies: Done")
+
+ elif distro in ["centos", "rhel"]:
+ os.system("sudo yum install -y tk > /dev/null 2>&1")
+ print("Dependencies: Done")
+ elif distro == "arch":
+ os.system("sudo pacman -S --noconfirm tk > /dev/null 2>&1")
+ print("Dependencies: Done")
+ elif distro == "void":
+ os.system("sudo xbps-install -y tk > /dev/null 2>&1")
+ print("Dependencies: Done")
+ else:
+ print("Unsupported distribution. Please install system dependencies manually.")
+
+
+def install_libs():
+ os.system(
+ "pip install customtkinter screeninfo playsound --break-system-packages > /dev/null 2>&1"
+ )
+ print("Libs: Done")
+
+
+def copy_file():
+ try:
+ os.system("cp ./src/pino.py pino > /dev/null 2>&1")
+ os.system(
+ 'echo "#!/usr/bin/env python3" | cat - pino > temp.txt && mv temp.txt pino > /dev/null 2>&1'
+ )
+ os.system("chmod +x pino > /dev/null 2>&1")
+ os.system("sudo cp pino ./src/pino_start /usr/bin/ > /dev/null 2>&1")
+ os.system("rm pino > /dev/null 2>&1")
+ os.system("sudo mkdir /etc/pino/ > /dev/null 2>&1")
+ os.system("mkdir ~/.config/pino/ ~/.config/pino/plugs/ > /dev/null 2>&1")
+ os.system("cp ./plugs/* ~/.config/pino/plugs > /dev/null 2>&1")
+ os.system(
+ "sudo cp ./src/config.json ./src/notification.mp3 /etc/pino/ > /dev/null 2>&1"
+ )
+ print("\nAll Done")
+ except:
+ print("The file has not moved")
+
+
+install_pip()
+install_libs()
+install_system_deps()
+copy_file()
diff --git a/plugs/battry b/plugs/battry
new file mode 100755
index 0000000..048461f
Binary files /dev/null and b/plugs/battry differ
diff --git a/plugs/src/battry.c b/plugs/src/battry.c
new file mode 100644
index 0000000..5429fe6
--- /dev/null
+++ b/plugs/src/battry.c
@@ -0,0 +1,106 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define BATTERY_PATH "/sys/class/power_supply/BAT1"
+#define MAX_BUFFER 100
+
+void pino(const char *title, const char *message) {
+ char command[MAX_BUFFER * 2];
+ snprintf(command, sizeof(command), "pino --title \"%s\" --massage \"%s\"",
+ title, message);
+ system(command);
+}
+
+int battery_capacity() {
+ char path[MAX_BUFFER];
+ snprintf(path, sizeof(path), "%s/capacity", BATTERY_PATH);
+
+ FILE *file = fopen(path, "r");
+ if (!file) {
+ perror("Error opening capacity file");
+ return -1;
+ }
+
+ int capacity;
+ if (fscanf(file, "%d", &capacity) != 1) {
+ perror("Error reading capacity");
+ fclose(file);
+ return -1;
+ }
+
+ fclose(file);
+ return capacity;
+}
+
+char *battery_status() {
+ char path[MAX_BUFFER];
+ snprintf(path, sizeof(path), "%s/status", BATTERY_PATH);
+
+ FILE *file = fopen(path, "r");
+ if (!file) {
+ perror("Error opening status file");
+ return NULL;
+ }
+
+ static char status[MAX_BUFFER];
+ if (fgets(status, sizeof(status), file) == NULL) {
+ perror("Error reading status");
+ fclose(file);
+ return NULL;
+ }
+
+ status[strcspn(status, "\n")] = 0;
+
+ fclose(file);
+ return status;
+}
+
+int main() {
+ int low_battery_warning = 0;
+ int charging_warning = 0;
+ int discharging_warning = 0;
+ int full = 0;
+
+ while (1) {
+ int capacity = battery_capacity();
+ char *status = battery_status();
+
+ if (capacity <= 20 && strcmp(status, "Discharging") == 0 &&
+ !low_battery_warning) {
+ pino("Low Battery", "Plug Your Charger in");
+ low_battery_warning = 1;
+ charging_warning = 0;
+ }
+
+ if (strcmp(status, "Charging") == 0) {
+ low_battery_warning = 0;
+ discharging_warning = 0;
+ full = 0;
+ if (!charging_warning) {
+ pino("Battery Charging", "The battery is charging now");
+ charging_warning = 1;
+ }
+ }
+
+ if (strcmp(status, "Discharging") == 0) {
+ low_battery_warning = 0;
+ charging_warning = 0;
+ full = 0;
+ if (!discharging_warning) {
+ pino("Battery Discharging", "The battery is discharging now ");
+ discharging_warning = 1;
+ }
+ }
+
+ if (capacity == 100 && strcmp(status, "Not charging") == 0 && !full) {
+ pino(" Battery Fully Charged", "You can unplug the charger now");
+ full = 1;
+ }
+
+ usleep(50000);
+ }
+
+ return 0;
+}
diff --git a/src/config.json b/src/config.json
new file mode 100644
index 0000000..0d09298
--- /dev/null
+++ b/src/config.json
@@ -0,0 +1,42 @@
+{
+ "screen": {
+ "monitor": 0,
+ "vertical": "right",
+ "horizontal": "top",
+ "x": 20,
+ "y": 20,
+ "width": 300,
+ "height": 100,
+ "opacity": 100,
+ "show": 3
+ },
+ "frame": {
+ "fg_color": "#1a1e24",
+ "font_family": "Fira Code",
+ "border": {
+ "width": 3,
+ "color": "#566D8d",
+ "border_radius": 10
+ }
+ },
+ "title": {
+ "color": "#c5c6c8",
+ "font_size": 19,
+ "x": 10,
+ "y": 10,
+ "weigth": "bold",
+ "wrap_length": "auto"
+ },
+ "massage": {
+ "color": "#626977",
+ "font_size": 15,
+ "x": 15,
+ "y": 45,
+ "weigth": "normal",
+ "wrap_length": "auto"
+ },
+ "optional": {
+ "pywal": false,
+ "sound": false
+ }
+}
diff --git a/src/notification.mp3 b/src/notification.mp3
new file mode 100644
index 0000000..3860589
Binary files /dev/null and b/src/notification.mp3 differ
diff --git a/src/pino.py b/src/pino.py
new file mode 100644
index 0000000..e7ebd31
--- /dev/null
+++ b/src/pino.py
@@ -0,0 +1,190 @@
+"""
+PINO Tool:
+ - Pino its a high customazabel app with low hardware usage and support pywal its a single file
+ and its work in x11 and wayland normally without problems
+
+ - to create a new notification u can use my Plugs or just create a scripts with any lang that u want
+ that when your script run this app to show what u want thats all
+
+REPORT:
+ if u get some glitchs or something and u want to report it,
+ just sent it to me in my DISCORD:pi66 and i will fix it
+
+HOW TO USE IT:
+ the app can handle 3 arguments:
+ [1] --title | will be set the string that u enter it to a title in the notification
+ [2] --massage | will be set the string that u enter it to a massage in the notification
+ [3] --config | this is a optional its use if you want to set a special config file for the first run
+
+ command:
+ pino --title "enter you title" --massage "enter your massage" --config "enter a path for the config file that u want "
+
+
+
+FUTURE:
+- possiblity to add icon
+
+"""
+
+from customtkinter import CTk, CTkFont, CTkFrame, CTkLabel
+from screeninfo import get_monitors
+from json import load
+from os.path import exists, expanduser
+from os import getlogin, system
+from argparse import ArgumentParser
+# from threading import Thread
+# from playsound import playsound
+
+
+parsers = ArgumentParser(description="Enter Title and Massage that you want to show")
+parsers.add_argument("--title", metavar="", help="enter a string title")
+parsers.add_argument("--massage", metavar="", help="enter a string massage")
+parsers.add_argument(
+ "--config", metavar="", help="to use a special config file 'optional'"
+)
+args = parsers.parse_args()
+
+
+pywal_conf = None
+conf = None
+config_folder = f"/home/{getlogin()}/.config/pino/"
+
+if not args.config:
+ if exists(f"{config_folder}config.json"):
+ with open(f"{config_folder}config.json", "r") as file:
+ conf = load(file)
+ else:
+ system(f"mkdir {config_folder} > /dev/null 2>&1")
+ system(f"cp /etc/pino/config.json {config_folder} > /dev/null 2>&1")
+ with open(f"{config_folder}config.json", "r") as file:
+ conf = load(file)
+else:
+ with open(expanduser(args.config), "r") as file:
+ conf = load(file)
+
+if not exists(f"{config_folder}notification.mp3"):
+ system(f"cp /etc/pino/notification.mp3 {config_folder} > /dev/null 2>&1")
+
+sx = get_monitors()[conf["screen"]["monitor"]].x
+sy = get_monitors()[conf["screen"]["monitor"]].y
+sw = get_monitors()[conf["screen"]["monitor"]].width
+sh = get_monitors()[conf["screen"]["monitor"]].height
+
+ax = conf["screen"]["x"]
+ay = conf["screen"]["y"]
+aw = conf["screen"]["width"]
+ah = conf["screen"]["height"]
+
+V = conf["screen"]["vertical"]
+H = conf["screen"]["horizontal"]
+
+frame_fg = ""
+border_color = ""
+title_color = ""
+massage_color = ""
+
+
+if conf["optional"]["pywal"]:
+ with open(f"/home/{getlogin()}/.cache/wal/colors.json", "r") as file:
+ pywal_conf = load(file)
+ border_color = pywal_conf["colors"]["color1"]
+ frame_fg = pywal_conf["colors"]["color0"]
+ title_color = pywal_conf["special"]["cursor"]
+ massage_color = pywal_conf["colors"]["color8"]
+
+else:
+ border_color = conf["frame"]["border"]["color"]
+ frame_fg = conf["frame"]["fg_color"]
+ title_color = conf["title"]["color"]
+ massage_color = conf["massage"]["color"]
+
+
+def place():
+ if V == "left".lower():
+ if H == "top".lower():
+ return f"{aw}x{ah}+{ax + sx}+{ay + sy}"
+ elif H == "bottom".lower():
+ return f"{aw}x{ah}+{sx + ax}+{sy + sh - ah - ay}"
+ if V == "right".lower():
+ if H == "top".lower():
+ return f"{aw}x{ah}+{sx + sw - aw - ax }+{ay + sy}"
+ elif H == "bottom".lower():
+ return f"{aw}x{ah}+{sx + sw - aw - ax }+{sy + sh - ah - ay}"
+
+
+class Main(CTk):
+ def __init__(self):
+ super().__init__()
+ self.geometry(str(place()))
+ self.resizable(False, False)
+ self.overrideredirect(True)
+
+ self.main = CTkFrame(
+ width=aw,
+ height=ah,
+ master=self,
+ border_width=conf["frame"]["border"]["width"],
+ border_color=border_color,
+ fg_color=frame_fg,
+ corner_radius=conf["frame"]["border"]["border_radius"],
+ )
+ self.main.place(x=0, y=0)
+
+ self.title = CTkLabel(
+ self,
+ text=f"{args.title} ",
+ anchor="w",
+ fg_color=frame_fg,
+ text_color=title_color,
+ width=aw
+ - int(conf["frame"]["border"]["width"])
+ - int(conf["title"]["x"] + 1),
+ wraplength=(int(aw - conf["title"]["x"]) - 20)
+ if (conf["title"]["wrap_length"] == "auto")
+ else (int(conf["title"]["wrap_length"]) - 20),
+ font=CTkFont(
+ conf["frame"]["font_family"],
+ conf["title"]["font_size"],
+ conf["title"]["weigth"],
+ ),
+ )
+ self.title.place(x=conf["title"]["x"], y=conf["title"]["y"])
+
+ self.massage = CTkLabel(
+ self,
+ text=f"{args.massage} ",
+ anchor="w",
+ fg_color=frame_fg,
+ text_color=massage_color,
+ width=aw
+ - int(conf["frame"]["border"]["width"])
+ - int(conf["massage"]["x"] + 2),
+ wraplength=(int(aw - conf["massage"]["x"]) - 20)
+ if (conf["massage"]["wrap_length"] == "auto")
+ else (int(conf["massage"]["wrap_length"]) - 20),
+ font=CTkFont(
+ conf["frame"]["font_family"],
+ conf["massage"]["font_size"],
+ conf["massage"]["weigth"],
+ ),
+ )
+ self.massage.place(x=conf["massage"]["x"], y=conf["massage"]["y"])
+
+
+if __name__ == "__main__":
+ if args.massage == None or args.title == None:
+ parsers.print_help()
+ exit()
+
+ root = Main()
+ root.after(30, lambda: root.attributes("-alpha", conf["screen"]["opacity"] / 100))
+ root.after(conf["screen"]["show"] * 1000, root.quit)
+
+ if conf["optional"]["sound"]:
+ from threading import Thread
+ from playsound import playsound
+
+ thread = Thread(target=lambda: playsound(f"{config_folder}notification.mp3"))
+ thread.start()
+
+ root.mainloop()
diff --git a/src/pino_start b/src/pino_start
new file mode 100755
index 0000000..5561600
Binary files /dev/null and b/src/pino_start differ
diff --git a/src/pino_start.c b/src/pino_start.c
new file mode 100644
index 0000000..eb4737f
--- /dev/null
+++ b/src/pino_start.c
@@ -0,0 +1,81 @@
+#include <dirent.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#define MAX_PATH_LENGTH 1024
+
+int is_executable(const char *path) {
+ struct stat st;
+
+ // Check if file exists and is a regular file
+ if (stat(path, &st) != 0) {
+ return 0;
+ }
+
+ // Check if file is executable
+ return (st.st_mode & S_IXUSR) || (st.st_mode & S_IXGRP) ||
+ (st.st_mode & S_IXOTH);
+}
+
+int main() {
+ const char *home_dir = getenv("HOME");
+ if (home_dir == NULL) {
+ fprintf(stderr, "Could not get HOME directory\n");
+ return 1;
+ }
+
+ char plugs_dir[MAX_PATH_LENGTH];
+ snprintf(plugs_dir, sizeof(plugs_dir), "%s/.config/pino/plugs/", home_dir);
+
+ DIR *dir;
+ struct dirent *entry;
+
+ // Open directory
+ dir = opendir(plugs_dir);
+ if (dir == NULL) {
+ fprintf(stderr, "Unable to open directory %s: %s\n", plugs_dir,
+ strerror(errno));
+ return 1;
+ }
+
+ // Read directory entries
+ while ((entry = readdir(dir)) != NULL) {
+ // Skip current and parent directory entries
+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
+ continue;
+ }
+
+ // Construct full path
+ char full_path[MAX_PATH_LENGTH];
+ snprintf(full_path, sizeof(full_path), "%s%s", plugs_dir, entry->d_name);
+
+ // Check if file is executable
+ if (is_executable(full_path)) {
+ printf("Starting: %s\n", full_path);
+
+ // Fork and execute
+ pid_t pid = fork();
+
+ if (pid == 0) {
+ // Child process
+ execl(full_path, full_path, NULL);
+
+ // If execl fails
+ fprintf(stderr, "Failed to execute %s\n", strerror(errno));
+ exit(1);
+ }
+ // Parent process continues to next file
+ }
+ }
+
+ // Close directory
+ closedir(dir);
+
+ printf("Finished.\n");
+
+ return 0;
+}
diff --git a/uninstall.py b/uninstall.py
new file mode 100644
index 0000000..e79138b
--- /dev/null
+++ b/uninstall.py
@@ -0,0 +1,61 @@
+import os
+
+
+def get_distro():
+ if os.path.isfile("/etc/os-release"):
+ with open("/etc/os-release") as f:
+ for line in f:
+ if line.startswith("ID="):
+ return line.strip().split("=")[1].strip('"')
+ elif os.system("command -v lsb_release > /dev/null 2>&1") == 0:
+ stream = os.popen("lsb_release -i")
+ result = stream.read().strip()
+ if result:
+ return result.split(":")[1].strip()
+ return "unknown"
+
+
+distro = get_distro()
+
+
+def remove_system_deps():
+ if distro in ["ubuntu", "debian"]:
+ os.system("sudo apt-get remove -y tk > /dev/null 2>&1")
+ print("Remove System Dep: Done")
+ elif distro == "fedora":
+ os.system("sudo dnf remove -y tk > /dev/null 2>&1")
+ print("Remove System Dep: Done")
+ elif distro in ["centos", "rhel"]:
+ os.system("sudo yum remove -y tk > /dev/null 2>&1")
+ print("Remove System Dep: Done")
+ elif distro == "arch":
+ os.system("sudo pacman -Rns --noconfirm tk > /dev/null 2>&1")
+ print("Remove System Dep: Done")
+ elif distro == "void":
+ os.system("sudo xbps-remove -R tk > /dev/null 2>&1")
+ print("Remove System Dep: Done")
+ else:
+ print("Unsupported distribution. Please install system dependencies manually.")
+
+
+def uninstall_libs():
+ os.system(
+ "pip uninstall --yes customtkinter playsound screeninfo --break-system-packages > /dev/null 2>&1"
+ )
+ print("Remove Libs: Done")
+
+
+def remove_files():
+ try:
+ os.system(
+ "sudo rm -r /usr/bin/pino /usr/bin/pino_start /etc/pino/ > /dev/null 2>&1"
+ )
+ os.system("rm -r ~/.config/pino/ ~/.config/pino/plugs/ > /dev/null 2>&1")
+ print("App Remove: Done")
+ except:
+ print("Faild remove")
+
+
+remove_system_deps()
+uninstall_libs()
+remove_files()
|