Last active
July 5, 2025 20:50
-
-
Save ammunoz/dc583ee555ddfabb99bf40f3d12c27f8 to your computer and use it in GitHub Desktop.
Terminal Notify on Command Completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: Check has at least one argument | |
if "%~1"=="" ( | |
echo "Usage: notify.bat <command> [arguments...]" | |
exit /b 1 | |
) | |
:: Run command | |
call %* | |
:: Call Python script to fire off notification | |
python "C:\path\to\script\notify.py" %* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
from plyer import notification | |
def show_notification(command): | |
notification.notify( | |
title="Task Complete", | |
message=f"The command '{command}' has finished.", | |
app_name="Command Notifier", | |
timeout=5 # Notification duration in seconds | |
) | |
if __name__ == "__main__": | |
if len(sys.argv) < 2: | |
print("Usage: python notify.py <command>") | |
else: | |
command = " ".join(sys.argv[1:]) | |
show_notification(command) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check has at least one argument | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: $0 <command> [arguments...]" | |
exit 1 | |
fi | |
# Run command | |
"$@" | |
# Call Python script to fire off notification | |
python3 /path/to/notify.py "$*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites:
python -m ensurepip --upgrade
pip install plyer
Instructions:
notify.bat
ornotify.sh
is in directory that is in user PATH.notify.bat
with appropriate path tonotify.py
.notify timeout /t 5