Skip to content

add dynamic wallpaper timer#349

Open
joshyorko wants to merge 1 commit into
projectbluefin:mainfrom
joshyorko:codex/dynamic-wallpaper-common
Open

add dynamic wallpaper timer#349
joshyorko wants to merge 1 commit into
projectbluefin:mainfrom
joshyorko:codex/dynamic-wallpaper-common

Conversation

@joshyorko
Copy link
Copy Markdown
Contributor

@joshyorko joshyorko commented May 26, 2026

Summary

  • Add a shared user systemd timer and service for Bluefin dynamic wallpapers.
  • Add a GeoClue-backed latitude helper that falls back cleanly when location is unavailable or denied.
  • Add a user setup hook so the timer is enabled for users through the common layer.

Why

This ports the applicable shared-layer work from ublue-os/bluefin#3890 into projectbluefin/common, where shared Bluefin workload behavior belongs. That keeps the feature in one layer for downstream Bluefin variants instead of landing it only in ublue-os/bluefin.

Scope note

The approved Bluefin PR also removed the old build-time month rewrite from ublue-os/bluefin at build_files/base/05-override-install.sh. That file does not exist in projectbluefin/common, so this PR cannot remove that line directly. If that rewrite still runs in Bluefin after this common change lands, it should be removed in a small follow-up PR against ublue-os/bluefin.

Testing

  • shellcheck system_files/shared/usr/libexec/bluefin-dynamic-wallpaper system_files/shared/usr/libexec/get-geoclue-latitude system_files/shared/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh
  • bash -n system_files/shared/usr/libexec/bluefin-dynamic-wallpaper system_files/shared/usr/libexec/get-geoclue-latitude system_files/shared/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh
  • git diff --check HEAD~1..HEAD
  • systemd-analyze verify with a temporary host-valid ExecStart relocation
  • Fake gsettings test confirmed southern hemisphere maps May to November and updates both light/dark wallpaper URIs
  • Fake gsettings test confirmed custom dark wallpaper is not overwritten
  • Fake gdbus tests confirmed valid latitude, AccessDenied exit 2, and (0.0, 0.0) rejection

just check was also run. It fails on existing formatting drift in untouched Justfiles under system_files/bluefin/usr/share/ublue-os/just/; this PR does not touch Justfile or *.just, so that path-filtered workflow should not run for this change.

Refs ublue-os/bluefin#3890

Summary by CodeRabbit

  • New Features

    • Dynamic monthly wallpaper that selects images per hemisphere and updates automatically.
    • Automatic daily wallpaper refresh with safe behavior to preserve custom user-set wallpapers.
  • Chores

    • User setup now enables and starts the per-user wallpaper timer so updates run automatically.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bf50fdf4-87be-4b26-b9df-9e70df989788

📥 Commits

Reviewing files that changed from the base of the PR and between 8ef7787 and a81ff9f.

📒 Files selected for processing (5)
  • system_files/bluefin/usr/lib/systemd/user/bluefin-dynamic-wallpaper.service
  • system_files/bluefin/usr/lib/systemd/user/bluefin-dynamic-wallpaper.timer
  • system_files/bluefin/usr/libexec/bluefin-dynamic-wallpaper
  • system_files/bluefin/usr/libexec/get-geoclue-latitude
  • system_files/bluefin/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh
🚧 Files skipped from review as they are similar to previous changes (5)
  • system_files/bluefin/usr/lib/systemd/user/bluefin-dynamic-wallpaper.timer
  • system_files/bluefin/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh
  • system_files/bluefin/usr/lib/systemd/user/bluefin-dynamic-wallpaper.service
  • system_files/bluefin/usr/libexec/bluefin-dynamic-wallpaper
  • system_files/bluefin/usr/libexec/get-geoclue-latitude

📝 Walkthrough

Walkthrough

Adds a GeoClue2-based latitude helper, a monthly wallpaper selection script that adjusts for hemisphere, a user-level systemd oneshot service and daily timer to run the script, and a user setup hook that enables the timer.

Changes

Dynamic Wallpaper System

Layer / File(s) Summary
GeoClue2 Latitude Retrieval Helper
system_files/bluefin/usr/libexec/get-geoclue-latitude
A Bash helper that creates a GeoClue2 client via D-Bus, starts it, polls for Location until available or timeout, reads/parses Latitude/Longitude, validates values, and prints latitude.
Dynamic Wallpaper Selection and Update
system_files/bluefin/usr/libexec/bluefin-dynamic-wallpaper
Reads current GNOME picture-uri/picture-uri-dark, validates they match Bluefin's *-bluefin.xml pattern, calls the geoclue helper to determine hemisphere, applies a +6-month offset for southern hemisphere, verifies the monthly XML file exists, and updates both light and dark URIs with gsettings.
Systemd Scheduling and User Setup
system_files/bluefin/usr/lib/systemd/user/bluefin-dynamic-wallpaper.service, system_files/bluefin/usr/lib/systemd/user/bluefin-dynamic-wallpaper.timer, system_files/bluefin/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh
Adds a oneshot user service running the wallpaper script, a user timer that runs 1 minute after boot then every 24h (Persistent=true) and is WantedBy graphical-session.target, and a user setup hook that enables/starts the timer.

Sequence Diagram

sequenceDiagram
  participant Timer as systemd Timer
  participant Service as bluefin-dynamic-wallpaper Service
  participant Wallpaper as bluefin-dynamic-wallpaper Script
  participant Geoclue as get-geoclue-latitude Script
  participant gsettings
  participant GeoClue2 as GeoClue2 D-Bus

  Timer->>Service: Trigger at boot + daily
  Service->>Wallpaper: Execute script
  Wallpaper->>gsettings: Read picture-uri, picture-uri-dark
  gsettings-->>Wallpaper: Current URIs
  Wallpaper->>Geoclue: Request latitude
  Geoclue->>GeoClue2: CreateClient, Set props, Start, Poll
  GeoClue2-->>Geoclue: Location, Latitude/Longitude
  Geoclue-->>Wallpaper: Latitude (or error/default)
  Wallpaper->>Wallpaper: Compute month/hemisphere, select file
  Wallpaper->>gsettings: Set picture-uri, picture-uri-dark
  gsettings-->>Wallpaper: Success
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through DBus, sniffed the air,
Found latitude hidden here and there.
North or south, the months rearrange,
XML skies in subtle change—
Each boot and dawn, your desktop wears new flair.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a systemd timer for dynamic wallpaper functionality.
Description check ✅ Passed The description comprehensively covers the changes, rationale, scope, testing performed, and references the upstream PR, though it does not strictly follow the template sections provided.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@joshyorko joshyorko changed the title [codex] add dynamic wallpaper timer add dynamic wallpaper timer May 26, 2026
@joshyorko joshyorko marked this pull request as ready for review May 26, 2026 02:50
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. area/services System Services and Management kind/enhancement New feature, don't implement without a spec and consensus labels May 26, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@system_files/shared/usr/libexec/get-geoclue-latitude`:
- Around line 100-107: The direct gdbus call that populates LAT_OUTPUT should
preserve the helper’s AccessDenied exit-code contract by either using the
existing run_gdbus wrapper or by detecting the DBus AccessDenied error text and
exiting with code 2; replace the inline gdbus invocation that sets LAT_OUTPUT
(and the analogous longitude block that sets LONG_OUTPUT) with a call to
run_gdbus --system --dest org.freedesktop.GeoClue2 --object-path
"$LOCATION_PATH" --method org.freedesktop.DBus.Properties.Get
org.freedesktop.GeoClue2.Location Latitude (and Longitude) so run_gdbus can map
org.freedesktop.DBus.Error.AccessDenied to exit code 2, or if you must keep the
inline call, check LAT_OUTPUT for "org.freedesktop.DBus.Error.AccessDenied" and
exit 2 instead of 1.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a8ea5fcc-c2b3-4fb0-ae7e-d2b0b9e781cb

📥 Commits

Reviewing files that changed from the base of the PR and between 7f273b6 and 3b520e8.

📒 Files selected for processing (5)
  • system_files/shared/usr/lib/systemd/user/bluefin-dynamic-wallpaper.service
  • system_files/shared/usr/lib/systemd/user/bluefin-dynamic-wallpaper.timer
  • system_files/shared/usr/libexec/bluefin-dynamic-wallpaper
  • system_files/shared/usr/libexec/get-geoclue-latitude
  • system_files/shared/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh

Comment thread system_files/shared/usr/libexec/get-geoclue-latitude Outdated
hanthor
hanthor previously approved these changes May 29, 2026
Copy link
Copy Markdown
Member

@hanthor hanthor left a comment

Choose a reason for hiding this comment

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

