오래 걸리는 작업(머신러닝 학습·대량 다운로드·테스트)이 끝났을 때 데스크톱 알림을 띄우면 매우 편합니다.
다른 일 하다가 「끝났다」 즉시 알림.
plyer — 크로스 플랫폼.
pip install plyer.
from plyer import notification.
notification.notify(title="완료", message="학습 종료", timeout=10).
Windows·Mac·Linux 모두 동일 코드로 OS 네이티브 알림.
Mac 전용 — osascript.
import subprocess.
subprocess.run(["osascript", "-e", 'display notification "메시지" with title "제목"']).
Mac의 알림 센터에 표시.
사운드 옵션도 가능.
Linux — notify-send.
subprocess.run(["notify-send", "제목", "메시지"]).
Ubuntu·GNOME 환경에서 동작.
libnotify-bin 패키지 필요할 수 있음.
음향 알림 — 더 강력한 신호.
import os; os.system("afplay /System/Library/Sounds/Glass.aiff")(Mac) 또는 print("\a")(터미널 벨).
시각·청각 동시에 알리면 놓치기 어려움 — 학습 끝나는 순간 즉시 인지.
한 줄 요약
데스크톱 알림은 plyer로 크로스 플랫폼, OS별로는 osascript(Mac)·notify-send(Linux).
음향까지 합치면 놓칠 일 없는 작업 종료 알림.
더 알아볼 것
- macOS 알림 권한 설정
- 터미널 벨 — print('\a')
- desktop-notifier — 더 풍부한 옵션