(Personal project to trigger alarm when near destination (to avoid missing stops), coded in termux environment to use quickly without deployment).
A lightweight, terminal-driven location-aware alert system designed for Android environments using Termux.
This application continuously monitors the user’s GPS position and triggers an alert when approaching a predefined destination.
- 📡 Real-time GPS tracking via Termux API
- 🎯 Distance-based trigger using geodesic calculations
- 🚶 Multiple travel modes:
- Walk (100m)
- Cycle (200m)
- Car (500m)
- Public Transport (800m)
- Custom distance
- 🔔 Multi-modal alert system:
- Notification
- Audio playback
- Vibration loop
⚠️ Overshoot detection
| Component | Technology Used |
|---|---|
| Location Fetching | termux-location |
| Distance Calculation | geopy (geodesic) |
| Notifications | termux-notification |
| Audio Alerts | termux-media-player |
| Vibration | termux-vibrate |
- Install Termux from F-Droid (recommended)
- Install the Termux:API app from F-Droid or Play Store
Grant Location permission to Termux:API in Android settings.
pkg update && pkg upgrade
pkg install python termux-api gitRun:
termux-locationYou should see JSON output with latitude and longitude.
If this fails:
- Enable location services on your phone
- Grant location permission to Termux
git clone https://github.com/sri443/Location-Alarm-On-Android-Using-Termux.git
cd Location-Alarm-On-Android-Using-Termuxpip install -r requirements.txtBy default, the script expects a ringtone file path. You need to update this to match a valid audio file on your device.
Place an audio file (e.g. .mp3, .wav) somewhere accessible on your device.
Example locations:
/sdcard/Download/alarm.mp3/storage/emulated/0/Music/alarm.mp3
Open main.py and find the line where the audio file is used.
Replace it with your file path:
RINGTONE = os.path.expanduser("~/storage/downloads/your-ringtone.mp3") Make sure:
- The path is correct
- The file exists
Run this command in Termux:
termux-media-player play /sdcard/Download/alarm.mp3If the audio plays, you're good.
Audio not playing
- Check file path is correct
- Ensure file format is supported (
.mp3recommended) - Verify file exists:
ls /sdcard/Download/
Permission issues
Run:
termux-setup-storageThen restart Termux and try again.
Command not found (termux-media-player)
Install required package:
pkg install termux-apiAlso ensure the Termux:API app is installed on your phone.
No sound even though command runs
- Check phone volume
- Make sure media volume is not muted
- Try a different audio file
- Absolute file paths are required (relative paths may fail)
- Keep the file in internal storage (not restricted app folders)
Run the script:
python main.py-
Enter destination coordinates
Example:13.0827,80.2707 -
Choose travel mode or set a custom distance
(This determines how far from the destination the alarm triggers) -
The system will continuously track your location
-
Alarm will trigger when:
- You are within the selected distance
- OR you pass the destination
-
No GPS data
- Ensure location is enabled on your phone
- Check permissions for Termux and Termux:API
- Run
termux-locationmanually to verify
-
Command not found (termux-*)
- Make sure
termux-apipackage is installed
- Make sure
-
Script errors
- Reinstall dependencies:
pip install -r requirements.txt
- Reinstall dependencies:
- Works only on Android (Termux environment)
- GPS accuracy depends on device and surroundings
- Uses a wakelock to keep running even when the screen is off
- Not a true background service — may stop if Termux is closed or restricted by Android
location-alarm-termux/
│
├── main.py
├── README.md
├── requirements.txt
├── .gitignore
├── LICENSE
│
├── assets/
│ └── demo.png
│
└── docs/
└── architecture.md
- Requires Termux environment (Android only)
- GPS accuracy depends on device hardware
- No background execution
- Background service support
- Map API integration
- ETA-based smart alerts
- Custom alarm profiles
- Travel analytics
- Daily commuting
- Travel navigation
- Location-based reminders
- Accessibility support
Contributions, issues, and feature requests are welcome.
MIT License
A practical location-triggered alert system integrating mobile utilities with geospatial computation.