-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod
More file actions
506 lines (415 loc) · 14.7 KB
/
Copy pathmod
File metadata and controls
506 lines (415 loc) · 14.7 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
######################################################### WICHT.bat ###############################################################################
@echo off
setlocal EnableDelayedExpansion
color F0
:: Wicht-Zeichen definieren
set z0=,
set z1=-
set z2=`
:: Anfangsgeschwindigkeit in Millisekunden
set "speed=200"
set "sync=0"
:: Cursor ausblenden
<nul set /p=[?25l
:mainloop
cls
echo WICHT FLITZT!
echo ----------------------------------------
echo [1] Ultra (20 ms)
echo [2] Schnell (50 ms)
echo [3] Mittel (200 ms)
echo [4] Langsam (600 ms)
echo [5] Sehr langsam (1200 ms)
echo [S] System-Sync (CPU-gesteuert)
echo [Q] Beenden
echo.
echo choose
choice /c 12345SQ /n >nul
set "choice=%errorlevel%"
set "sync=0"
if "%choice%"=="1" set "speed=20"
if "%choice%"=="2" set "speed=50"
if "%choice%"=="3" set "speed=200"
if "%choice%"=="4" set "speed=600"
if "%choice%"=="5" set "speed=1200"
if "%choice%"=="6" set "sync=1"
if "%choice%"=="7" goto ende
cls
:: Flitzschleife
:flitz
:: Bei Systemsync: CPU-Last holen und daraus speed berechnen
if "!sync!"=="1" (
for /f "skip=1 tokens=1" %%C in ('wmic cpu get loadpercentage') do (
if not defined cpuLoad set "cpuLoad=%%C"
)
set /a speed = 1200 - (!cpuLoad! * 10)
if !speed! lss 50 set speed=50
set "cpuLoad="
)
:: Position & Symbol
set /a "x=(!random! %% 80) + 1"
set /a "y=(!random! %% 25) + 1"
set /a "z=(!random! %% 3)"
if "!z!"=="0" set "sym=%z0%"
if "!z!"=="1" set "sym=%z1%"
if "!z!"=="2" set "sym=%z2%"
cls
:: Cursor setzen und Symbol anzeigen
call :setCursor !y! !x!
<nul set /p=!sym!
:: Pause nach Geschwindigkeit
ping -n 1 -w !speed! 127.0.0.1 >nul
:: Tastendruck prüfen (non-blocking)
choice /c 12345SQ /n /t 0 /d 0 >nul 2>nul
if not errorlevel 255 (
goto mainloop
)
goto flitz
:setCursor
<nul set /p=[%1;%2H
exit /b
:ende
<nul set /p=[?25h
color 07
cls
pause
########################################################################################################################################################
############################################################## WICHT.sh #########################################################################
#!/bin/bash
# Wicht-Zeichen definieren
zeichen=( "," "-" "\`" )
# Anfangsgeschwindigkeit in ms
speed=200
sync=0
# Terminal vorbereiten: Cursor aus, weißer Hintergrund, schwarzer Text
tput civis
echo -ne "\033[47;30m" # Weißer Hintergrund (47), schwarzer Text (30)
# Funktion: Cursorposition setzen
set_cursor() {
tput cup "$1" "$2"
}
# Funktion: CPU-Auslastung holen
get_cpu_load() {
if command -v mpstat &>/dev/null; then
# Linux mit mpstat
idle=$(mpstat 1 1 | awk '/Average/ {print 100 - $NF}')
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
idle=$(top -l 1 | awk '/CPU usage/ {gsub("%",""); print 100 - $7}')
else
idle=50
fi
echo ${idle%.*}
}
# Hauptmenü
while true; do
clear
echo "WICHT FLITZT!"
echo "----------------------------------------"
echo "[1] Ultra (20 ms)"
echo "[2] Schnell (50 ms)"
echo "[3] Mittel (200 ms)"
echo "[4] Langsam (600 ms)"
echo "[5] Sehr langsam (1200 ms)"
echo "[S] System-Sync (CPU-gesteuert)"
echo "[Q] Beenden"
echo
echo -n "choose: "
read -rsn1 key
sync=0
case "$key" in
1) speed=20 ;;
2) speed=50 ;;
3) speed=200 ;;
4) speed=600 ;;
5) speed=1200 ;;
[Ss]) sync=1 ;;
[Qq]) break ;;
*) continue ;;
esac
# Flitzmodus
while true; do
if [ "$sync" -eq 1 ]; then
cpu_load=$(get_cpu_load)
speed=$((1200 - cpu_load * 10))
[ "$speed" -lt 50 ] && speed=50
fi
cols=$(tput cols)
lines=$(tput lines)
x=$((RANDOM % cols))
y=$((RANDOM % lines))
z=$((RANDOM % 3))
sym=${zeichen[$z]}
clear
set_cursor "$y" "$x"
echo -ne "$sym"
# Wartezeit
sleep $(awk "BEGIN {print $speed/1000}")
# Tastenabfrage ohne Enter
read -t 0.001 -rsn1 newkey
if [[ "$newkey" =~ [1-5SsQq] ]]; then
break
fi
done
done
# Cursor zurück, Farben zurücksetzen
tput cnorm
echo -ne "\033[0m"
clear
################################################################################################################################################################
############################################################# WICHT_VISUAL.py ##################################################################################
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Color, Rectangle, Line
from kivy.clock import Clock
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
import random
import math
import subprocess
import platform
class WichtSimulation(Widget):
def __init__(self, sync_mode="none", **kwargs):
super(WichtSimulation, self).__init__(**kwargs)
self.sync_mode = sync_mode # "cpu", "ping", or "none"
self.flitz_timer = 0
self.flitz_delay = 6
self.wicht_line = None
self.sync_value = 0
Clock.schedule_interval(self.update_sync, 1.0)
Clock.schedule_interval(self.update, 1.0 / 60.0)
def update_sync(self, dt):
if self.sync_mode == "cpu":
self.sync_value = self.get_cpu_load()
elif self.sync_mode == "ping":
self.sync_value = self.get_ping_ms()
if self.sync_mode in ["cpu", "ping"]:
scaled = 12 - int((min(self.sync_value, 100) / 100.0) * 9)
self.flitz_delay = max(3, min(12, scaled))
elif self.sync_mode == "none":
self.flitz_delay = 6
def get_cpu_load(self):
try:
if platform.system() == "Windows":
output = subprocess.check_output("wmic cpu get loadpercentage", shell=True)
lines = output.decode().splitlines()
for line in lines:
if line.strip().isdigit():
return int(line.strip())
elif platform.system() == "Linux":
with open('/proc/stat', 'r') as f:
first = f.readline()
cpu_data = list(map(int, first.strip().split()[1:]))
idle1 = cpu_data[3]
total1 = sum(cpu_data)
import time
time.sleep(0.1)
with open('/proc/stat', 'r') as f:
second = f.readline()
cpu_data = list(map(int, second.strip().split()[1:]))
idle2 = cpu_data[3]
total2 = sum(cpu_data)
idle = idle2 - idle1
total = total2 - total1
return int(100 * (1.0 - idle / total))
except:
return 0
def get_ping_ms(self):
try:
param = "-n" if platform.system() == "Windows" else "-c"
output = subprocess.check_output(["ping", param, "1", "8.8.8.8"])
text = output.decode(errors="ignore")
for line in text.splitlines():
if "time=" in line:
ms = line.split("time=")[1].split()[0].replace("ms", "").replace(" ", "")
return min(100, int(float(ms)))
except:
return 100
def update(self, dt):
self.canvas.clear()
with self.canvas:
Color(1, 1, 1, 1)
Rectangle(pos=self.pos, size=self.size)
if self.flitz_timer > 0:
self.flitz_timer -= 1
else:
self.wicht_line = None
if self.wicht_line is None:
self.start_x = random.randint(50, int(self.width) - 50)
self.start_y = random.randint(50, int(self.height) - 50)
if random.random() < 0.7: # häufiger gebogen
curve_angle = random.uniform(-1.0, 1.0)
curve_length = random.randint(8, 25) # maximal 5 mm (~25 px)
self.end_x = self.start_x + curve_length * math.cos(curve_angle)
self.end_y = self.start_y + curve_length * math.sin(curve_angle)
else:
angle = random.uniform(0, 2 * math.pi)
length = random.randint(8, 25) # maximal 5 mm
self.end_x = self.start_x + length * math.cos(angle)
self.end_y = self.start_y + length * math.sin(angle)
self.wicht_line = [(self.start_x, self.start_y), (self.end_x, self.end_y)]
self.flitz_timer = self.flitz_delay
if self.wicht_line:
shrink_factor = (self.flitz_delay - self.flitz_timer) / (self.flitz_delay / 4)
current_end_x = self.wicht_line[1][0] + (self.start_x - self.wicht_line[1][0]) * shrink_factor
current_end_y = self.wicht_line[1][1] + (self.start_y - self.wicht_line[1][1]) * shrink_factor
with self.canvas:
Color(0, 0, 0, 1)
Line(points=[self.wicht_line[0][0], self.wicht_line[0][1],
current_end_x, current_end_y], width=0.3) # noch dünner
class WichtSelector(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.orientation = "vertical"
self.spacing = 10
self.padding = 50
self.add_widget(Button(text="Sync mit CPU-Last", on_press=lambda x: self.start("cpu")))
self.add_widget(Button(text="Sync mit Ping", on_press=lambda x: self.start("ping")))
self.add_widget(Button(text="Freies Flitzen", on_press=lambda x: self.start("none")))
def start(self, mode):
self.clear_widgets()
self.add_widget(WichtSimulation(sync_mode=mode))
class WichtApp(App):
def build(self):
return WichtSelector()
if __name__ == "__main__":
WichtApp().run()
###############################################################################################################################################################
################################################################## WICHT_TASK_MOD.py ############################################################################
import pygame
import random
import math
import time
import threading
import psutil
from pystray import Icon, MenuItem, Menu
from PIL import Image
from ping3 import ping
# --- Konfiguration ---
WIDTH, HEIGHT = 64, 64 # Icon-Größe
ICON_SIZE = (WIDTH, HEIGHT)
TRANSPARENT = (0, 0, 0, 0)
# --- Zustand ---
flitz_timer = 0
wicht_line = None
flitz_delay = 6
pause_delay = 10
mode = 0 # 0 = Zufall, 1 = CPU, 2 = Ping
color = (0, 0, 0) # Startfarbe: Schwarz
# --- pygame Setup ---
pygame.init()
screen = pygame.Surface(ICON_SIZE, pygame.SRCALPHA)
# --- Tray Icon Setup ---
def create_image():
return Image.new("RGBA", ICON_SIZE, TRANSPARENT)
icon = Icon("Wicht", create_image())
# --- Datenquellen ---
def get_cpu_load():
return psutil.cpu_percent(interval=0.1)
def get_ping_delay():
try:
result = ping("8.8.8.8", timeout=1)
return result if result else 1
except:
return 1
# --- Update Tray Icon ---
def update_icon():
global flitz_timer, wicht_line, pause_delay, color
screen.fill(TRANSPARENT)
if flitz_timer > 0:
flitz_timer -= 1
elif wicht_line:
wicht_line = None
flitz_timer = pause_delay
if wicht_line is None and flitz_timer == 0:
start_x = random.randint(10, WIDTH - 10)
start_y = random.randint(10, HEIGHT - 10)
is_curve = random.choice([True, False]) # Bogen oder gerade Linie?
if is_curve:
angle = random.uniform(-0.3, 0.3)
length = random.randint(10, 20)
end_x = start_x + length * math.cos(angle)
end_y = start_y + length * math.sin(angle)
else:
angle = random.uniform(0, 2 * math.pi)
length = random.randint(10, 20)
end_x = start_x + length * math.cos(angle)
end_y = start_y + length * math.sin(angle)
wicht_line = ((start_x, start_y), (end_x, end_y))
flitz_timer = flitz_delay
if wicht_line:
shrink_factor = (flitz_delay - flitz_timer) / (flitz_delay / 3)
start_x, start_y = wicht_line[0]
current_end_x = int(wicht_line[1][0] + (start_x - wicht_line[1][0]) * shrink_factor)
current_end_y = int(wicht_line[1][1] + (start_y - wicht_line[1][1]) * shrink_factor)
pygame.draw.line(screen, color, wicht_line[0], (current_end_x, current_end_y), 2)
icon.icon = Image.frombytes("RGBA", ICON_SIZE, pygame.image.tostring(screen, "RGBA"))
# --- Menüaktionen ---
def on_quit(icon, item):
icon.stop()
def set_mode_random(icon, item):
global mode
mode = 0
def set_mode_cpu(icon, item):
global mode
mode = 1
def set_mode_ping(icon, item):
global mode
mode = 2
def set_color_black(icon, item):
global color
color = (0, 0, 0)
def set_color_white(icon, item):
global color
color = (255, 255, 255)
def set_color_orange(icon, item):
global color
color = (255, 165, 0)
def set_color_green(icon, item):
global color
color = (0, 255, 0)
def set_color_red(icon, item):
global color
color = (255, 0, 0)
# --- Steuerung der Pausenzeit ---
def adjust_flitz_pause():
global pause_delay
while True:
if mode == 0:
pause_delay = random.randint(10, 30)
elif mode == 1:
cpu = get_cpu_load()
pause_delay = max(3, int(30 - cpu / 3))
elif mode == 2:
delay = get_ping_delay()
pause_delay = int(min(30, max(5, delay * 100)))
time.sleep(1)
# --- Animation starten ---
def run_animation():
while True:
update_icon()
time.sleep(0.03)
# --- Menü konfigurieren ---
color_menu = Menu(
MenuItem("Schwarz", set_color_black, checked=lambda item: color == (0, 0, 0)),
MenuItem("Weiß", set_color_white, checked=lambda item: color == (255, 255, 255)),
MenuItem("Orange", set_color_orange, checked=lambda item: color == (255, 165, 0)),
MenuItem("Grün", set_color_green, checked=lambda item: color == (0, 255, 0)),
MenuItem("Rot", set_color_red, checked=lambda item: color == (255, 0, 0)),
)
icon.menu = Menu(
MenuItem("Zufällig flitzen", set_mode_random, checked=lambda item: mode == 0),
MenuItem("Synchron mit CPU", set_mode_cpu, checked=lambda item: mode == 1),
MenuItem("Synchron mit Ping", set_mode_ping, checked=lambda item: mode == 2),
Menu.SEPARATOR,
MenuItem("Farbe", color_menu),
Menu.SEPARATOR,
MenuItem("Beenden", on_quit)
)
# --- Starten ---
def start_icon():
threading.Thread(target=adjust_flitz_pause, daemon=True).start()
threading.Thread(target=run_animation, daemon=True).start()
icon.run() # Muss im Hauptthread laufen!
start_icon()
################################################################################################################################################################