MichaIng / DietPi

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

DietPi-Software | Chromium: Hide mouse in autostart kiosk mode #2575

Open Zixim opened 5 years ago

Zixim commented 5 years ago

ADMIN EDIT: Solutions

If you still want to be able to use the mouse, only hide it when idle:

On RPi:

G_AGI unclutter && echo '/usr/bin/unclutter -idle 0.1 &' > /etc/chromium-browser/customizations/99-dietpi-unclutter

On all other devices:

G_AGI unclutter && echo '/usr/bin/unclutter -idle 0.1 &' > /etc/chromium.d/dietpi-unclutter

If you never want to use the mouse:

G_CONFIG_INJECT 'xinit[[:blank:]]' 'xinit $FP_CHROMIUM $CHROMIUM_OPTS -- -nocursor' /var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh

Required Information

!/bin/bash

G_DIETPI_VERSION_CORE=6 G_DIETPI_VERSION_SUB=21 G_DIETPI_VERSION_RC=1 G_GITBRANCH=master G_GITOWNER=Fourdee

cat /etc/debian_version 9.8

uname -a Linux DietPi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux SBC device Rpi3

Additional Information (if applicable)

Steps to reproduce

The Pi has no attached keyb nor mouse. as described here : https://github.com/Fourdee/DietPi/issues/2298#issuecomment-443406683 install unclutter add line to chromium-autostart.sh , before xinit line:

sleep 10 && unclutter -idle 0.1 &

xinit $FP_CHROMIUM $CHROMIUM_OPTS

Expected behaviour

Chromium starts and displays page. Cursor disappears after approx 10 seconds.

Actual behaviour

Cursor never disappears

Extra details

Have also tried

xinit $FP_CHROMIUM -nocursor $CHROMIUM_OPTS

No joy.

https://github.com/Fourdee/DietPi/issues/2298#issuecomment-443406683

MichaIng commented 5 years ago

@Zixim Thanks for your report.

I remember this from the other topic, so indeed you tried out both method and non of them worked. I will check this out on x86 machine to verify it's either DietPi or RPi specific.

crawc commented 5 years ago

This seems to do the trick using unclutter, I tested this on a Raspberry Pi 3B+.

/var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh Change the last line to these 2 lines: xinit $FP_CHROMIUM $CHROMIUM_OPTS & sleep 1 && /usr/bin/unclutter -display :0 -idle 0.01 &

Zixim commented 5 years ago

I admit that I never added the display parameter when trying out dietpi. I do have unclutter working on Raspbian boards without the parameter.

MichaIng commented 5 years ago

@crawc Okay, so unclutter has to be started after xinit, this is good to know. I guess xinit has to fully finish, why the sleep is required? Depending on the system 1 second might be not sufficient. For now I added the solution to the OT with sleep 5 and -idle 0.1 (from Fourdees suggestion) to be failsafe.

I still wonder why -nocursor does not work which looks like a cleaner integrated attempt which should apply to the correct display directly and work without any random sleep. I will have a closer look into this.

crawc commented 5 years ago

Sorry for the delayed reply. Yes, without the sleep unclutter can't utilize display :0 until xinit creates it. You are correct 1 second might not be enough time for other platforms. Maybe a better way would be have a loop to check if xinit is started then execute unclutter. I will see what I can come up with and post back.

MichaIng commented 5 years ago

@crawc @Zixim Found the solution with -nocursor. It is indeed an xinit/Xorg option, not a chromium option. But it needs to be added after the xinit chromium call that everything is recognized correctly and after closing the chromium args via --.

So the command entry needs to be: xinit $FP_CHROMIUM $CHROMIUM_OPTS -- -nocursor The cursor is still available. When moving it I see webpage elements highlighting, but it has no visible graphic.


However the noclutter option has the advantage that the cursor can show up when moved. Found some guides about how to add it as desktop autostart script:

But this depends on LXDE desktop which is not always chosen, not must be any desktop chosen for chromium. So we need to find a way to add it as xinit/Xorg autostart script.


Lol actually unclutter should be already executed by default on all xinit calls:

root@VM-Stretch:~# cat /etc/X11/xinit/xinitrc
#!/bin/sh

# /etc/X11/xinit/xinitrc
#
# global xinitrc file, used by all X sessions started by xinit (startx)

# invoke global X session script
. /etc/X11/Xsession

root@VM-Stretch:~# cat /etc/X11/Xsession.d/90unclutter
# /etc/X11/Xsession.d/90unclutter
# This file is sourced by Xsession(5), not executed.

if [ -e /etc/default/unclutter ]
then
        . /etc/default/unclutter
fi

if [ -x /usr/bin/unclutter ] && [ "${START_UNCLUTTER}" = "true" ]
then
        /usr/bin/unclutter ${EXTRA_OPTS} &
fi

root@VM-Stretch:~# cat /etc/default/unclutter
# /etc/default/unclutter - configuration file for unclutter

# Set this option to 'true' if you want to start unclutter
# automagically after X has been started for a user.
# Otherwise, set it to 'false'.
START_UNCLUTTER="true"

# Options passed to unclutter, see 'man unclutter' for details.
EXTRA_OPTS="-idle 1 -root"
MichaIng commented 5 years ago

Okay found the best two solutions based on use case

@crawc @Zixim Any suggestion?

crawc commented 5 years ago

I like the idea of having options: No cursor or Hide cursor when in chrome kiosk mode.

