11#wayset 3. Created by WebMast from WALM
22
3+ #Wayset 4 update - lock buttons detect
4+
35import os
46import keyboards
7+ import keyboard as kek
8+ from time import sleep
59
610scroll_lock = []
11+ enable_led = 1
12+ toggle_key = None
713
814try :
915 scroll_lock .clear ()
1420
1521for i in range (5 ):
1622 for i in range (append_index ):
17- detect = os .system (f" sh -c 'echo 1 > /sys/class/leds/input{ i } ::scrolllock/brightness'" )
23+ detect = os .system (f" sh -c 'echo { enable_led } > /sys/class/leds/input{ i } ::scrolllock/brightness'" )
1824 if detect == 0 :
1925 if i in scroll_lock :
2026 pass
@@ -42,7 +48,7 @@ def scroll_detect_index():
4248
4349 for i in range (5 ):
4450 for i in range (append_index ):
45- detect = os .system (f" sh -c 'echo 1 > /sys/class/leds/input{ i } ::scrolllock/brightness'" )
51+ detect = os .system (f" sh -c 'echo { enable_led } > /sys/class/leds/input{ i } ::scrolllock/brightness'" )
4652 if detect == 0 :
4753 if i in scroll_lock :
4854 pass
@@ -58,17 +64,65 @@ def scroll_detect_index():
5864 else :
5965 append_index += 100
6066
67+ def toggle_led_pown ():
68+ detect_scroll = os .system (f" sh -c 'echo { enable_led } > /sys/class/leds/input{ i } ::scrolllock/brightness'" )
69+
70+ if detect_scroll == 0 :
71+ print (f'{ i } = { detect_scroll } ' )
72+
73+ if len (scroll_lock ) == keyboards .indexes :
74+ pass
75+ else :
76+ scroll_detect_index ()
77+ else :
78+ scroll_lock .remove (i )
79+ print (scroll_lock )
80+
81+ def on_key_press (event ):
82+ global toggle_key , enable_led
83+ toggle_key = event .name
84+
85+ if toggle_key == 'scroll lock' :
86+ if enable_led == 0 :
87+ enable_led = 1
88+ toggle_led_pown ()
89+ sleep (0.05 )
90+ elif enable_led == 1 :
91+ enable_led = 0
92+ toggle_led_pown ()
93+ sleep (0.05 )
94+ if toggle_key == 'num lock' :
95+ if enable_led == 0 :
96+ enable_led = 0
97+ sleep (0.05 )
98+ else :
99+ enable_led = 1
100+ sleep (0.05 )
101+ if toggle_key == 'caps lock' :
102+ if enable_led == 0 :
103+ enable_led = 0
104+ sleep (0.05 )
105+ else :
106+ enable_led = 1
107+ sleep (0.05 )
108+
109+ kek .on_press (on_key_press )
110+
61111while True :
62112 for i in scroll_lock :
63- detect_scroll = os .system (f" sh -c 'echo 1 > /sys/class/leds/input{ i } ::scrolllock/brightness'" )
64113
65- if detect_scroll == 0 :
66- print ( f' { i } = { detect_scroll } ' )
114+ if enable_led == 1 :
115+ detect_scroll = os . system ( f" sh -c 'echo { enable_led } > /sys/class/leds/input { i } ::scrolllock/brightness'" )
67116
68- if len (scroll_lock ) == keyboards .indexes :
69- pass
117+ if detect_scroll == 0 :
118+ print (f'{ i } = { detect_scroll } ' )
119+
120+ if len (scroll_lock ) == keyboards .indexes :
121+ pass
122+ else :
123+ scroll_detect_index ()
70124 else :
71- scroll_detect_index ( )
72- else :
73- scroll_lock . remove ( i )
74- print ( scroll_lock )
125+ scroll_lock . remove ( i )
126+ print ( scroll_lock )
127+ elif enable_led == 0 :
128+ pass
0 commit comments