-
-
Notifications
You must be signed in to change notification settings - Fork 27
Add HiDPI support for Plymouth boot #330
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
base: main
Are you sure you want to change the base?
Changes from 8 commits
71cb927
9c48ddc
bea8944
6f115ea
02cd7bd
03cf5da
1716781
0701853
ab61f47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Configure Plymouth for HiDPI screens | ||
| install_data( | ||
| 'plymouth-hidpi.sh', | ||
| install_dir: get_option('bindir'), | ||
| install_mode: 'rwxr-xr-x' | ||
| ) | ||
|
|
||
| configure_file( | ||
| input: 'plymouth-hidpi.service.in', | ||
| output: 'plymouth-hidpi.service', | ||
| configuration: { 'BINDIR': join_paths(get_option('prefix'), get_option('bindir')) }, | ||
| install: true, | ||
| install_dir: '/etc/systemd/system' | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [Unit] | ||
| Description=Configure Plymouth for HiDPI screens | ||
| After=graphical.target | ||
| Requires=graphical.target | ||
|
|
||
| [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' | ||
|
|
||
| [Install] | ||
| WantedBy=graphical.target | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #!/bin/bash | ||
|
|
||
| CONFIG_FILE="/etc/plymouth/plymouthd.conf" | ||
|
|
||
| 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 | ||
|
||
|
|
||
| # Get the active user based on the currently active graphical session | ||
| ACTIVE_USER=$(who | grep -E '(:[0-9]+)' | awk '{print $1}' | head -n 1) | ||
|
|
||
| if [[ -z "$ACTIVE_USER" ]]; then | ||
| logger -t plymouth-hidpi "No active user with a graphical session." | ||
| exit 1 | ||
| fi | ||
|
|
||
| USER_HOME=$(eval echo ~$ACTIVE_USER) # Get the home directory of the active user | ||
| MONITORS_XML="$USER_HOME/.config/monitors.xml" | ||
|
|
||
| if [[ ! -f "$MONITORS_XML" ]]; then | ||
| logger -t plymouth-hidpi "Monitors XML file not found for user: $PRIMARY_USER" | ||
| exit 1 | ||
| fi | ||
|
|
||
| PRIMARY_MONITOR_SCALE=$(awk ' | ||
| /<primary>yes<\/primary>/ {print prev; exit} | ||
| {prev=$0} | ||
| ' $MONITORS_XML | grep -oP '<scale>\K[0-9]+') | ||
| # Scale=2 means 2x resolution ('Retina Display' in Apple computers) | ||
| logger -t plymouth-hidpi "Primary monitor scale: '$PRIMARY_MONITOR_SCALE'" | ||
|
|
||
| create_config() { | ||
| cat <<EOF > "$CONFIG_FILE" | ||
| [Daemon] | ||
| DeviceScale=1 | ||
| EOF | ||
| logger -t plymouth-hidpi "Created new config: '$CONFIG_FILE' with HiDPI setting" | ||
| } | ||
|
|
||
| apply_hidpi_setting() { | ||
| if [[ "$PRIMARY_MONITOR_SCALE" -eq 2 ]]; then | ||
| if [[ ! -f "$CONFIG_FILE" ]]; then | ||
| create_config | ||
|
|
||
| # Apply the changes | ||
| update-initramfs -u | ||
| logger -t plymouth-hidpi "Updated initramfs after HiDPI change" | ||
| else | ||
| logger -t plymouth-hidpi "HiDPI config file already exists, no changes made" | ||
| fi | ||
| else | ||
| logger -t plymouth-hidpi "Skipped HiDPI settings (DPI: $DPI, Threshold: $HIDPI_THRESHOLD)" | ||
| fi | ||
| } | ||
|
|
||
| apply_hidpi_setting | ||
There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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:
Could you please review the latest commit?