-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification.py
More file actions
116 lines (93 loc) · 2.78 KB
/
notification.py
File metadata and controls
116 lines (93 loc) · 2.78 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
"""
Notification system - Audio and visual feedback
"""
import winsound
import threading
from config import (
NOTIFICATIONS,
COMPLETION_SOUND_FREQ,
COMPLETION_SOUND_DURATION,
APP_NAME
)
# Try to import plyer for toast notifications
try:
from plyer import notification as plyer_notification
PLYER_AVAILABLE = True
except ImportError:
PLYER_AVAILABLE = False
def play_completion_sound():
"""Play a beep sound when sequence is exhausted"""
if not NOTIFICATIONS.get('sound_enabled', True):
return
def _play():
try:
winsound.Beep(COMPLETION_SOUND_FREQ, COMPLETION_SOUND_DURATION)
except Exception:
pass
# Play in background thread to avoid blocking
threading.Thread(target=_play, daemon=True).start()
def play_success_sound():
"""Play a subtle click sound for successful paste"""
def _play():
try:
# Higher frequency, shorter duration for success
winsound.Beep(1200, 50)
except Exception:
pass
threading.Thread(target=_play, daemon=True).start()
def show_toast(title: str, message: str, timeout: int = 3):
"""Show a Windows toast notification"""
if not NOTIFICATIONS.get('toast_enabled', True):
return
if not PLYER_AVAILABLE:
return
def _show():
try:
plyer_notification.notify(
title=title,
message=message,
app_name=APP_NAME,
timeout=timeout
)
except Exception:
pass
# Show in background thread to avoid blocking
threading.Thread(target=_show, daemon=True).start()
def notify_sequence_loaded(count: int):
"""Notify user that a new sequence has been loaded"""
show_toast(
APP_NAME,
f"Sequence loaded: {count} item{'s' if count != 1 else ''} ready",
timeout=2
)
def notify_paste_position(current: int, total: int):
"""Notify user of current paste position"""
if NOTIFICATIONS.get('show_position', True):
show_toast(
APP_NAME,
f"Pasted {current}/{total}",
timeout=1
)
def notify_sequence_complete(total: int):
"""Notify user that sequence is exhausted"""
play_completion_sound()
show_toast(
APP_NAME,
f"Sequence complete! All {total} items pasted.",
timeout=3
)
def notify_sequence_reset():
"""Notify user that sequence was reset"""
show_toast(
APP_NAME,
"Sequence reset to start",
timeout=2
)
def notify_no_content():
"""Notify user there's no content to paste"""
play_completion_sound()
show_toast(
APP_NAME,
"No content loaded. Copy text first with Ctrl+C",
timeout=3
)