Skip to content

mehdiz5/PrayerTime-Waybar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PrayerTime-Waybar ๐Ÿ•Œ

A Waybar module that displays Islamic prayer times and automatically plays the adhan (call to prayer). Features automatic location detection, timezone handling, and interactive mute controls with real-time status updates.

โœจ Features

  • ๐Ÿ“ Automatic Location Detection: Uses IP-based geolocation to calculate prayer times (fallback: Makkah)
  • โฐ Smart Prayer Times: Displays next prayer and countdown in Waybar tooltip
  • ๐Ÿ”” Auto Adhan Playback: Plays call to prayer at correct times with multiple audio backend support
  • ๐Ÿ”‡ Interactive Mute: Click to toggle adhan on/off with instant visual feedback
  • ๐ŸŽจ Customizable: Full control over appearance and prayer calculation methods
  • ๐Ÿ”„ Auto Refresh: Updates prayer times daily and responds to mute changes immediately
  • ๐Ÿš€ Easy Install/Uninstall: Automated scripts with backup/restore capabilities
  • โš™๏ธ Systemd Integration: Runs as a user service, starts automatically on login

๐Ÿ“‹ Requirements

Essential

  • Waybar (Wayland status bar)
  • Python 3.8+
  • jq (JSON processor for waybar scripts)
  • curl (HTTP requests)

Audio Backend (one of)

  • VLC (python-vlc library + VLC player) โ€” recommended
  • mpv
  • ffplay (from ffmpeg)

Install on Arch-based systems:

sudo pacman -S waybar python python-pip jq curl vlc

๐Ÿš€ Installation

  1. Clone the repository:

    git clone https://github.com/mehdiz5/PrayerTime-Waybar.git
    cd PrayerTime-Waybar
  2. Add your adhan audio file:

    # Copy or download your preferred adhan MP3 to the project directory
    cp /path/to/your/adhan.mp3 ./azan.mp3
    
    # Or download one (example):
    # wget https://example.com/adhan.mp3 -O azan.mp3
  3. Run the installer:

    ./install.sh

    The installer will:

    • Create a Python virtual environment
    • Install required Python packages
    • Prompt for your Waybar config paths (defaults provided)
    • Create backups of your Waybar config and style files
    • Add the custom/azan module to your Waybar config
    • Append module styles to your style.css
    • Generate and enable a systemd user service
    • Start the prayer daemon
  4. Restart Waybar (if it doesn't auto-reload):

    killall waybar && waybar &

You should now see the prayer module in your Waybar!

โš™๏ธ Configuration

Prayer Calculation Method

The daemon uses pyIslam for prayer time calculations. Edit azan_daemon.py to change the calculation method (line ~53):

def get_prayer_times():
    lat, lon, tz_name, offset = get_location_info()
    pconf = PrayerConf(lon, lat, offset, 5, 1)  # Change the 5 here
    #                                      ^
    #                                      Method ID

Available methods: 1 (Karachi), 2 (MWL), 3 (Egypt), 4 (Makkah), 5 (ISNA - default), 6 (France). See pyIslam documentation for details.

Waybar Module Position

By default, the module is added to modules-center. To change position, edit your ~/.config/waybar/config.jsonc:

{
  "modules-left": ["..."],
  "modules-center": ["clock", "custom/azan"],  // Move here if desired
  "modules-right": ["..."]
}

Styling

Customize the module appearance in ~/.config/waybar/style.css:

#custom-azan {
    color: #b4befe;              /* Icon color */
    background: transparent;
    font-size: 14px;
    padding: 0 10px;
    margin: 0 5px;
    border-radius: 8px;
}

#custom-azan:hover {
    color: #f9e2af;              /* Hover color */
    background: rgba(180, 190, 254, 0.1);
}

Adhan Audio File

Replace azan.mp3 with your preferred audio file:

cp /path/to/new-adhan.mp3 ./azan.mp3
systemctl --user restart prayer-daemon

๐ŸŽฎ Usage

Interactive Controls

  • Click the module: Toggle mute on/off (immediate visual update via signal)
  • Hover over module: See all prayer times with next prayer highlighted

Manual Daemon Control

# Check service status
systemctl --user status prayer-daemon

# Restart the daemon
systemctl --user restart prayer-daemon

# Stop the daemon
systemctl --user stop prayer-daemon

# View logs
journalctl --user -u prayer-daemon -f

# Check current status via API
curl http://127.0.0.1:4567/status | jq

# Toggle mute via API
curl http://127.0.0.1:4567/mute

๐Ÿ” Troubleshooting

