Skip to content
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

Configure screen resolution/orientation in Kiosk mode. #7263

Open
Nurgak opened this issue Oct 31, 2024 · 8 comments
Open

Configure screen resolution/orientation in Kiosk mode. #7263

Nurgak opened this issue Oct 31, 2024 · 8 comments

Comments

@Nurgak
Copy link

Nurgak commented Oct 31, 2024

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
Copy link
Owner

MichaIng commented Oct 31, 2024

Here is a request about this: #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
Copy link
Author

Nurgak commented Nov 5, 2024

@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:

  • dietpi.txt
    SOFTWARE_CHROMIUM_RES_X=720
    SOFTWARE_CHROMIUM_RES_Y=1280
  • config.txt
    framebuffer_width=720
    framebuffer_height=1280
    display_hdmi_rotate=1

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
Copy link
Author

Nurgak commented Nov 8, 2024

Just to update this question with my experience so far:

  • Chromium does not need any extra configuration in /var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh to have OpenGL acceleration enabled (RPi4).
    • However, upon the first boot/headless install the RPi needs to be rebooted for OpenGL to be available for Chromium.
    • Make sure the DISPLAY environment variable is not set, or OpenGL will not be available.
  • There is no dietpi.txt, cmdline.txt or config.txt options that would allow screen resolution/orientation definition for Chromium in Kiosk mode, it will be reset to the maximum in landscape upon the script execution.
    • The only way to change it is to call xrandr -d :0 -o right -s 1280x900 once Chomium is started.
  • The Chromium auto-start script (/var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh) has flawed instructions on how to customize the options: CHROMIUM_OPTS+=' --...' does not work (options are not appended, they are ignored).
    • It should be CHROMIUM_OPTS="${CHROMIUM_OPTS} --...".
    • I would make a PR, but I don't know where the Chromium auto-start script template is hosted.

MichaIng added a commit that referenced this issue Nov 8, 2024
- DietPi-Software | Chromium: Resolved an issue where optional Chromium flags via "CHROMIUM_OPTS+=" line in /var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh did not have any effect, as "+=" is bash-only syntax, while the script is executed with dash (bourne shell). Many thanks to @Nurgak for reporting this issue: #7263 (comment)
@MichaIng
Copy link
Owner

MichaIng commented Nov 8, 2024

@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:

  • Right, on first boot, KMS (and hence hardware acceleration) is not enabled yet, but it is set to be enabled automatically, once Chromium is installed, requiring a reboot to take effect.
  • Please try again with above in /boot/cmdline.txt.
  • Good find, var+=value is bash-only, while the script is executed with dash since a while, so that this line throws a syntax error. Fixed with: 497d95d

@Nurgak
Copy link
Author

Nurgak commented Nov 11, 2024

@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
Copy link

cadavre commented Nov 14, 2024

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

@Nurgak
Copy link
Author

Nurgak commented Nov 15, 2024

@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?

@Nurgak
Copy link
Author

Nurgak commented Dec 20, 2024

@MDAR
If you are taking about the SOFTWARE_CHROMIUM_RES_X/Y then yes, these fix the Chromium size, however that is different from the display resolution, which defaults to the maximum the screen can support. So you can set a lower Chromium resolution, but then Chromium will only take up part of the screen.

My goal was to set the display size and Chromium size so Chromium would be full-screened while the display is at a lower resolution than its maximum, which is currently not possible when using vc4-kms-v3d.

This was referenced Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants