MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.9k stars 499 forks source link

Configure screen resolution/orientation in Kiosk mode. #7263

Open Nurgak opened 3 weeks ago

Nurgak commented 3 weeks ago

Creating a feature request

Is your feature request related to a problem? Please describe:

In Kiosk mode, sometimes it is useful to set a custom resolution and orientation, rather than the maximum and landscape.

However, currently the Kiosk mode will force the screen resolution to the maximum and orientation to landscape. The only way to change it is via xrand, such as xrandr -d :0 -o right -s 1280x900. This needs to be called every time when Kiosk mode starts.

I'm sure there is a more elegant way to do it, but I have not been successful finding it. The settings in /boot/config.txt (RPi-specific?) only apply for the command line, not in Kiosk mode. Generally speaking, the browser itself should always be maximized in Kiosk mode, so this issue is related.

Describe the solution you'd like:

Ideally, I'd like the settings in /boot/config.txt to apply in Kiosk mode, both for the screen size as well as orientation.

Describe alternatives you've considered:

I considered modifying the Kiosk mode startup script in /var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh, to add xrandr -d :0 -o right -s 1280x900, but I don't like it because this cannot be configured before first boot.

Additional context

My use-case is to display some JavaScript animation. More pixels to refresh is more demanding, and will slow down the animation. Having a more "pixelated" screen is not an issue. This is why a lower screen resolution is useful for me (also portrait orientation).

Related request: I'd like the CHROMIUM_OPTS of the Kiosk mode to be exposed (uncommented) so it could be configured before first boot in dietpi.txt. This is useful as it allows to hide the cursor (and other improvements).

MichaIng commented 3 weeks ago

Here is a request about this: https://github.com/MichaIng/DietPi/issues/5585

In addition, since KMS is mandatory for Chromium, can you try whether it works (instead of using any X config or xrandr) to add

video=HDMI-A-1:768x1024,rotate=90

to /boot/cmdline.txt (space-separated). In case it is not the right HDMI display, find the correct one in /sys/class/drm/, and adjust the resolution as intended. I am actually not sure whether the values need to be inverted with rotate=90.

Nurgak commented 2 weeks ago

@MichaIng Thank you for the reference and the information. I have tried different options in /boot/cmdline.txt, but none work the way I expect. Before Chromium starts the screen resolution is maxed out no matter what options I use.

However, I found the option that does what I need:

In dietpi-config set Display Options -> Display Resolution to 720p. When set to vc4-kms-v3d it does not work.

I wonder if I can get graphical acceleration working in Chromium without setting vc4-kms-v3d...

Nurgak commented 2 weeks ago

Just to update this question with my experience so far:

MichaIng commented 1 week ago

@Nurgak I forgot the video option 🙈, can you try with this:

video=HDMI-A-1:768x1024,rotate=90

Hence same but with the actual option video= prefixed, as the remains are a value of this option.

About your points:

Nurgak commented 1 week ago

@MichaIng Thank you for the correction and help.

I tried to add the option to /boot/cmdline.txt, it did have an effect while booting (console view), but the screen resolution/orientation was reset to maximum and portrait mode when Chromium started, as before.

I always start from a fresh DietPi flash, and reboot it for good measure, but the configuration is not what I expect.

Calling the xrandr command, after Chromium has started, is the only thing that helps right now.

cadavre commented 1 week ago

@Nurgak can you share your diff of chromium-autostart.sh? I'm trying to achieve the same result, but resolution is not changing.

Nurgak commented 1 week ago

@cadavre I did not touch chromium-autostart.sh, ideally I would not want to as it's a generated file.

The resolution can only be set using xrandr -d :0 -o right -s 1280x900 from the command line. Perhaps this command can be added to chromium-autostart.sh?