Skip to content

Fix screensaver TTE import on Python updates#4530

Closed
skibidiandulka wants to merge 12 commits intobasecamp:devfrom
skibidiandulka:fix/tte-pythonpath
Closed

Fix screensaver TTE import on Python updates#4530
skibidiandulka wants to merge 12 commits intobasecamp:devfrom
skibidiandulka:fix/tte-pythonpath

Conversation

@skibidiandulka
Copy link

@skibidiandulka skibidiandulka commented Feb 6, 2026

Description:
This PR makes the Omarchy screensaver resilient to Python updates that break the tte entrypoint. We now:

  • verify tte actually runs before using it
  • fall back to python -m terminaltexteffects (including older Python site‑packages when needed)
  • track the spawned effect by PID and validate the command line to avoid PID reuse issues
  • always restore the cursor, even if the effect exits early

This prevents immediate exits, stuck invisible cursors, and crashes when the module is present but the tte binary is out of sync
with the system Python.

@skibidiandulka skibidiandulka marked this pull request as draft February 6, 2026 21:54
@skibidiandulka skibidiandulka marked this pull request as ready for review February 6, 2026 21:55
@skibidiandulka
Copy link
Author

skibidiandulka commented Feb 6, 2026

Im a begginer, but I thought that I cant make anything wrong by trying. I think that this could be the fix? I am open to any critisism even if my request doesnt get to the final version. Btw OMARCHY community has been the best one so far!!

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b9ac433a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 11 to 15
# Fall back to running the module via python3 -m.
if python3 -m terminaltexteffects --version >/dev/null 2>&1; then
tte() { python3 -m terminaltexteffects "$@"; }
return 0
fi

Choose a reason for hiding this comment

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

P1 Badge Track python module runs when tte binary is missing

When the tte binary isn’t present, this defines tte() to run python3 -m terminaltexteffects. The spawned process name is python3, so later pgrep -t ... -x tte and pkill -x tte no longer match. In that environment the inner loop exits immediately, the outer loop keeps spawning new screensaver processes, and exit_screensaver won’t terminate the running effect. Consider tracking the PID of the background process or matching terminaltexteffects instead of the tte name.

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 22b709de16

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 12 to 14
if python3 -m terminaltexteffects --version >/dev/null 2>&1; then
tte() { python3 -m terminaltexteffects "$@"; }
return 0

Choose a reason for hiding this comment

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

P2 Badge Ensure TTE PID tracks the real python process

When tte is defined as a shell function for the python fallback, running tte … & backgrounds a subshell, so $! (and thus TTE_PID) refers to that subshell, not the python3 process. In exit_screensaver, killing TTE_PID will stop the subshell but can leave the python process running, so the screensaver may keep running after input. This only happens when tte is not a real binary and the python module path is used. Consider using exec inside the function (e.g., tte() { exec python3 -m terminaltexteffects "$@"; }) so the PID corresponds to the actual process or otherwise capture the python PID directly.

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

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

@codex review

Choose a reason for hiding this comment

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

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Author

Choose a reason for hiding this comment

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

@codex review

@skibidiandulka skibidiandulka marked this pull request as draft February 6, 2026 22:18
@skibidiandulka skibidiandulka marked this pull request as ready for review February 6, 2026 22:19
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f531e35a93

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

fi

while pgrep -t "${tty#/dev/}" -x tte >/dev/null; do
while kill -0 "$TTE_PID" 2>/dev/null; do

Choose a reason for hiding this comment

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

P2 Badge Guard against PID reuse when checking TTE liveness

The loop now relies on kill -0 $TTE_PID to detect whether the screensaver effect is still running. If tte exits and its PID gets quickly reused by another process (e.g., on a busy system), kill -0 will keep succeeding, so the loop won’t restart the effect and the screensaver can stay stuck on a blank window until input or focus change. The prior pgrep -t ... -x tte avoided PID reuse by checking the process name. Consider validating the command name (e.g., pgrep -x -p $TTE_PID tte) or using wait to detect termination.

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

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

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e552863108

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 39 to 44
tte_is_alive() {
[[ -n "${TTE_PID:-}" ]] || return 1
[[ -r "/proc/$TTE_PID/cmdline" ]] || return 1
kill -0 "$TTE_PID" 2>/dev/null || return 1
tr '\0' ' ' <"/proc/$TTE_PID/cmdline" | rg -q 'terminaltexteffects|/usr/bin/tte'
}

Choose a reason for hiding this comment

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

P2 Badge Avoid hard dependency on ripgrep in liveness check

tte_is_alive pipes the cmdline through rg, but this script doesn’t otherwise require ripgrep and rg isn’t referenced elsewhere in bin/. On systems without ripgrep installed, the pipeline exits non‑zero, so the first tte_is_alive call after launch fails and the screensaver exits immediately. This only happens on machines missing rg, but it makes the screensaver unusable there. Consider using grep -Eq (available in base systems) or guarding the rg call.

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

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

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f13436f8c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 39 to 43
tte_is_alive() {
[[ -n "${TTE_PID:-}" ]] || return 1
[[ -r "/proc/$TTE_PID/cmdline" ]] || return 1
kill -0 "$TTE_PID" 2>/dev/null || return 1
tr '\0' ' ' <"/proc/$TTE_PID/cmdline" | grep -Eq 'terminaltexteffects|/usr/bin/tte'

Choose a reason for hiding this comment

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

P2 Badge Accept non-/usr/bin tte executables

The liveness check only matches terminaltexteffects or the literal /usr/bin/tte in /proc/$TTE_PID/cmdline. If the tte entrypoint is installed somewhere else (e.g., /usr/local/bin/tte via pip, or a venv), its command line won’t contain either substring even though the process is healthy. In that case tte_is_alive returns false and the loop immediately calls exit_screensaver, so the screensaver exits right after launch on those installs. Consider loosening the match (e.g., matching tte basename or trusting kill -0) so non-/usr/bin installs don’t get treated as dead.

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

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

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab62027d68

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 39 to 43
tte_is_alive() {
[[ -n "${TTE_PID:-}" ]] || return 1
[[ -r "/proc/$TTE_PID/cmdline" ]] || return 1
kill -0 "$TTE_PID" 2>/dev/null || return 1
tr '\0' ' ' <"/proc/$TTE_PID/cmdline" | grep -Eq 'terminaltexteffects|/tte(\s|$)'

Choose a reason for hiding this comment

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

P2 Badge Detect bare tte cmdline to avoid false exits

The new liveness check only matches terminaltexteffects or /tte, but when tte is installed as a system command its /proc/$PID/cmdline typically contains just tte (argv[0] without a slash). In that common setup, tte_is_alive returns false even while the screensaver is running, so the loop immediately calls exit_screensaver after the 0.1s sleep. Consider matching a bare tte token as well (e.g., (^|\s)tte(\s|$) or (^|/)tte).

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

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

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5939680f2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 50 to 54
exit_screensaver() {
cleanup_cursor
if [[ -n "${TTE_PID:-}" ]]; then
kill "$TTE_PID" 2>/dev/null || true
else

Choose a reason for hiding this comment

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

P3 Badge Avoid killing recycled PID without re-checking

If tte exits unexpectedly, tte_is_alive can return false because /proc/$TTE_PID/cmdline no longer matches, but exit_screensaver will still kill "$TTE_PID" without verifying that PID still belongs to tte. On a busy system the PID can be recycled quickly, so this can terminate an unrelated process when the screensaver exits after a crash. Consider re-validating the cmdline before killing or falling back to a name-based kill only when the PID still matches tte.

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

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

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: caae6f5acf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 54 to 56
else
pkill -x tte 2>/dev/null || true
pkill -f terminaltexteffects 2>/dev/null || true

Choose a reason for hiding this comment

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

P2 Badge Limit terminaltexteffects kill to screensaver instance

When the screensaver's TTE process exits early (e.g., tte fails to start), exit_screensaver falls back to pkill -f terminaltexteffects, which will terminate any other user process running python -m terminaltexteffects outside the screensaver. This is a regression from the prior pkill -x tte behavior and can disrupt unrelated sessions whenever the screensaver fails to start or the PID check fails. Consider scoping the kill to the recorded PID or the current tty/session instead of a global pkill -f.

Useful? React with 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

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

@codex review

Choose a reason for hiding this comment

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

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Author

Choose a reason for hiding this comment

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

@codex review

Choose a reason for hiding this comment

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

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Author

@skibidiandulka skibidiandulka left a comment

Choose a reason for hiding this comment

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

@dhh I think my pull request should be ready to go. I believe this should solve the screensaver not working for most people because of the conflicting python versions. If there are any issues with the code I am more than happy to correct it!!

@Mrid22
Copy link
Contributor

Mrid22 commented Feb 7, 2026

@dhh I think my pull request should be ready to go. I believe this should solve the screensaver not working for most people because of the conflicting python versions. If there are any issues with the code I am more than happy to correct it!!

Hey, this looks great, but AFAIK, someone already opened a PR #4287 for this, and the fix will be implemented in the next release of omarchy. Pretty sure the issue is just a python version mismatch, although there are alot of other nice safeguards in here that could be implemented in a seperate PR

@dhh
Copy link
Member

dhh commented Feb 7, 2026

We've fixed the immediate issue by updating the python-terminaltexteffects package. Going to review what the best next step here is. Maybe we just go all the way to a binary.

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.

3 participants