Module Not Appearing

  1. Verify daemon is running:

    systemctl --user status prayer-daemon
    curl http://127.0.0.1:4567/status
  2. Check Waybar config was updated:

    grep -A 6 '"custom/azan"' ~/.config/waybar/config.jsonc

    Should show:

    "custom/azan": {
      "exec": "/full/path/to/scripts/waybar-azan.sh",
      "return-type": "json",
      "interval": 20,
      "on-click": "/full/path/to/scripts/waybar-azan-mute.sh",
      "signal": 20
    }
  3. Check module in modules array:

    grep "modules-" ~/.config/waybar/config.jsonc | grep azan
  4. Verify scripts are executable:

    ls -la scripts/waybar-azan*.sh
  5. Restart Waybar:

    killall waybar && waybar &

Daemon Fails to Start

  1. Check service logs:

    journalctl --user -u prayer-daemon --no-pager -n 50
  2. Verify Python environment:

    ./env/bin/python --version
    ./env/bin/pip list | grep -E "vlc|requests|pytz|islam"
  3. Test daemon manually:

    ./env/bin/python azan_daemon.py

No Adhan Sound

  1. Check audio file exists:

    file azan.mp3
    mpv azan.mp3  # Test playback
  2. Verify VLC/audio player is installed:

    which vlc mpv ffplay
  3. Check mute status:

    curl http://127.0.0.1:4567/status | jq '.muted_status'
  4. Test VLC library:

    ./env/bin/python -c "import vlc; print('VLC OK')"

Wrong Prayer Times

  1. Check detected location:

    curl https://ipinfo.io/json | jq
  2. Verify timezone:

    timedatectl
  3. Check daemon location info (look at startup logs):

    journalctl --user -u prayer-daemon | grep -i location
  4. Test location detection:

    ./env/bin/python -c "
    import requests
    data = requests.get('https://ipinfo.io/json').json()
    print(f\"Location: {data['city']}, {data['country']}\")
    print(f\"Coordinates: {data['loc']}\")
    print(f\"Timezone: {data['timezone']}\")
    "

๐Ÿ—‘๏ธ Uninstallation

Run the automated uninstaller:

./uninstall.sh

The script will:

  • Stop and disable the systemd service
  • Kill any running daemon processes
  • Remove the service file
  • Restore your Waybar config and style from backups
  • Optionally remove the Python virtual environment

Verify Daemon is Stopped

After uninstalling, verify the daemon is no longer running:

# Check for running daemon process
pgrep -f azan_daemon.py

# Try to connect to API (should fail)
curl -f http://127.0.0.1:4567/status 2>/dev/null && echo "Still running!" || echo "Stopped โœ“"

# Check systemd service status
systemctl --user status prayer-daemon

If the daemon is still running, manually stop it:

# Kill daemon process
pkill -f azan_daemon.py

# Or force kill if needed
pkill -9 -f azan_daemon.py

Then restart Waybar:

killall waybar && waybar &

To completely remove the project:

cd ..
rm -rf PrayerTime-Waybar

๐Ÿ“ Project Structure

PrayerTime-Waybar/
โ”œโ”€โ”€ azan_daemon.py          # Main daemon (HTTP server + adhan scheduler)
โ”œโ”€โ”€ azan.mp3                # Your adhan audio file (not included)
โ”œโ”€โ”€ install.sh              # Automated installer
โ”œโ”€โ”€ uninstall.sh            # Automated uninstaller
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ waybar-azan.sh      # Status display script (called by Waybar)
โ”‚   โ””โ”€โ”€ waybar-azan-mute.sh # Mute toggle script (on-click handler)
โ”œโ”€โ”€ waybar/
โ”‚   โ””โ”€โ”€ style.css           # CSS styles for the module
โ””โ”€โ”€ env/                    # Python virtual environment (created by installer)

๐Ÿ”ง API Endpoints

The daemon exposes a local HTTP API on 127.0.0.1:4567:

GET /status

Returns current prayer times and status:

{
  "text": "Prayer",
  "tooltip": "<b>โ— Asr      : 15:23</b>\nMaghrib : 17:45\n...",
  "next_prayer": "Asr",
  "next_time": "15:23",
  "muted_status": "No"
}

GET /mute

Toggles mute state and returns:

{
  "mute": true
}

๐Ÿค Contributing

Contributions are welcome! Areas for improvement:

  • Add configuration file for easier customization
  • Support more prayer calculation methods
  • Add notification support (libnotify)
  • Configurable adhan files per prayer
  • GUI for configuration
  • Systemd timer for prayer time updates
  • Support for multiple locations/timezones

๐Ÿ“ License

This project is open source. Feel free to use, modify, and distribute.

๐Ÿ™ Acknowledgments

  • Uses pyIslam for prayer time calculations
  • Built for Waybar
  • Inspired by the Muslim community's need for prayer time tools on Linux
  • Custom adhan for specific prayers
  • Prayer reminder notifications
  • Multiple audio file support
  • Prayer time adjustments

๐Ÿ“ License

This project is open source under the MIT License.

About

An Islamic Prayer Time Daemon and simple UI witn autoconfiguration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors