Skip to content

Conversation

@rreina
Copy link

@rreina rreina commented Mar 25, 2025

Configure Plymouth to display at 1x scaling on HiDPI screens, such as the MacBook Pro 15" Mid 2015, which has a 192 DPI display. Currently, Plymouth appears too large (2x the expected size) during boot, but displays correctly at 1x during shutdown, likely due to the window manager’s HiDPI settings only available after booting up.

Approach:

  1. Modify the 'meson.build' file to install a service that runs a script, which creates or modifies the '/etc/plymouth/plymouthd.conf' configuration if the primary monitor scaling factor is 2 (2x / 200% / Retina Display)
  2. The service runs once on every boot to keep the Plymouth settings updated based on the scaling of the primary monitor
  3. The script logs changes using the standard logger API.

Testing:

  • The shell script and the service have been fully tested in elementary OS 8
  • Assistance would be very much appreciated to test the integration of the meson script and service during the installation of elementary OS. Specifically, I’m unsure how to modify the elementary OS 8 ISO to include the modified default-settings and perform comprehensive tests.

@vjr vjr requested a review from a team March 26, 2025 01:08
@rreina
Copy link
Author

rreina commented Mar 29, 2025

Hi, thanks for running the CI.

I've been able to build with meson locally and install the generated 'elementary-default-settings' deb package in my machine.

The meson script needed a change so the service is effectively installed and enabled during the post install of the primary deb package. Please check commit #02cd7bd

Regards

@rreina
Copy link
Author

rreina commented Mar 29, 2025

Hi,

I've done further testing and noticed that sometimes the 'xrdb' command doesn't work as expected. To address this, I've applied a fix: the script now waits for Gala to start, not just the X11 session. Additionally, I've simplified the script to only create the configuration file at '/etc/plymouth/plymouthd.conf', assuming it doesn't already exist.

Regards

# Configure Plymouth for HiDPI screens
install_data(
'plymouth-hidpi.sh',
install_dir: '/usr/local/bin',
Copy link
Member

Choose a reason for hiding this comment

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

It will be nice if this can respect get_option('bindir'). To substitute path to the script in plymouth-hidpi.service you can use meson's configure_file().

Copy link
Author

Choose a reason for hiding this comment

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

Indeed. Thanks for the guidance. Please check the latest commit

meson.build Outdated
subdir('gtk')

# Plymouth HiDPI support
subdir('plymouth')
Copy link
Member

Choose a reason for hiding this comment

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

It will probably be nice if there is a meson option to disable this (because I package this on NixOS and we don't enable plymouth by default and don't configure plymouth this way in a immutable system... 😂 )

Copy link
Author

@rreina rreina Mar 30, 2025

Choose a reason for hiding this comment

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

Sure no probs. It's added. Please check the latest commit

Plymouth HiDPI support can be disabled by running Meson with a command like:
meson setup builddir -Denable-plymouth-hidpi=false

@rreina rreina force-pushed the add-plymouth-hidpi-config branch from eebb6bb to d9bde3d Compare March 30, 2025 18:52
…tors.xml file. Also respect get_option('bindir') for improved configuration handling.
@rreina rreina force-pushed the add-plymouth-hidpi-config branch 2 times, most recently from cf43a4e to 1e4d00f Compare March 30, 2025 19:25
@rreina rreina force-pushed the add-plymouth-hidpi-config branch from 1e4d00f to 0701853 Compare March 30, 2025 19:26
@rreina rreina requested review from bobby285271 and lenemter March 30, 2025 21:56
Comment on lines 6 to 9
[Service]
Type=oneshot
ExecStart="@BINDIR@/plymouth-hidpi.sh"
ExecStartPost=/bin/bash -c 'if [ $? -eq 0 ]; then systemctl disable plymouth-hidpi.service; rm -f /etc/systemd/system/plymouth-hidpi.service @BINDIR@/plymouth-hidpi.sh; fi'
Copy link
Member

Choose a reason for hiding this comment

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

What if user upgrades their monitor? I guess we should update plymouth config in this case. What if we just run this session every boot, not just the first one? Will that give us any issues?

Copy link
Author

@rreina rreina Apr 1, 2025

Choose a reason for hiding this comment

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

I agree that'd be a good improvement.

Hence, the following changes were added:

  1. The script now runs on every boot. It doesn't wait for 'Gala' to be running anymore, it just wait until the user logs in (max waiting time is 5 mins, otherwise it tries again on next boot).
  2. The Plymouth config file is created or updated based on needs, and when updated, the scaling setting is edited or removed based on the scaling factor detected.

Could you please review the latest commit?

Comment on lines 5 to 17
TIMEOUT_SECONDS=300 # Maximum wait time in seconds
ELAPSED=0

# Wait until Gala is running or timeout occurs
while ! pgrep -x "gala" > /dev/null && [ $ELAPSED -lt $TIMEOUT_SECONDS ]; do
sleep 5
((ELAPSED += 5))
done

if [ $ELAPSED -ge $TIMEOUT_SECONDS ]; then
echo "Timeout reached while waiting for Gala to start" >&2
exit 1
fi
Copy link
Member

Choose a reason for hiding this comment

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

This should be removed since this script no longer relies on gala

Copy link
Author

@rreina rreina Apr 1, 2025

Choose a reason for hiding this comment

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

Yeah, thanks. The script was waiting for 'Gala' to be ready so there was certainty there's a logged in user, but it wasn't really necessary anymore.

I've pushed an update with the last commit to just check if there's an user logged in (5 mins timeout).

Also, I assume the '~.../monitors.xml' file might not be available immediately after installing elementary OS, at least not until the user logs in for the first time. This is the only reason the script waits for an active user session. Otherwise, I’d remove the session check as well. If you know when the file is created or how to confirm this assumption, that would be very helpful.

@rreina rreina requested a review from lenemter April 1, 2025 13:57
@danirabbit
Copy link
Member

I'm not sure about this solution, but there is a plymouth repo that this PR should be made against instead: https://github.com/elementary/plymouth-theme

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.

4 participants