Well-structured port of the dynamic wallpaper work from ublue-os/bluefin — systemd timer + service pair, GeoClue latitude helper with clean fallback, and user-setup hook to enable it for new users. CI passes. Approved.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 29, 2026
inffy
inffy previously requested changes May 29, 2026
Copy link
Copy Markdown
Member

@inffy inffy left a comment

Choose a reason for hiding this comment

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

No way Aurora wants this. So its in the wrong shared folder folder

See https://github.com/projectbluefin/common#directory-structure

@dosubot dosubot Bot removed the lgtm This PR has been approved by a maintainer label May 29, 2026
@renner0e
Copy link
Copy Markdown
Contributor

No way Aurora wants this. So its in the wrong shared folder folder

I guess we should codify this in codeowners and as a PR template

@joshyorko joshyorko force-pushed the codex/dynamic-wallpaper-common branch from 3b520e8 to 8ef7787 Compare May 29, 2026 14:48
@joshyorko joshyorko requested a review from inffy May 29, 2026 14:49
@joshyorko
Copy link
Copy Markdown
Contributor Author

No way Aurora wants this. So its in the wrong shared folder folder

See https://github.com/projectbluefin/common#directory-structure

understood, done

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
system_files/bluefin/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh (1)

9-9: 💤 Low value

set -x looks like a leftover debug artifact.

version-script already disables tracing (set +x) on success, and re-enabling it here traces the systemctl invocation into the user session journal on every setup run. If this isn't intentional debugging, drop it.

🧹 Proposed cleanup
-set -x
-
 echo "Enabling dynamic wallpaper timer"
 systemctl --user enable --now bluefin-dynamic-wallpaper.timer
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@system_files/bluefin/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh`
at line 9, Remove the leftover tracing invocation "set -x" so the hook does not
re-enable shell tracing and thereby avoid leaking the subsequent systemctl
invocation into the user session journal; locate the "set -x" token in the
20-dynamic-wallpaper.sh hook and delete it (or replace with a no-op/comment) so
tracing remains disabled by the existing version-script "set +x" behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@system_files/bluefin/usr/libexec/get-geoclue-latitude`:
- Around line 60-77: The Set and Start gdbus calls (invoked via run_gdbus for
org.freedesktop.GeoClue2.Client DesktopId, RequestedAccuracyLevel and
Client.Start against "$CLIENT_PATH") are printing their results to stdout and
leaking "()" into the script output; silence those calls by discarding their
stdout/stderr (e.g. redirect their output to /dev/null) so only the
latitude/longitude read commands produce stdout for LATITUDE; keep the calls and
arguments (run_gdbus, DesktopId, RequestedAccuracyLevel, Client.Start,
"$CLIENT_PATH") unchanged except for adding the redirection.
- Around line 108-120: The sed regex used to extract LATITUDE and LONGITUDE from
LAT_OUTPUT/LON_OUTPUT is too strict (expects "<double 52.52>") and fails when
gdbus prints "<52.52>"; update the extraction used for LATITUDE and LONGITUDE
(the sed invocation lines) to accept either form (make the "double " prefix
optional) so both "<52.52>" and "<double 52.52>" parse correctly; apply the same
tolerant pattern change to both the LATITUDE and LONGITUDE assignments that
follow run_gdbus.

---

Nitpick comments:
In
`@system_files/bluefin/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh`:
- Line 9: Remove the leftover tracing invocation "set -x" so the hook does not
re-enable shell tracing and thereby avoid leaking the subsequent systemctl
invocation into the user session journal; locate the "set -x" token in the
20-dynamic-wallpaper.sh hook and delete it (or replace with a no-op/comment) so
tracing remains disabled by the existing version-script "set +x" behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 035d39a6-0f98-4e43-a2a0-b7cf3b56b26b

📥 Commits

Reviewing files that changed from the base of the PR and between 3b520e8 and 8ef7787.

📒 Files selected for processing (5)
  • system_files/bluefin/usr/lib/systemd/user/bluefin-dynamic-wallpaper.service
  • system_files/bluefin/usr/lib/systemd/user/bluefin-dynamic-wallpaper.timer
  • system_files/bluefin/usr/libexec/bluefin-dynamic-wallpaper
  • system_files/bluefin/usr/libexec/get-geoclue-latitude
  • system_files/bluefin/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh

Comment thread system_files/bluefin/usr/libexec/get-geoclue-latitude Outdated
Comment thread system_files/bluefin/usr/libexec/get-geoclue-latitude Outdated
Copy link
Copy Markdown
Member

@hanthor hanthor left a comment

Choose a reason for hiding this comment

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

Approved.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 29, 2026
Copy link
Copy Markdown
Member

@hanthor hanthor left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, @joshyorko! Building on @inffy's feedback — the files themselves are correctly placed under system_files/bluefin/, which is good. However, the concern is about the setup hook: system_files/bluefin/usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh.

Per the repository directory structure, content in system_files/shared/ is consumed by all downstream images including Aurora. Aurora would not want a Bluefin-specific dynamic wallpaper timer enabled for their users.

The systemd service/timer units and scripts are correctly scoped to system_files/bluefin/. Please make sure the user-setup hook is also exclusively under system_files/bluefin/ and is not referenced from or copied into the shared/ layer. If the hook currently lives in a shared hooks directory (e.g. system_files/shared/usr/share/ublue-os/user-setup.hooks.d/), it should be moved to the bluefin/-specific path so that Aurora users are not affected.

Once that is confirmed/corrected, the content looks like a great addition for Bluefin specifically!

Copy link
Copy Markdown
Member

@hanthor hanthor left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, @joshyorko! Building on @inffy's feedback: the systemd service, timer units, and scripts are correctly placed under system_files/bluefin/ - that part is right. The key concern is that the user-setup hook (20-dynamic-wallpaper.sh) must also live exclusively under system_files/bluefin/ and not be included in the system_files/shared/ layer. Per the repo directory structure, content in shared/ is consumed by all downstream images including Aurora, and Aurora would not want a Bluefin-specific dynamic wallpaper timer enabled for their users. As long as all 5 files remain under system_files/bluefin/ (which the current diff shows they do), the directory placement is correct. Please double-check that nothing in the Containerfile or build process copies this hook into the shared layer. Once confirmed, the feature looks like a solid addition for Bluefin!

Copy link
Copy Markdown
Member

@hanthor hanthor left a comment

Choose a reason for hiding this comment

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

test comment from hanthor

@castrojo
Copy link
Copy Markdown
Contributor

🤖 Copilot Test Report

Branch: codex/dynamic-wallpaper-common | 6 commits behind main | Tested: 2026-05-30T04:50Z

Test Results

Test Result
just check (syntax validation) ✅ PASS
Branch merge conflicts with main ✅ None detected

Files Changed

  • usr/lib/systemd/user/bluefin-dynamic-wallpaper.{service,timer} — new systemd user units
  • usr/libexec/bluefin-dynamic-wallpaper + get-geoclue-latitude — scripts
  • usr/share/ublue-os/user-setup.hooks.d/20-dynamic-wallpaper.sh — setup hook (enables timer on first login)

Service Review

  • Timer fires 1 min after boot, then every 24h — reasonable cadence
  • Setup hook uses version-script guard to run once per user
  • WantedBy=graphical-session.target is correct for a user wallpaper service
  • geoclue dependency: reviewers should verify GeoClue is available in the base image or the script handles absence gracefully

What testing this PR needs beyond static analysis

This PR ships systemd units and a shell script — functional testing requires a running system. Ghost/titan lab test is recommended: build with ~/common-test-build.sh codex/dynamic-wallpaper-common, boot titan, and verify the timer activates and wallpaper updates.

Copy link
Copy Markdown
Member

@hanthor hanthor left a comment

Choose a reason for hiding this comment

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

Reviewed. Approved.

hanthor
hanthor previously approved these changes May 30, 2026
Copy link
Copy Markdown
Member

@hanthor hanthor left a comment

Choose a reason for hiding this comment

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

Reviewed. Approved.

@castrojo castrojo closed this May 30, 2026
@castrojo castrojo reopened this May 30, 2026
@castrojo castrojo closed this May 30, 2026
@castrojo castrojo reopened this May 30, 2026
@joshyorko joshyorko force-pushed the codex/dynamic-wallpaper-common branch from 8ef7787 to a81ff9f Compare May 30, 2026 18:13
Copy link
Copy Markdown
Member

@hanthor hanthor left a comment

Choose a reason for hiding this comment

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

LGTM! Excellent port of the shared-layer dynamic wallpaper work from bluefin to common. Verified all shellchecks and validation checks are successfully passing. Ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/services System Services and Management kind/enhancement New feature, don't implement without a spec and consensus lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants