Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ esac
ln -s /usr/share/apparmor/extra-profiles/bwrap-userns-restrict /etc/apparmor.d/ || true

#DEBHELPER#

# Plymouth HiDPI support

if [ -x /bin/systemctl ] || [ -x /usr/bin/systemctl ]; then
systemctl preset plymouth-hidpi.service || true
systemctl enable plymouth-hidpi.service || true
fi
3 changes: 3 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ subdir('skel')

# GTK settings
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

11 changes: 11 additions & 0 deletions plymouth/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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

install_mode: 'rwxr-xr-x'
)

install_data(
'plymouth-hidpi.service',
install_dir: '/etc/systemd/system'
)
14 changes: 14 additions & 0 deletions plymouth/plymouth-hidpi.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Configure Plymouth for HiDPI screens
After=graphical.target
Requires=graphical.target

[Service]
Type=oneshot
Environment="DISPLAY=:0"
ExecStart=/usr/local/bin/plymouth-hidpi.sh
ExecStartPost=/bin/bash -c 'if [ $? -eq 0 ]; then systemctl disable plymouth-hidpi.service; rm -f /etc/systemd/system/plymouth-hidpi.service /usr/local/bin/plymouth-hidpi.sh; fi'

[Install]
WantedBy=graphical.target

48 changes: 48 additions & 0 deletions plymouth/plymouth-hidpi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

CONFIG_FILE="/etc/plymouth/plymouthd.conf"
HIDPI_THRESHOLD=180 # Min DPI of a HiDPI screen

TIMEOUT=300 # Set the maximum wait time in seconds
ELAPSED=0

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

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

# Get current DPI
export DISPLAY=":0"
DPI=$(xrdb -query | grep dpi | awk '{print $2}')

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 [[ "$DPI" -ge "$HIDPI_THRESHOLD" ]]; 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