-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
1749 lines (1429 loc) · 81.2 KB
/
main.py
File metadata and controls
1749 lines (1429 loc) · 81.2 KB
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
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import customtkinter as ctk
import tkinter as tk
import subprocess
import os
import glob
import time
import re
import sys
import json
import shutil
import pwd
from PIL import Image, ImageTk
import threading
from tkinter import messagebox
import tempfile
from config import *
from translations import TRANSLATIONS
from helpers import get_cmd
from components import LineChart
from dialogs import PasswordDialog
import system_info as sys_info
import kernel_actions as k_actions
CURRENT_LANG = "tr"
class SettingsManager:
def __init__(self, config_path):
self.config_path = config_path
self.data = {}
self.load()
def load(self):
if os.path.exists(self.config_path):
try:
with open(self.config_path, "r", encoding="utf-8") as f:
self.data = json.load(f)
except:
self.data = {}
def save(self):
try:
os.makedirs(os.path.dirname(self.config_path), exist_ok=True)
with open(self.config_path, "w", encoding="utf-8") as f:
json.dump(self.data, f, indent=4)
except Exception as e:
print(f"Settings save error: {e}")
class KernelManager(ctk.CTk):
def __init__(self):
super().__init__()
# Ayar Yöneticisi
self.settings = SettingsManager(CONFIG_FILE)
# Dil Tespiti
self.lang = self.settings.data.get("language")
if not self.lang:
try:
lang_code = os.environ.get("LC_ALL") or os.environ.get("LC_CTYPE") or os.environ.get("LANG")
if lang_code and lang_code.startswith("en"):
self.lang = "en"
else:
self.lang = "tr"
except:
self.lang = "tr"
global CURRENT_LANG
CURRENT_LANG = self.lang
self.title(self.tr("app_title"))
self.geometry("1200x800")
ctk.set_appearance_mode("dark")
self.configure(fg_color=COLOR_BG)
# Uygulama İkonu
try:
if hasattr(sys, "_MEIPASS"):
base_path = sys._MEIPASS
else:
base_path = os.path.dirname(os.path.abspath(__file__))
icon_path = os.path.join(base_path, "icon.png")
if os.path.exists(icon_path):
image = Image.open(icon_path)
self.icon_photo = ImageTk.PhotoImage(image)
self.wm_iconphoto(True, self.icon_photo)
except Exception:
pass
# --- UI Layout ---
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(0, weight=1)
# Sidebar
self.sidebar = ctk.CTkFrame(self, width=200, corner_radius=0, fg_color=COLOR_SURFACE)
self.sidebar.grid(row=0, column=0, sticky="nsew")
self.logo_label = ctk.CTkLabel(self.sidebar, text="KERNEL\nMANAGER", font=("JetBrains Mono", 24, "bold"), text_color=COLOR_ACCENT_MAIN)
self.logo_label.pack(pady=20, padx=10)
# Kalıcı Yap Butonu
self.btn_make_permanent = ctk.CTkButton(self.sidebar, text=self.tr("make_permanent"), command=self.open_persistence_window, fg_color=COLOR_ACCENT_SEC, text_color=COLOR_TAB_TEXT)
self.btn_make_permanent.pack(side="bottom", pady=10, padx=10)
# Profiller Butonu
self.btn_profiles = ctk.CTkButton(self.sidebar, text=self.tr("profiles"), command=self.open_profile_window, fg_color=COLOR_ACCENT_MAIN, text_color=COLOR_TAB_TEXT)
self.btn_profiles.pack(side="bottom", pady=10, padx=10)
# Tema Değiştirici
self.switch_var = ctk.StringVar(value="on")
self.theme_switch = ctk.CTkSwitch(self.sidebar, text=self.tr("dark_mode"), command=self.toggle_theme,
variable=self.switch_var, onvalue="on", offvalue="off", progress_color=COLOR_ACCENT_MAIN)
self.theme_switch.pack(side="bottom", pady=20, padx=10)
# Dil Seçici
self.lang_var = ctk.StringVar(value=self.lang)
self.lang_combo = ctk.CTkOptionMenu(self.sidebar, variable=self.lang_var, values=["tr", "en"], command=self.change_language, width=100)
self.lang_combo.pack(side="bottom", pady=10, padx=10)
ctk.CTkLabel(self.sidebar, text=self.tr("language"), text_color=COLOR_TEXT_SEC).pack(side="bottom", pady=0)
# Main View
self.main_frame = ctk.CTkFrame(self, corner_radius=15, fg_color=COLOR_BG)
self.main_frame.grid(row=0, column=1, padx=20, pady=20, sticky="nsew")
# --- Tabview (Sekmeler) ---
self.tabview = ctk.CTkTabview(self.main_frame, fg_color=COLOR_BG,
segmented_button_fg_color=COLOR_SURFACE,
segmented_button_selected_color=COLOR_ACCENT_MAIN,
segmented_button_selected_hover_color=COLOR_ACCENT_MAIN,
segmented_button_unselected_color=COLOR_TAB_UNSELECTED,
segmented_button_unselected_hover_color=COLOR_TAB_HOVER,
text_color=COLOR_TAB_TEXT)
self.tabview.pack(fill="both", expand=True, padx=10, pady=10)
self.tab_genel = self.tabview.add(self.tr("tab_general"))
self.tab_cpu = self.tabview.add(self.tr("tab_cpu"))
self.tab_gpu = self.tabview.add(self.tr("tab_gpu"))
self.tab_disk_mem = self.tabview.add(self.tr("tab_disk_mem"))
self.tab_network = self.tabview.add(self.tr("tab_network"))
self.tab_modules = self.tabview.add(self.tr("tab_modules"))
# --- Genel Sekmesi Layout ---
self.genel_scroll = ctk.CTkScrollableFrame(self.tab_genel, fg_color="transparent")
self.genel_scroll.pack(fill="both", expand=True, padx=5, pady=5)
# 0. Header (Logo + OS Name)
self.frame_header = ctk.CTkFrame(self.genel_scroll, fg_color="transparent")
self.frame_header.pack(fill="x", pady=(10, 5), padx=5)
# OS Name Frame
self.frame_os_name = ctk.CTkFrame(self.frame_header, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.frame_os_name.pack(fill="x", expand=True)
self.lbl_ascii_logo = ctk.CTkLabel(self.frame_os_name, text="", font=FONT_MONO, justify="left", text_color=COLOR_ACCENT_SEC)
self.lbl_ascii_logo.pack(side="left", padx=(20, 10), pady=10)
self.lbl_os_big = ctk.CTkLabel(self.frame_os_name, text="Linux", font=("Inter", 32, "bold"), text_color=COLOR_TEXT_MAIN)
self.lbl_os_big.pack(side="left", padx=10)
# 1. Sistem Bilgileri
self.frame_os = ctk.CTkFrame(self.genel_scroll, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.frame_os.pack(fill="x", pady=5, padx=5)
ctk.CTkLabel(self.frame_os, text=self.tr("system_info"), font=FONT_SUBHEADER, text_color=COLOR_ACCENT_MAIN).pack(anchor="w", padx=10, pady=5)
self.lbl_os_info = ctk.CTkLabel(self.frame_os, text="...", justify="left", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_os_info.pack(anchor="w", padx=10, pady=(0, 10))
# 2. CPU
self.frame_cpu_genel = ctk.CTkFrame(self.genel_scroll, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.frame_cpu_genel.pack(fill="x", pady=5, padx=5)
ctk.CTkLabel(self.frame_cpu_genel, text=self.tr("processor"), font=FONT_SUBHEADER, text_color=COLOR_ACCENT_MAIN).pack(anchor="w", padx=10, pady=5)
self.lbl_cpu_genel = ctk.CTkLabel(self.frame_cpu_genel, text="...", justify="left", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_cpu_genel.pack(anchor="w", padx=10, pady=(0, 10))
# 3. GPU
self.frame_gpu_genel = ctk.CTkFrame(self.genel_scroll, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.frame_gpu_genel.pack(fill="x", pady=5, padx=5)
ctk.CTkLabel(self.frame_gpu_genel, text=self.tr("graphics"), font=FONT_SUBHEADER, text_color=COLOR_ACCENT_MAIN).pack(anchor="w", padx=10, pady=5)
self.lbl_gpu_genel = ctk.CTkLabel(self.frame_gpu_genel, text="...", justify="left", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_gpu_genel.pack(anchor="w", padx=10, pady=(0, 10))
# 4. Bellek & Disk
self.frame_storage = ctk.CTkFrame(self.genel_scroll, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.frame_storage.pack(fill="x", pady=5, padx=5)
ctk.CTkLabel(self.frame_storage, text=self.tr("memory_disk"), font=FONT_SUBHEADER, text_color=COLOR_ACCENT_MAIN).pack(anchor="w", padx=10, pady=5)
self.lbl_storage_genel = ctk.CTkLabel(self.frame_storage, text="...", justify="left", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_storage_genel.pack(anchor="w", padx=10, pady=(0, 10))
# 5. Batarya (Varsayılan olarak gizli, varsa gösterilir)
self.frame_battery = ctk.CTkFrame(self.genel_scroll, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.lbl_battery_header = ctk.CTkLabel(self.frame_battery, text=self.tr("battery"), font=FONT_SUBHEADER, text_color=COLOR_ACCENT_MAIN)
self.lbl_battery_header.pack(anchor="w", padx=10, pady=5)
self.lbl_battery_info = ctk.CTkLabel(self.frame_battery, text="...", justify="left", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_battery_info.pack(anchor="w", padx=10, pady=(0, 10))
# --- Disk ve Bellek Tab İçeriği ---
self.ram_frame = ctk.CTkFrame(self.tab_disk_mem, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.ram_frame.pack(pady=10, padx=10, fill="x")
# RAM Left (Info) & Right (Chart)
self.ram_left = ctk.CTkFrame(self.ram_frame, fg_color="transparent")
self.ram_left.pack(side="left", fill="both", expand=True, padx=10, pady=10)
self.ram_right = ctk.CTkFrame(self.ram_frame, fg_color="transparent")
self.ram_right.pack(side="right", fill="both", padx=10, pady=10)
ctk.CTkLabel(self.ram_left, text="RAM", font=FONT_HEADER, text_color=COLOR_ACCENT_MAIN).pack(pady=5, anchor="w")
self.lbl_ram_total = ctk.CTkLabel(self.ram_left, text=f"{self.tr('ram_capacity')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_ram_total.pack(pady=2, anchor="w")
self.lbl_ram_usage = ctk.CTkLabel(self.ram_left, text=f"{self.tr('usage')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_ram_usage.pack(pady=2, anchor="w")
self.ram_progress = ctk.CTkProgressBar(self.ram_left, width=300, progress_color=COLOR_ACCENT_MAIN)
self.ram_progress.pack(pady=5, anchor="w")
self.ram_progress.set(0)
self.ram_stats_frame = ctk.CTkFrame(self.ram_left, fg_color="transparent")
self.ram_stats_frame.pack(pady=5, fill="x", anchor="w")
self.lbl_ram = ctk.CTkLabel(self.ram_stats_frame, text=f"{self.tr('ram_speed')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_ram.pack(side="left", padx=(0, 10))
# ZRAM Section (New Layout)
ctk.CTkLabel(self.ram_left, text="ZRAM", font=FONT_HEADER, text_color=COLOR_ACCENT_MAIN).pack(pady=(20, 5), anchor="w")
self.zram_stats_frame = ctk.CTkFrame(self.ram_left, fg_color="transparent")
self.zram_stats_frame.pack(fill="x", anchor="w")
self.lbl_zram_stats = ctk.CTkLabel(self.zram_stats_frame, text=f"{self.tr('status')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_zram_stats.pack(anchor="w")
self.zram_control_frame = ctk.CTkFrame(self.ram_left, fg_color="transparent")
self.zram_control_frame.pack(fill="x", pady=5, anchor="w")
self.zram_algo_var = ctk.StringVar(value="")
self.cmb_zram_algo = ctk.CTkOptionMenu(self.zram_control_frame, variable=self.zram_algo_var, values=[], command=self.change_zram_algo, width=100, fg_color=COLOR_SURFACE, button_color=COLOR_ACCENT_MAIN)
self.cmb_zram_algo.pack(side="left", padx=(0, 10))
self.entry_zram_size = ctk.CTkEntry(self.zram_control_frame, width=80, placeholder_text=self.tr("size_placeholder"))
self.entry_zram_size.pack(side="left", padx=(0, 5))
self.btn_zram_size = ctk.CTkButton(self.zram_control_frame, text=self.tr("set"), width=60, command=self.change_zram_size, fg_color=COLOR_ACCENT_MAIN, text_color=("white", "black"))
self.btn_zram_size.pack(side="left")
# RAM Chart (Right)
self.ram_chart = LineChart(self.ram_right, width=350, height=120, line_color=COLOR_ACCENT_SEC)
self.ram_chart.pack(pady=10)
# --- Disk Frame ---
self.disk_frame = ctk.CTkFrame(self.tab_disk_mem, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.disk_frame.pack(pady=10, padx=10, fill="x")
# Disk Left (Info) & Right (Chart)
self.disk_left = ctk.CTkFrame(self.disk_frame, fg_color="transparent")
self.disk_left.pack(side="left", fill="both", expand=True, padx=10, pady=10)
self.disk_right = ctk.CTkFrame(self.disk_frame, fg_color="transparent")
self.disk_right.pack(side="right", fill="both", padx=10, pady=10)
ctk.CTkLabel(self.disk_left, text=self.tr("disk_status"), font=FONT_HEADER, text_color=COLOR_ACCENT_MAIN).pack(pady=5, anchor="w")
self.lbl_disk_root = ctk.CTkLabel(self.disk_left, text=f"{self.tr('root_disk')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_disk_root.pack(pady=2, anchor="w")
self.lbl_disk_home = ctk.CTkLabel(self.disk_left, text=f"{self.tr('home_disk')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_disk_home.pack(pady=2, anchor="w")
self.disk_sched_frame = ctk.CTkFrame(self.disk_left, fg_color="transparent")
self.disk_sched_frame.pack(pady=2, anchor="w", fill="x")
ctk.CTkLabel(self.disk_sched_frame, text="Scheduler:", font=FONT_MONO, text_color=COLOR_TEXT_SEC).pack(side="left", padx=(0,5))
self.disk_sched_var = ctk.StringVar(value="")
self.cmb_disk_sched = ctk.CTkOptionMenu(self.disk_sched_frame, variable=self.disk_sched_var, values=[], command=self.change_disk_scheduler, width=120, fg_color=COLOR_SURFACE, button_color=COLOR_ACCENT_MAIN)
self.cmb_disk_sched.pack(side="left")
self.lbl_disk_load = ctk.CTkLabel(self.disk_left, text=f"{self.tr('disk_load')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_disk_load.pack(pady=2, anchor="w")
self.lbl_disk_speed = ctk.CTkLabel(self.disk_left, text=f"{self.tr('disk_speed')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_disk_speed.pack(pady=2, anchor="w")
self.lbl_disk_temp = ctk.CTkLabel(self.disk_left, text=f"{self.tr('temperature')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_disk_temp.pack(pady=2, anchor="w")
# Disk Chart (Right)
self.disk_chart = LineChart(self.disk_right, width=350, height=120, line_color=COLOR_ACCENT_MAIN, line_color2=COLOR_WARNING, auto_scale=True)
self.disk_chart.pack(pady=10)
# --- Network Tab Layout ---
self.network_frame = ctk.CTkFrame(self.tab_network, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.network_frame.pack(pady=10, padx=10, fill="x")
# Network Left (Info) & Right (Chart)
self.net_left = ctk.CTkFrame(self.network_frame, fg_color="transparent")
self.net_left.pack(side="left", fill="both", expand=True, padx=10, pady=10)
self.net_right = ctk.CTkFrame(self.network_frame, fg_color="transparent")
self.net_right.pack(side="right", fill="both", padx=10, pady=10)
ctk.CTkLabel(self.net_left, text=self.tr("network_status"), font=FONT_HEADER, text_color=COLOR_ACCENT_MAIN).pack(pady=5, anchor="w")
self.lbl_net_interface = ctk.CTkLabel(self.net_left, text=f"{self.tr('interface')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_net_interface.pack(pady=2, anchor="w")
self.lbl_net_name = ctk.CTkLabel(self.net_left, text=f"{self.tr('network_name')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_net_name.pack(pady=2, anchor="w")
self.lbl_net_ip = ctk.CTkLabel(self.net_left, text=f"{self.tr('ip_address')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_net_ip.pack(pady=2, anchor="w")
self.lbl_net_dns = ctk.CTkLabel(self.net_left, text=f"DNS: ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_net_dns.pack(pady=2, anchor="w")
self.lbl_net_speed_down = ctk.CTkLabel(self.net_left, text=f"{self.tr('download')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_net_speed_down.pack(pady=2, anchor="w")
self.lbl_net_speed_up = ctk.CTkLabel(self.net_left, text=f"{self.tr('upload')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_net_speed_up.pack(pady=2, anchor="w")
self.lbl_net_total = ctk.CTkLabel(self.net_left, text=f"{self.tr('total')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_net_total.pack(pady=2, anchor="w")
# Network Chart (Right)
self.net_chart = LineChart(self.net_right, width=350, height=120, line_color=COLOR_ACCENT_MAIN)
self.net_chart.pack(pady=10)
# --- CPU Tab İçeriği ---
self.cpu_info_frame = ctk.CTkFrame(self.tab_cpu, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.cpu_info_frame.pack(pady=10, padx=10, fill="x")
ctk.CTkLabel(self.cpu_info_frame, text=self.tr("processor"), font=FONT_HEADER, text_color=COLOR_ACCENT_MAIN).pack(pady=5)
self.lbl_cpu_name = ctk.CTkLabel(self.cpu_info_frame, text="CPU: ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_cpu_name.pack(pady=2)
self.lbl_cpu_cores = ctk.CTkLabel(self.cpu_info_frame, text=f"{self.tr('cores')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_cpu_cores.pack(pady=2)
self.gov_frame = ctk.CTkFrame(self.cpu_info_frame, fg_color="transparent")
self.gov_frame.pack(pady=2)
ctk.CTkLabel(self.gov_frame, text="Governor:", font=FONT_MONO, text_color=COLOR_TEXT_SEC).pack(side="left", padx=(0, 5))
self.cpu_gov_var = ctk.StringVar(value="...")
self.cmb_cpu_gov = ctk.CTkOptionMenu(self.gov_frame, variable=self.cpu_gov_var, values=[], command=self.change_cpu_governor, width=150, fg_color=COLOR_SURFACE, button_color=COLOR_ACCENT_MAIN, button_hover_color=COLOR_ACCENT_MAIN, text_color=COLOR_TEXT_MAIN)
self.cmb_cpu_gov.pack(side="left")
self.epp_frame = ctk.CTkFrame(self.cpu_info_frame, fg_color="transparent")
# Pack işlemi update_ui_from_data içinde dinamik yapılır
ctk.CTkLabel(self.epp_frame, text="EPP:", font=FONT_MONO, text_color=COLOR_TEXT_SEC).pack(side="left", padx=(0, 5))
self.cpu_epp_var = ctk.StringVar(value="...")
self.cmb_cpu_epp = ctk.CTkOptionMenu(self.epp_frame, variable=self.cpu_epp_var, values=[], command=self.change_cpu_epp, width=150, fg_color=COLOR_SURFACE, button_color=COLOR_ACCENT_MAIN)
self.cmb_cpu_epp.pack(side="left")
self.epp_frame.pack_forget()
self.freq_limit_frame = ctk.CTkFrame(self.cpu_info_frame, fg_color="transparent")
self.freq_limit_frame.pack(pady=2)
ctk.CTkLabel(self.freq_limit_frame, text="Min:", font=FONT_MONO, text_color=COLOR_TEXT_SEC).pack(side="left", padx=(0, 5))
self.cpu_min_var = ctk.StringVar(value="...")
self.cmb_cpu_min = ctk.CTkOptionMenu(self.freq_limit_frame, variable=self.cpu_min_var, values=[], command=self.change_cpu_min_freq, width=100, fg_color=COLOR_SURFACE, button_color=COLOR_ACCENT_MAIN)
self.cmb_cpu_min.pack(side="left", padx=(0, 10))
ctk.CTkLabel(self.freq_limit_frame, text="Max:", font=FONT_MONO, text_color=COLOR_TEXT_SEC).pack(side="left", padx=(0, 5))
self.cpu_max_var = ctk.StringVar(value="...")
self.cmb_cpu_max = ctk.CTkOptionMenu(self.freq_limit_frame, variable=self.cpu_max_var, values=[], command=self.change_cpu_max_freq, width=100, fg_color=COLOR_SURFACE, button_color=COLOR_ACCENT_MAIN)
self.cmb_cpu_max.pack(side="left")
# CPU Chart
self.cpu_chart = LineChart(self.cpu_info_frame, width=500, height=100, line_color=COLOR_ACCENT_MAIN)
self.cpu_chart.pack(pady=10)
self.cpu_stats_frame = ctk.CTkFrame(self.cpu_info_frame, fg_color="transparent")
self.cpu_stats_frame.pack(pady=5, fill="x")
self.lbl_freq = ctk.CTkLabel(self.cpu_stats_frame, text=f"{self.tr('frequency')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_freq.pack(side="left", expand=True)
self.lbl_temp = ctk.CTkLabel(self.cpu_stats_frame, text=f"{self.tr('temperature')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_temp.pack(side="left", expand=True)
self.lbl_fan = ctk.CTkLabel(self.cpu_stats_frame, text=f"{self.tr('fan')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_fan.pack(side="left", expand=True)
self.cpu_cores_scroll = ctk.CTkScrollableFrame(self.tab_cpu, label_text=self.tr("core_details"), fg_color=COLOR_SURFACE, label_text_color=COLOR_ACCENT_MAIN, label_font=FONT_SUBHEADER)
self.cpu_cores_scroll.pack(pady=10, padx=10, fill="both", expand=True)
# --- GPU Tab İçeriği ---
self.gpu_info_frame = ctk.CTkFrame(self.tab_gpu, fg_color=COLOR_SURFACE, border_color=COLOR_BORDER, border_width=1, corner_radius=8)
self.gpu_info_frame.pack(pady=10, padx=10, fill="x")
ctk.CTkLabel(self.gpu_info_frame, text=self.tr("graphics"), font=FONT_HEADER, text_color=COLOR_ACCENT_MAIN).pack(pady=5)
self.lbl_gpu_name = ctk.CTkLabel(self.gpu_info_frame, text="GPU: ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_gpu_name.pack(pady=2)
self.gpu_gov_frame = ctk.CTkFrame(self.gpu_info_frame, fg_color="transparent")
self.gpu_gov_frame.pack(pady=2)
ctk.CTkLabel(self.gpu_gov_frame, text="Governor:", font=FONT_MONO, text_color=COLOR_TEXT_SEC).pack(side="left", padx=(0, 5))
self.gpu_gov_var = ctk.StringVar(value="...")
self.cmb_gpu_gov = ctk.CTkOptionMenu(self.gpu_gov_frame, variable=self.gpu_gov_var, values=[], command=self.change_gpu_governor, width=150, fg_color=COLOR_SURFACE, button_color=COLOR_ACCENT_MAIN)
self.cmb_gpu_gov.pack(side="left")
self.gpu_stats_frame = ctk.CTkFrame(self.gpu_info_frame, fg_color="transparent")
self.gpu_stats_frame.pack(pady=5, fill="x")
self.lbl_gpu_temp = ctk.CTkLabel(self.gpu_stats_frame, text=f"{self.tr('temperature')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_gpu_temp.pack(side="left", expand=True)
self.lbl_gpu_usage = ctk.CTkLabel(self.gpu_stats_frame, text=f"{self.tr('usage')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_gpu_usage.pack(side="left", expand=True)
self.lbl_gpu_freq = ctk.CTkLabel(self.gpu_stats_frame, text=f"{self.tr('frequency')} ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_gpu_freq.pack(side="left", expand=True)
self.lbl_gpu_vram = ctk.CTkLabel(self.gpu_stats_frame, text="VRAM: ...", font=FONT_MONO, text_color=COLOR_TEXT_SEC)
self.lbl_gpu_vram.pack(side="left", expand=True)
# --- Modüller Tab İçeriği ---
self.module_textbox = ctk.CTkTextbox(self.tab_modules, width=500, height=300, fg_color=COLOR_SURFACE, text_color=COLOR_TEXT_MAIN, font=FONT_MONO)
self.module_textbox.pack(pady=10, padx=10, fill="both", expand=True)
self.prev_stats = None
self.core_widgets = {}
self.prev_disk_io = None
self.prev_disk_time = None
self.prev_disk_read = None
self.prev_disk_write = None
self.prev_net_bytes_recv = 0
self.prev_net_bytes_sent = 0
self.prev_net_time = 0
# Threading Variables
self.shared_data = {} # Thread ile UI arasındaki veri köprüsü
self.thread_lock = threading.Lock()
self.zram_changing = False
self.jupyter_compat = JupyterCompatibilityWrapper()
self.jupyter_compat.handshake_hardware_limits()
self.refresh_all()
self.auto_refresh()
def tr(self, key):
lang_data = TRANSLATIONS.get(self.lang)
if lang_data is None:
lang_data = TRANSLATIONS.get("tr", {})
return lang_data.get(key, key)
def change_language(self, choice):
self.lang = choice
global CURRENT_LANG
CURRENT_LANG = choice
# Ayarı kaydet
self.settings.data["language"] = choice
self.settings.save()
# Otomatik Yeniden Başlat
self.stop_thread = True
self.destroy()
# Restart Logic
# Nuitka compiled check: __compiled__ or sys.frozen
is_compiled = "__compiled__" in globals() or getattr(sys, 'frozen', False)
if is_compiled:
executable = sys.executable
# Derlenmiş modda sys.argv[0] genellikle binary yoludur ve daha güvenilirdir
if sys.argv and os.path.exists(sys.argv[0]):
executable = sys.argv[0]
executable = os.path.abspath(executable)
# os.execl yerine Popen kullanmak onefile modunda daha kararlıdır
subprocess.Popen([executable] + sys.argv[1:])
else:
subprocess.Popen([sys.executable] + sys.argv)
sys.exit(0)
def toggle_theme(self):
if self.switch_var.get() == "on":
ctk.set_appearance_mode("Dark")
mode = "Dark"
else:
ctk.set_appearance_mode("Light")
mode = "Light"
# Grafikleri manuel güncelle
self.cpu_chart.update_theme(mode)
self.ram_chart.update_theme(mode)
self.disk_chart.update_theme(mode)
self.net_chart.update_theme(mode)
def refresh_all(self):
self.update_fastfetch_info()
self.get_hardware_info()
# İlk açılışta veriyi manuel tetiklemeye gerek yok, thread zaten çalışacak
# Ancak UI güncellemesini başlatıyoruz.
self.update_module_list()
# Arka plan thread'ini başlat
self.stop_thread = False
self.monitor_thread = threading.Thread(target=self.background_monitor_loop, daemon=True)
self.monitor_thread.start()
def change_cpu_governor(self, new_gov):
k_actions.set_cpu_governor(new_gov)
def change_cpu_epp(self, new_epp):
k_actions.set_cpu_epp(new_epp)
def change_cpu_min_freq(self, choice):
k_actions.set_cpu_min_freq(choice)
def change_cpu_max_freq(self, choice):
k_actions.set_cpu_max_freq(choice)
def change_zram_algo(self, new_algo):
def _change():
self.zram_changing = True
try:
# ZRAM algoritmasını değiştirmek için cihazı resetlemek gerekir.
# Adımlar: swapoff -> reset -> algo set -> disksize set -> mkswap -> swapon
# 1. Mevcut boyutu al
disksize = "0"
if os.path.exists("/sys/block/zram0/disksize"):
with open("/sys/block/zram0/disksize", "r") as f:
disksize = f.read().strip()
if disksize == "0": return
# 2. Swapoff
try:
subprocess.run([get_cmd("swapoff"), "/dev/zram0"], check=True, stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError:
pass # Zaten kapalı olabilir veya hata verebilir, devam etmeyi dene
# 3. Reset
with open("/sys/block/zram0/reset", "w") as f:
f.write("1")
# 4. Algoritma değiştir
with open("/sys/block/zram0/comp_algorithm", "w") as f:
f.write(new_algo)
# 5. Boyutu geri yükle
with open("/sys/block/zram0/disksize", "w") as f:
f.write(disksize)
# 6. Mkswap & Swapon
subprocess.run([get_cmd("mkswap"), "/dev/zram0"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run([get_cmd("swapon"), "/dev/zram0"], check=True)
print(f"ZRAM algorithm changed to {new_algo}")
self.after(0, lambda: messagebox.showinfo(self.tr("success"), f"ZRAM: {new_algo}"))
except OSError as e:
if e.errno == 16: # Device or resource busy
self.after(0, lambda: messagebox.showerror(self.tr("error"), "ZRAM busy (Device busy)."))
else:
self.after(0, lambda: messagebox.showerror(self.tr("error"), f"ZRAM I/O Error: {e}"))
except Exception as e:
print(f"ZRAM Change Error: {e}")
self.after(0, lambda: messagebox.showerror(self.tr("error"), f"ZRAM Error:\n{e}"))
finally:
self.zram_changing = False
threading.Thread(target=_change, daemon=True).start()
def change_zram_size(self):
new_size = self.entry_zram_size.get().strip()
if not new_size: return
def _change():
self.zram_changing = True
try:
# 1. Mevcut algo'yu al
current_algo = "lzo"
if os.path.exists("/sys/block/zram0/comp_algorithm"):
with open("/sys/block/zram0/comp_algorithm", "r") as f:
content = f.read().strip()
match = re.search(r'\[(.*?)\]', content)
if match: current_algo = match.group(1)
# 2. Swapoff
try:
subprocess.run([get_cmd("swapoff"), "/dev/zram0"], check=True, stderr=subprocess.DEVNULL)
except subprocess.CalledProcessError:
pass
# 3. Reset
with open("/sys/block/zram0/reset", "w") as f:
f.write("1")
# 4. Algo'yu geri yükle
with open("/sys/block/zram0/comp_algorithm", "w") as f:
f.write(current_algo)
# 5. Yeni boyutu ayarla
with open("/sys/block/zram0/disksize", "w") as f:
f.write(new_size)
# 6. Mkswap & Swapon
subprocess.run([get_cmd("mkswap"), "/dev/zram0"], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.run([get_cmd("swapon"), "/dev/zram0"], check=True)
print(f"ZRAM size changed to {new_size}")
self.after(0, lambda: messagebox.showinfo(self.tr("success"), f"ZRAM size: {new_size}"))
except OSError as e:
if e.errno == 16:
self.after(0, lambda: messagebox.showerror(self.tr("error"), "ZRAM busy (Device busy)."))
else:
self.after(0, lambda: messagebox.showerror(self.tr("error"), f"ZRAM I/O Error: {e}"))
except Exception as e:
print(f"ZRAM Size Change Error: {e}")
self.after(0, lambda: messagebox.showerror(self.tr("error"), f"ZRAM Error:\n{e}"))
finally:
self.zram_changing = False
threading.Thread(target=_change, daemon=True).start()
def change_gpu_governor(self, new_gov):
k_actions.set_gpu_governor(new_gov)
def change_disk_scheduler(self, new_sched):
k_actions.set_disk_scheduler(new_sched)
def auto_refresh(self):
self.update_ui_from_data()
self.after(1000, self.auto_refresh)
def update_fastfetch_info(self):
# OS Name
os_name = "Linux"
os_id = "linux"
try:
if os.path.exists("/etc/os-release"):
with open("/etc/os-release") as f:
for line in f:
if line.startswith("PRETTY_NAME="):
os_name = line.split("=")[1].strip().strip('"')
if line.startswith("ID="):
os_id = line.split("=")[1].strip().strip('"')
except: pass
# Host
host = "Unknown"
try:
if os.path.exists("/sys/devices/virtual/dmi/id/product_name"):
with open("/sys/devices/virtual/dmi/id/product_name", "r") as f:
host = f.read().strip()
if not host or host in ("System Product Name", "To be filled by O.E.M."):
host = subprocess.check_output(["hostname"]).decode().strip()
except: pass
# Kernel
try:
kernel = subprocess.check_output([get_cmd('uname'), '-r']).decode().strip()
except: kernel = "Unknown"
# Uptime
try:
uptime = subprocess.check_output(["uptime", "-p"]).decode().strip().replace("up ", "")
except: uptime = "Unknown"
# Shell
try:
target_user = os.environ.get('SUDO_USER')
if not target_user:
target_user = os.environ.get('USER')
if target_user:
shell = pwd.getpwnam(target_user).pw_shell.split('/')[-1]
else:
shell = os.environ.get("SHELL", "/bin/bash").split("/")[-1]
except:
shell = "Unknown"
# CPU
cpu = "Unknown"
try:
with open("/proc/cpuinfo", "r") as f:
for line in f:
if "model name" in line:
cpu = line.split(":", 1)[1].strip()
break
except: pass
# GPU
gpu = "Unknown"
try:
gpu = subprocess.check_output(f"{get_cmd('lspci')} | grep -E 'VGA|3D' | cut -d: -f3", shell=True).decode().strip().split('\n')[0]
except: pass
# Memory
mem = "Unknown"
try:
with open("/proc/meminfo", "r") as f:
meminfo = f.read()
total_m = re.search(r'MemTotal:\s+(\d+)', meminfo)
avail_m = re.search(r'MemAvailable:\s+(\d+)', meminfo)
if total_m and avail_m:
t_kb = int(total_m.group(1))
a_kb = int(avail_m.group(1))
u_kb = t_kb - a_kb
mem_percent = (u_kb / t_kb) * 100
mem = f"{u_kb // 1024 // 1024}G / {t_kb // 1024 // 1024}G (%{mem_percent:.1f})"
except: pass
# Disk (Root)
disk = "Unknown"
try:
total, used, free = shutil.disk_usage("/")
disk_percent = (used / total) * 100
disk = f"{used // (2**30)}G / {total // (2**30)}G (%{disk_percent:.1f})"
except: pass
# Batarya Kontrolü
battery_info = None
try:
bats = glob.glob("/sys/class/power_supply/BAT*")
if bats:
# İlk bataryayı al
bat_path = bats[0]
with open(os.path.join(bat_path, "capacity"), "r") as f:
cap = f.read().strip()
with open(os.path.join(bat_path, "status"), "r") as f:
status = f.read().strip()
battery_info = f"{self.tr('battery_full')}: %{cap}\n{self.tr('battery_status')}: {status}"
except: pass
# ASCII Logo Seçimi
logos = {
"arch": """
/\\
/ \\
/ \\
/ \\
/ ,, \\
/ | | \\
/_-'' ''-_\\
""",
"ubuntu": """
_
---(_)
_(o)__ _
(_)_ _) (_)
(_)---
""",
"debian": """
_,met$$$$$gg.
,g$$$$$$$$$$$$$$$P.
,g$$P" ""Y$$.".
,$$P' `$$$.
',$$P ,ggs. `$$b:
`d$$' ,$P"' . $$$
$$P d$' , $$P
$$: $$. - ,d$$'
$$; Y$b._ _,d$P'
Y$$. `.`"Y$$$$P"'
`$$b "-.__
`Y$$
`Y$$.
`$$b.
`Y$$b.
`"Y$b._
`""
""",
"fedora": """
_____
/ __)\\
| / \\ \\
__ | |__/ /
/ _\\| |__ /
( (__| | |
\\___|__|__|
"""
}
# Varsayılan Tux
default_logo = """
.--.
|o_o |
|:_/ |
// \\ \\
(| | )
/'\\_ _/`\\
\\___)=(___/
"""
ascii_art = logos.get(os_id, default_logo).strip("\n")
# UI Güncelleme
self.lbl_ascii_logo.configure(text=ascii_art)
self.lbl_os_big.configure(text=os_name)
self.lbl_os_info.configure(text=f"{self.tr('host')}: {host}\n{self.tr('kernel')}: {kernel}\n{self.tr('uptime')}: {uptime}\n{self.tr('shell')}: {shell}")
self.lbl_cpu_genel.configure(text=cpu)
self.lbl_gpu_genel.configure(text=gpu)
self.lbl_storage_genel.configure(text=f"Memory: {mem}\nDisk (/): {disk}")
# Batarya Frame Göster/Gizle
if battery_info:
self.frame_battery.pack(fill="x", pady=5, padx=5)
self.lbl_battery_info.configure(text=battery_info)
else:
self.frame_battery.pack_forget()
def get_hardware_info(self):
# CPU Model İsmi
if hasattr(self, 'lbl_cpu_name') and self.lbl_cpu_name.winfo_exists():
try:
cpu = "Unknown"
with open("/proc/cpuinfo", "r") as f:
for line in f:
if "model name" in line:
cpu = line.split(":", 1)[1].strip()
break
self.lbl_cpu_name.configure(text=f"CPU: {cpu}")
except:
self.lbl_cpu_name.configure(text="CPU: Bilinmiyor")
# CPU Çekirdek Sayısı
if hasattr(self, 'lbl_cpu_cores') and self.lbl_cpu_cores.winfo_exists():
try:
self.lbl_cpu_cores.configure(text=f"{self.tr('cores')} {os.cpu_count()}")
except:
self.lbl_cpu_cores.configure(text="Çekirdek: Bilinmiyor")
# GPU Model İsmi (lspci gerektirir)
try:
# VGA veya 3D controller satırını bul ve ismini al
gpu = subprocess.check_output(f"{get_cmd('lspci')} | grep -E 'VGA|3D' | cut -d: -f3", shell=True).decode().strip().split('\n')[0]
self.lbl_gpu_name.configure(text=f"GPU: {gpu}")
except:
self.lbl_gpu_name.configure(text="GPU: Bilinmiyor (lspci kurulu mu?)")
# Toplam RAM
try:
ram = subprocess.check_output(f"{get_cmd('free')} -h | grep Mem | awk '{{print $2}}'", shell=True).decode().strip()
self.lbl_ram_total.configure(text=f"{self.tr('ram_capacity')} {ram}")
except:
self.lbl_ram_total.configure(text="RAM: Bilinmiyor")
def background_monitor_loop(self):
"""
Tüm ağır veri toplama işlemlerini yapan arka plan döngüsü.
UI thread'ini bloklamamak için subprocess ve I/O işlemleri burada yapılır.
"""
while not getattr(self, "stop_thread", False):
try:
data = {}
# 1. CPU Frekansı
try:
with open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", "r") as f:
data['cpu_freq'] = int(f.read().strip()) / 1000
except:
data['cpu_freq'] = None
# CPU Governor Info
try:
with open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "r") as f:
data['cpu_gov'] = f.read().strip()
except:
data['cpu_gov'] = "N/A"
# CPU Driver
try:
with open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver", "r") as f:
data['cpu_driver'] = f.read().strip()
except:
data['cpu_driver'] = "N/A"
try:
with open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors", "r") as f:
govs = f.read().strip().split()
if data['cpu_driver'] == 'amd-pstate-epp':
data['avail_govs'] = [g for g in govs if g in ('performance', 'powersave')]
else:
data['avail_govs'] = govs
except:
data['avail_govs'] = []
# EPP Info
try:
with open("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference", "r") as f:
data['cpu_epp'] = f.read().strip()
except:
data['cpu_epp'] = "N/A"
try:
with open("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences", "r") as f:
data['avail_epp'] = f.read().strip().split()
except:
data['avail_epp'] = []
# CPU Freq Limits
freqs = []
try:
with open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies", "r") as f:
raw = f.read().strip().split()
freqs = sorted([int(x) for x in raw])
except FileNotFoundError:
# amd-pstate-epp fix: Sürücü frekans listesi sunmuyorsa
# cpuinfo_min/max değerlerinden sanal bir liste oluştur.
try:
with open("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq", "r") as f:
min_f = int(f.read().strip())
with open("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", "r") as f:
max_f = int(f.read().strip())
step = 100000 # 100 MHz
aligned_start = ((min_f // step) + 1) * step
aligned_freqs = list(range(aligned_start, max_f, step))
freqs = sorted(list(set([min_f] + aligned_freqs + [max_f])))
except:
freqs = []
except Exception:
freqs = []
data['avail_freqs_list'] = [f"{x//1000} MHz" for x in freqs]
try:
with open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq", "r") as f:
val = int(f.read().strip())
data['current_min_freq'] = f"{val//1000} MHz"
except:
data['current_min_freq'] = "N/A"
try:
with open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq", "r") as f:
val = int(f.read().strip())
data['current_max_freq'] = f"{val//1000} MHz"
except:
data['current_max_freq'] = "N/A"
# 2. Sensörler (Sıcaklık, Fan)
data['sensors'] = sys_info.scan_sensors()
# 3. GPU Verileri (Subprocess içerir - Ağır İşlem)
gpu_data = {'temp': None, 'usage': None, 'vram_used': 0, 'vram_total': 0, 'freq': None, 'gov': 'N/A', 'avail_govs': []}
# NVIDIA Check
try:
out = subprocess.check_output(f"{get_cmd('nvidia-smi')} --query-gpu=temperature.gpu,utilization.gpu,memory.used,memory.total,clocks.gr --format=csv,noheader,nounits", shell=True, stderr=subprocess.DEVNULL).decode().strip()
parts = out.split(',')
if len(parts) >= 5:
gpu_data['temp'] = float(parts[0])
gpu_data['usage'] = float(parts[1])
gpu_data['vram_used'] = int(float(parts[2]))
gpu_data['vram_total'] = int(float(parts[3]))
gpu_data['freq'] = f"{int(float(parts[4]))} MHz"
except:
# AMD/Intel Fallback
if data['sensors'].get('gpu_temp') is not None:
gpu_data['temp'] = data['sensors']['gpu_temp']
# AMD Kart Bulma
best_card_path = sys_info.get_gpu_sysfs_path()
# AMD Usage
if best_card_path and os.path.exists(os.path.join(best_card_path, "gpu_busy_percent")):
try:
with open(os.path.join(best_card_path, "gpu_busy_percent"), "r") as f:
gpu_data['usage'] = int(f.read().strip())
except: pass
# AMD VRAM
try:
vram_used_path = os.path.join(best_card_path, "mem_info_vram_used") if best_card_path else ""
vram_total_path = os.path.join(best_card_path, "mem_info_vram_total") if best_card_path else ""
if os.path.exists(vram_used_path) and os.path.exists(vram_total_path):
with open(vram_used_path, "r") as f:
gpu_data['vram_used'] = int(f.read().strip()) // (1024**2)
with open(vram_total_path, "r") as f:
gpu_data['vram_total'] = int(f.read().strip()) // (1024**2)
except: pass
# AMD Freq
try:
freq_path = os.path.join(best_card_path, "pp_dpm_sclk") if best_card_path else ""
if os.path.exists(freq_path):
with open(freq_path, "r") as f:
content = f.read()
match = re.search(r'(\d+)Mhz\s*\*', content)
if match: gpu_data['freq'] = f"{match.group(1)} MHz"
except: pass
# GPU Governor / Power Profile (AMD/Intel)
try:
gov_path = os.path.join(best_card_path, "power_dpm_force_performance_level") if best_card_path else ""
if os.path.exists(gov_path):
with open(gov_path, "r") as f:
gpu_data['gov'] = f.read().strip()
gpu_data['avail_govs'] = ['auto', 'low', 'high']
except: pass
data['gpu'] = gpu_data
# 4. RAM Hızı (Subprocess - Ağır)
try:
cmd = f"{get_cmd('dmidecode')} -t memory | grep 'Configured Memory Speed:' | head -1 | awk -F: '{{print $2}}'"
data['ram_speed'] = subprocess.check_output(cmd, shell=True, stderr=subprocess.DEVNULL).decode("utf-8").strip()
except: