Skip to content

Commit 8ddb93e

Browse files
author
tom
committed
first commit
0 parents  commit 8ddb93e

42 files changed

Lines changed: 6373 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Build PyCron Video Alarm
2+
3+
on:
4+
push:
5+
branches: [ "**" ]
6+
pull_request:
7+
branches: [ "**" ]
8+
9+
jobs:
10+
check-trigger:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
should_build: ${{ steps.check.outputs.should_build }}
14+
steps:
15+
- name: Check commit/PR message for 'build'
16+
id: check
17+
env:
18+
COMMIT_MSG: ${{ github.event.head_commit.message }}
19+
PR_TITLE: ${{ github.event.pull_request.title }}
20+
run: |
21+
MSG=$(echo "${COMMIT_MSG}${PR_TITLE}" | tr '[:upper:]' '[:lower:]')
22+
if [[ "$MSG" == build* ]]; then
23+
echo "should_build=true" >> $GITHUB_OUTPUT
24+
else
25+
echo "should_build=false" >> $GITHUB_OUTPUT
26+
fi
27+
28+
build-linux:
29+
runs-on: ubuntu-latest
30+
needs: check-trigger
31+
if: needs.check-trigger.outputs.should_build == 'true'
32+
steps:
33+
- uses: actions/checkout@v3
34+
35+
- name: Set up Python 3.11
36+
uses: actions/setup-python@v4
37+
with:
38+
python-version: "3.11"
39+
40+
- name: Install system dependencies
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install -y python3-tk libxcb-cursor0
44+
45+
- name: Install dependencies
46+
run: |
47+
python -m pip install --upgrade pip
48+
pip install -r requirements.txt
49+
pip install pyinstaller
50+
51+
- name: Build with PyInstaller
52+
run: |
53+
export TZ='America/New_York'
54+
TS=$(date +'%Y-%m-%d_%H%M')
55+
BUILD_DATE=$(date +'%Y-%m-%d %H:%M EST')
56+
echo "Built: $BUILD_DATE" > version.txt
57+
echo "Archive: ${TS}_PyCronVideoAlarm_Linux" >> version.txt
58+
59+
pyinstaller --noconfirm --onefile --windowed \
60+
--name "PyCronVideoAlarm_Linux" \
61+
--icon "alarm_icon7.ico" \
62+
--add-data "src:src" \
63+
--add-data "alarm_icon7.ico:." \
64+
--add-data "alarm_icon7.png:." \
65+
--add-data "version.txt:." \
66+
--add-data "LICENSE:." \
67+
--hidden-import=crontab \
68+
--hidden-import=jeepney \
69+
src/main.py
70+
71+
- name: Upload Artifact
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: PyCronVideoAlarm_Linux
75+
path: dist/PyCronVideoAlarm_Linux
76+
77+
build-windows:
78+
runs-on: windows-latest
79+
needs: check-trigger
80+
if: needs.check-trigger.outputs.should_build == 'true'
81+
steps:
82+
- uses: actions/checkout@v3
83+
84+
- name: Set up Python 3.11
85+
uses: actions/setup-python@v4
86+
with:
87+
python-version: "3.11"
88+
89+
- name: Install dependencies
90+
run: |
91+
python -m pip install --upgrade pip
92+
pip install -r requirements.txt
93+
pip install pyinstaller
94+
95+
- name: Build with PyInstaller
96+
run: |
97+
$tz = [System.TimeZoneInfo]::FindSystemTimeZoneById("Eastern Standard Time")
98+
$est = [System.TimeZoneInfo]::ConvertTimeFromUtc((Get-Date).ToUniversalTime(), $tz)
99+
$ts = $est.ToString('yyyy-MM-dd_HHmm')
100+
"Built: $($est.ToString('yyyy-MM-dd HH:mm')) EST" | Out-File -FilePath version.txt -Encoding utf8
101+
"Archive: ${ts}_PyCronVideoAlarm_Windows.exe" | Add-Content -Path version.txt -Encoding utf8
102+
103+
pyinstaller --noconfirm --onefile --windowed `
104+
--name "PyCronVideoAlarm_Windows" `
105+
--icon="alarm_icon7.ico" `
106+
--add-data "src;src" `
107+
--add-data "alarm_icon7.ico;." `
108+
--add-data "alarm_icon7.png;." `
109+
--add-data "bin;bin" `
110+
--add-data "version.txt;." `
111+
--add-data "LICENSE;." `
112+
--hidden-import=pycaw `
113+
--hidden-import=comtypes `
114+
--hidden-import=comtypes.stream `
115+
src/main.py
116+
117+
- name: Upload Artifact
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: PyCronVideoAlarm_Windows
121+
path: dist/PyCronVideoAlarm_Windows.exe

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#*.mp4
2+
#*.mov
3+
#*.avi
4+
#*.webm
5+
audio/YOURBESTFRIENDJIPPY-BEATTAPE36.m4a
6+
audio/YOURBESTFRIENDJIPPY-BEATTAPE36.mp3
7+
build/
8+
dist/
9+
reference/
10+
audio/
11+
video/
12+
sequences/
13+
__pycache__/

LICENSE

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
PyCron Video Alarm Manager — Noncommercial License
2+
Copyright (c) 2026 Juke32 (https://github.com/juke32)
3+
4+
Permission is granted to use, copy, and share this software without financial gain, provided that:
5+
6+
1. Juke32 is clearly credited in any distribution or derivative work.
7+
2. This license and copyright notice are included in all copies.
8+
3. Forks and modifications are permitted for personal use and to submit
9+
contributions back to the original project. They may not be distributed
10+
as standalone projects without written permission.
11+
4. The software is not sold, sublicensed, or used in any way that generates
12+
financial gain for anyone other than Juke32.
13+
14+
All rights to sell, license, or otherwise profit from this software are
15+
exclusively reserved by Juke32. For permission, contact https://github.com/juke32.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE AUTHOR
18+
IS NOT LIABLE FOR ANY DAMAGES ARISING FROM ITS USE.

README.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# PyCron Video Alarm
2+
3+
> A cross-platform video alarm clock that wakes you up with videos, audio, and custom automation sequences — scheduled through your OS natively (cron on Linux, Task Scheduler on Windows).
4+
5+
[![License](https://img.shields.io/badge/License-Custom%20Source--Available-red.svg)](./LICENSE)
6+
[![Platform](https://img.shields.io/badge/platform-Linux%20%7C%20Windows-blue)](https://github.com/juke32/PyCronVideoAlarm/releases)
7+
[![Buy Me a Coffee](https://img.shields.io/badge/Support-Buy%20Me%20a%20Coffee-orange)](https://buymeacoffee.com)
8+
9+
---
10+
11+
## ✨ What It Does
12+
13+
- 🎬 **Play videos as alarms** — launch any video file at a scheduled time using MPV
14+
- 🔊 **Play audio** — wake up to music, sounds, or recorded voice clips
15+
- 📋 **Alarm Sequences** — chain actions together (play video → open website → dim screen → etc.)
16+
- 🕐 **Sleep Cycle Calculator** — calculates optimal wake times in 90-minute cycles
17+
- 🔁 **Recurring Alarms** — set alarms for specific days of the week, or one-time only
18+
- 🌙 **Sleep Mode** — dim/black screen overlay with keep-awake to assist sleeping
19+
- 💡 **Brightness Control** — dim the display as part of a sequence (Linux + Windows)
20+
- 🏠 **Native OS Scheduling** — uses `cron` on Linux, Task Scheduler on Windows (no background process needed)
21+
- 🖱️ **Party Mode** — instant random video from your library
22+
- 🎨 **Themes** — multiple dark/light themes
23+
24+
---
25+
26+
## ⚡ Quick Start
27+
28+
### Option A: Download Pre-built Executable *(Recommended)*
29+
30+
1. Download the latest release from the [Releases page](https://github.com/juke32/PyCronVideoAlarm/releases)
31+
2. Extract the folder anywhere you want the app to live permanently
32+
3. Run the executable:
33+
- **Windows**: `PyCronVideoAlarm_Windows.exe`
34+
- **Linux**: `./PyCronVideoAlarm_Linux` (may need: `chmod +x PyCronVideoAlarm_Linux`)
35+
4. On first run, go to **Settings → Add to Applications** to register it in your app launcher
36+
37+
> [!TIP]
38+
> **Keep the folder in one place.** Cron/Task Scheduler entries point to this exact path. Moving the exe after setting alarms will break the schedule links.
39+
40+
### Option B: Run from Source
41+
42+
```bash
43+
git clone https://github.com/juke32/PyCronVideoAlarm.git
44+
cd PyCronVideoAlarm
45+
python3 -m venv .venv
46+
source .venv/bin/activate # Linux
47+
# .venv\Scripts\activate.bat # Windows
48+
pip install -r requirements.txt
49+
python src/main.py
50+
```
51+
52+
---
53+
54+
## 📦 Dependencies
55+
56+
### External (install separately)
57+
58+
| Dependency | Purpose | Linux | Windows |
59+
|---|---|---|---|
60+
| **MPV** | Video & audio playback | `sudo apt install mpv` | [mpv.io](https://mpv.io) or `winget install mpv` |
61+
62+
### Python (auto-installed via `requirements.txt`)
63+
64+
| Package | Purpose |
65+
|---|---|
66+
| `Pillow` | Image handling / icon display |
67+
| `python-crontab` | Linux cron scheduling *(Linux only)* |
68+
| `jeepney` | DBus / Wayland support *(Linux only)* |
69+
| `pycaw`, `comtypes`, `pywin32` | Windows audio + Task Scheduler *(Windows only)* |
70+
| `pyautogui`, `opencv-python` | Screen automation actions |
71+
| `sounddevice`, `numpy`, `scipy` | Audio recording action |
72+
73+
---
74+
75+
## 📂 Folder Structure
76+
77+
Place the executable (or run from source) with this layout. The app creates missing folders automatically on first run.
78+
79+
```
80+
PyCronVideoAlarm/
81+
82+
├── PyCronVideoAlarm_Linux ← Main executable (Linux)
83+
├── PyCronVideoAlarm_Windows.exe ← Main executable (Windows)
84+
├── settings.json ← Auto-generated on first run
85+
86+
├── sequences/ ← Alarm sequences (.json files)
87+
│ ├── Morning_Routine.json
88+
│ └── Weekend_Wake.json
89+
90+
├── audio/ ← Audio files for sequences
91+
│ ├── Alarm_Clock.mp3
92+
│ └── 00-100_numbers/ ← Drop the "0-100 Audio" pack here
93+
94+
└── video/ ← Video files for sequences
95+
├── FunnyFolder/ ← Drop funny video packs here
96+
└── MotivationFolder/ ← Drop motivational packs here
97+
```
98+
99+
> [!NOTE]
100+
> Sample sequences, audio, and video packs are available as optional downloads on the [Releases page](https://github.com/juke32/PyCronVideoAlarm/releases). Drop them in the folders above and the included sequences will work immediately.
101+
102+
---
103+
104+
## 🐧 Linux Setup
105+
106+
### Make it executable
107+
```bash
108+
chmod +x PyCronVideoAlarm_Linux
109+
./PyCronVideoAlarm_Linux
110+
```
111+
112+
### Crontab access
113+
The app schedules alarms via cron. Test access with:
114+
```bash
115+
crontab -l
116+
# "no crontab for user" = you have access (just no entries yet)
117+
# "permission denied" = run: echo $USER | sudo tee -a /etc/cron.allow
118+
```
119+
120+
> [!CAUTION]
121+
> Never run the app or set alarms with `sudo`. Cron jobs set as root cannot access your display or audio session.
122+
123+
### Brightness control
124+
Install `brightnessctl` for the most reliable brightness support:
125+
```bash
126+
sudo apt install brightnessctl
127+
```
128+
Or add your user to the `video` group:
129+
```bash
130+
sudo usermod -aG video $USER # log out and back in after
131+
```
132+
133+
### Session requirement
134+
Your user session must be **logged in** for media to play. The app automatically injects `DISPLAY` and `XDG_RUNTIME_DIR` into cron commands for GUI playback.
135+
136+
For full Linux details (Fedora, udev rules, codecs, sleep inhibition): see [README_Linux.md](./README_Linux.md)
137+
138+
---
139+
140+
## 🪟 Windows Setup
141+
142+
1. Download and run `VideoAlarm_Windows.exe`
143+
2. Install MPV: `winget install mpv` or from [mpv.io](https://mpv.io)
144+
3. Alarms are registered in **Windows Task Scheduler** — no background process needed
145+
4. Go to **Settings → Add to Start Menu** to add a shortcut
146+
147+
> [!NOTE]
148+
> Windows can wake from sleep to fire an alarm if configured in Task Scheduler (enabled by default in the app).
149+
150+
---
151+
152+
## 🛠️ Troubleshooting
153+
154+
| Problem | Solution |
155+
|---|---|
156+
| Alarm didn't fire | Check the **Next Alarm** ticker in the Alarms tab. Verify cron/Task Scheduler using a 1-minute test alarm. |
157+
| Video won't play | Ensure MPV is installed: `mpv --version` in terminal |
158+
| No sound | On Linux, check `XDG_RUNTIME_DIR` is set. The app logs this on each alarm run. |
159+
| App won't open on Linux | Run `chmod +x VideoAlarm_Linux` then try again |
160+
| Brightness control fails | Install `brightnessctl` or add user to `video` group (Linux) |
161+
162+
Enable **Settings → Logging** and check the logs folder for detailed error output.
163+
164+
---
165+
166+
## 🏗️ Building from Source
167+
168+
```bash
169+
# Linux
170+
./build_linux.sh
171+
172+
# Windows
173+
build_windows.bat
174+
```
175+
176+
Or push a commit whose message **starts with** `build` to trigger GitHub Actions (builds both platforms automatically).
177+
178+
---
179+
180+
## 🤝 Contributing & Support
181+
182+
This project is a labour of love. If it helped you wake up on time (or made your morning less terrible), consider supporting it:
183+
184+
**[Buy Me a Coffee](https://buymeacoffee.com)** — any amount helps!
185+
186+
Issues, feature requests, and pull requests are welcome on the [GitHub repo](https://github.com/juke32/PyCronVideoAlarm).
187+
188+
---
189+
190+
## 📄 License
191+
192+
[Custom Source-Available License](./LICENSE) — free for personal and non-commercial use with attribution. Commercial use, resale, and public redistribution of modified versions require permission from Juke32.

0 commit comments

Comments
 (0)