I just tried the unclutter option on the RPi3B+ and it did NOT hide the cursor.

MichaIng commented 5 years ago

@crawc Thanks for testing on RPi. Does /etc/chromium.d even exist there? And if so are there example drop-ins inside? Perhaps this is handled differently by the chormium-browser package on RPi compared to the chromium package on Debian.


Just tested G_AGI unclutter && echo '/usr/bin/unclutter -idle 0.1 &' > /etc/chromium.d/dietpi-unclutter on top of DietPi-Software Chromium install and Chromium autostart and on VM the cursor hides as expected 🤔.

crawc commented 5 years ago

Yes, the directory did exist with a single file custom_flags before I created the dietpi-unclutter file.

root@DietPi:~# ls -ltrh /etc/chromium.d/ total 8.0K -rw-r--r-- 1 root root 255 Feb 28 16:10 custom_flags -rw-r--r-- 1 root root 44 Mar 12 20:10 dietpi-unclutter

MichaIng commented 5 years ago

@crawc Okay, can you please paste the content of the file, just to be sure? cat /etc/chromium.d/custom_flags

crawc commented 5 years ago

I tried with -display :0 , sleep 1 && , and the combination but its still showing the cursor.

root@DietPi:~# cat /etc/chromium.d/custom_flags export CHROMIUM_FLAGS="$CHROMIUM_FLAGS --test-type --no-sandbox --temp-profile --user-data-dir --disable-smooth-scrolling --disable-low-res-tiling --enable-low-end-device-mode --num-raster-threads=4 --profiler-timing=0 --disable-composited-antialiasing "

MichaIng commented 5 years ago

@crawc Hmm the file is identical with the one from Debian. Pre shell script, so the unclutter command should work as desired. However perhaps the files are not sourced. Which user do you use to login? If not root, could you try to login as root? Perhaps non-root users read/source only from their home dir.

crawc commented 5 years ago

I'm using the root user.

MichaIng commented 5 years ago

@crawc Ahh just found another config dir for the chromium-browser package on RPi: /etc/chromium-browser/customizations Could you try to move the dietpi-unclutter inside there: mv /etc/chromium.d/dietpi-unclutter /etc/chromium-browser/customizations/99-dietpi-unclutter And to be sure revert to initial state: echo '/usr/bin/unclutter -idle 0.1 &' > /etc/chromium-browser/customizations/99-dietpi-unclutter

crawc commented 5 years ago

@MichaIng That did it on the RPi3B+, I will test on RPi1 and RPi2 as well! Nice find!

MichaIng commented 5 years ago

@crawc Finally, great! Veery important to know that there are indeed such main differences between RPi and Debian Chromium packages.

Did xinit $FP_CHROMIUM $CHROMIUM_OPTS -- -nocursor btw work as well to hide the cursor permanently?


I added this to v6.23 milestone, now that we finally found the solution on RPi.

MichaIng commented 5 years ago

Implementation planned with some additional options: https://github.com/MichaIng/DietPi/issues/2938

mrbluecoat commented 4 years ago

@MichaIng, xinit $FP_CHROMIUM $CHROMIUM_OPTS -- -nocursor worked for me on a RPI-3B+

MichaIng commented 4 years ago

@mrbluecoat Thanks for testing, I guess the following works as well, doesn't it? xinit -nocursor $FP_CHROMIUM $CHROMIUM_OPTS Its all about having -nocursor as xinit option and not as chromium binary option. -- can be used as syntax to end chromium arguments, but having xinit options in the front should work the same way.

mrbluecoat commented 4 years ago

With your version I get bad command line option "-nocursor" and connection to X server is lost

MichaIng commented 4 years ago

@mrbluecoat Thanks for testing. Okay strange, then xinit requires some different syntax.

arahasya commented 4 years ago

Hi, for auto refresh of chromium every 20 seconds interval should I use 99-dietpi-autorefresh? or add the script code somewhere else?

Joulinar commented 4 years ago

@arahasya I guess you raised same question on the forum https://dietpi.com/forum/t/autorefresh-chromium-kiosk-using-xdotool/4553

MDAR commented 1 year ago

Have you found a solution for this?

This command works for me on an Odroid C4 with DietPi 8.12.1

xinit /usr/bin/chromium --kiosk --window-size=1920,1080 --window-position=0,0 http://127.0.0.1:8080/basicui/app -- -nocursor & (I run this from Node-RED, or versions of it with the URL set dynamically)

Which I guess translates to the autostart.sh file as

exec "$STARTX" "$FP_CHROMIUM" $CHROMIUM_OPTS "${URL:-https://dietpi.com/}" -- -nocursor &

pkoevesdi commented 1 year ago

I think this is the right syntax for "If you never want to use the mouse": exec "$STARTX" "$FP_CHROMIUM" $CHROMIUM_OPTS "${URL:-https://dietpi.com/}" -- -nocursor that has to got into /var/lib/dietpi/dietpi-software/installed/chromium-autostart.sh. So just added an -- -nocursor to the end of the last line. Maybe somebody could edit the initial posting's solution to this? Because, what's now there simply doesn't work on the current (DietPi 8.20.1) version of chromium-autostart.sh. Remember: this thread here has become part of the official documentation: https://dietpi.com/docs/software/desktop/#chromium Still took me half an hour to find the real correct solution.

MichaIng commented 1 year ago

Ah right, many thanks. Indeed the config file location as well as the way the X server is invoked has changed. I'll adjust it this weekend.