Skip to content

feat: Add Theme Scheduler with auto sunrise/sunset and fixed time modes#5809

Open
Harshil-Anuwadia wants to merge 1 commit into
basecamp:devfrom
Harshil-Anuwadia:dev
Open

feat: Add Theme Scheduler with auto sunrise/sunset and fixed time modes#5809
Harshil-Anuwadia wants to merge 1 commit into
basecamp:devfrom
Harshil-Anuwadia:dev

Conversation

@Harshil-Anuwadia
Copy link
Copy Markdown

feat: Add automated theme scheduler (Time & Sunrise/Sunset)

Description

This PR adds a new feature that lets users automatically switch between light and dark themes. It can run on a fixed schedule or automatically follow local sunrise and sunset times.

I integrated it directly into the Setup section of omarchy-menu, so no manual config editing is needed.

Features

  • Auto Mode: Uses wttr.in (same as the weather widget) to automatically trigger theme changes at local sunrise and sunset.
  • Time Mode: Lets users set custom HH:MM times for day and night.
  • Menu Integration: Clean UI in the setup menu. The menu automatically hides the custom time inputs if you're in Auto mode.
  • Notifications: Sends a standard Omarchy desktop notification whenever the theme changes.
screenshot-2026-05-14_11-09-59

Technical Details & Fixes

  • Locking: I used an atomic directory lock (/tmp/omarchy-theme-schedule.lock.dir). Initially, I tried file locks (flock), but child processes like waybar kept inheriting the file descriptor and causing the script to hang. Directory locks completely solved this.
  • Systemd Environment: The background service explicitly imports WAYLAND_DISPLAY and HYPRLAND_INSTANCE_SIGNATURE so the theme commands run correctly from a background context.
  • Failsafes: If the user sets it to Auto mode but their internet goes down, the script falls back to their fixed Time settings instead of failing.
  • Waybar Cleanup: Added a quick sanity check at the end of the script to kill duplicate waybar instances if they accidentally spawn during a transition.

Files Added/Modified

  • bin/omarchy-theme-schedule (Core script)
  • bin/omarchy-menu (Integrated into setup menu)
  • config/systemd/user/omarchy-theme-schedule.timer
  • config/systemd/user/omarchy-theme-schedule.service
  • migrations/1778733053.sh (Auto-enables the timer for existing users)

Copilot AI review requested due to automatic review settings May 14, 2026 05:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a systemd user timer/service and migration to support an automated theme scheduler (fixed times or sunrise/sunset) that runs periodically in the background.

Changes:

  • Adds a user-level systemd timer to run the scheduler periodically.
  • Adds a user-level systemd oneshot service that executes the scheduler and appends logs to a file.
  • Adds a migration to auto-enable the timer for existing users when the unit is present.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 3 comments.

File Description
migrations/1778733053.sh Enables/starts the new user timer during migration.
config/systemd/user/omarchy-theme-schedule.timer Defines the periodic schedule for theme checks.
config/systemd/user/omarchy-theme-schedule.service Runs the scheduler script and configures environment/logging.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


[Service]
Type=oneshot
ExecStartPre=/usr/bin/systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP HYPRLAND_INSTANCE_SIGNATURE

[Service]
Type=oneshot
ExecStartPre=/usr/bin/systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP HYPRLAND_INSTANCE_SIGNATURE
Comment thread migrations/1778733053.sh

# Enable the theme scheduler timer if it was recently added
if [[ -f "$HOME/.config/systemd/user/omarchy-theme-schedule.timer" ]]; then
systemctl --user enable --now omarchy-theme-schedule.timer || true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants