Repository navigation
Catch the bar clock up when the system clock jumps #13541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stevederico
wants to merge
7
commits into
omacom:quattro
Choose a base branch
from
stevederico:fix/clock-stale-after-resume
base: quattro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b68ea61
Restart the bar clock and calendar on a resync request
stevederico 929d76d
Resync the bar clock when the system clock jumps
stevederico 6450ce2
Check the timer is enabled only when the clock resync migration ran
stevederico 19139cb
Date the clock resync migration after the ones quattro has run
stevederico 3364c85
Keep only the systemd unit check in the clock resync test
stevederico 8e70643
Keep the first-run unit list sentence on one line
stevederico e8702b9
Catch WallClock up on resync instead of toggling enabled
stevederico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| [Unit] | ||
| Description=Restart the bar clock after the system clock jumped | ||
| # The same environment omarchy-sleep-lock waits for: the IPC call finds the | ||
| # running shell through OMARCHY_PATH and WAYLAND_DISPLAY. -q makes a shell that | ||
| # is not running, or still starting, a success rather than a failed unit. | ||
| ConditionEnvironment=OMARCHY_PATH | ||
| ConditionEnvironment=WAYLAND_DISPLAY | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStart=/usr/bin/omarchy-shell -q omarchy.clock resync |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| [Unit] | ||
| Description=Watch for the system clock jumping | ||
| # Nothing to count down: OnClockChange= waits on a timerfd the user manager | ||
| # already holds, so the timer costs no process and no wakeups. The kernel | ||
| # cancels that timerfd when CLOCK_REALTIME jumps against CLOCK_MONOTONIC, which | ||
| # is what a resume from suspend does as well as a clock being set. | ||
| PartOf=graphical-session.target | ||
|
|
||
| [Timer] | ||
| OnClockChange=yes | ||
| # A zone change leaves the label on the old zone until the next tick, which is | ||
| # why omarchy-menu-timezone pushes a refresh; this covers any other way it is set. | ||
| OnTimezoneChange=yes | ||
|
|
||
| [Install] | ||
| WantedBy=graphical-session.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| echo "Catch the bar clock up when the system clock jumps" | ||
|
|
||
| # SystemClock waits out the rest of the minute on a timer that stops during | ||
| # suspend, so after a wake the bar kept the old time for up to a minute. The | ||
| # timer restarts the clock when the system clock jumps, which a wake is. New | ||
| # installs enable it with the other user units; this is for existing ones. | ||
|
|
||
| # The units live in default/, so link them where the user manager looks. A | ||
| # link follows the shipped file, so it never goes stale. | ||
| mkdir -p "$HOME/.config/systemd/user" | ||
| for unit in omarchy-clock-resync.service omarchy-clock-resync.timer; do | ||
| if [[ ! -e /usr/lib/systemd/user/$unit ]]; then | ||
| ln -sfn "$OMARCHY_PATH/default/systemd/user/$unit" "$HOME/.config/systemd/user/$unit" | ||
| fi | ||
| done | ||
|
|
||
| systemctl --user daemon-reload >/dev/null 2>&1 || true | ||
|
|
||
| # `systemctl enable` needs a live user manager, which an update from a TTY does | ||
| # not have, so fall back to writing the symlink it would have written. | ||
| if ! systemctl --user enable omarchy-clock-resync.timer >/dev/null 2>&1; then | ||
| wants_dir="$HOME/.config/systemd/user/graphical-session.target.wants" | ||
| mkdir -p "$wants_dir" | ||
| if [[ -e /usr/lib/systemd/user/omarchy-clock-resync.timer ]]; then | ||
| ln -sfn /usr/lib/systemd/user/omarchy-clock-resync.timer "$wants_dir/omarchy-clock-resync.timer" | ||
| else | ||
| ln -sfn "$HOME/.config/systemd/user/omarchy-clock-resync.timer" "$wants_dir/omarchy-clock-resync.timer" | ||
| fi | ||
| fi | ||
|
|
||
| # Nothing to start into over SSH; the next graphical login handles it. | ||
| if systemctl --user is-active --quiet graphical-session.target; then | ||
| systemctl --user start omarchy-clock-resync.timer >/dev/null 2>&1 || true | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| units="$ROOT/default/systemd/user" | ||
|
|
||
| require_command systemd-analyze | ||
|
|
||
| # systemd ignores a key it does not know with only a warning, so a misspelt | ||
| # OnClockChange= would leave a timer that never fires. verify also checks that | ||
| # the ExecStart binary exists, so it needs the package. | ||
| if [[ -x /usr/bin/omarchy-shell ]]; then | ||
| verify=$(systemd-analyze --user verify "$units/omarchy-clock-resync.timer" "$units/omarchy-clock-resync.service" 2>&1) || | ||
| fail "systemd accepts the clock resync units" "$verify" | ||
| [[ -z $verify ]] || fail "systemd accepts the clock resync units" "$verify" | ||
| pass "systemd accepts the clock resync units" | ||
| else | ||
| skip "systemd accepts the clock resync units: /usr/bin/omarchy-shell is not installed" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.