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

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

Open
Zixim opened this issue Feb 22, 2019 · 28 comments
Open

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

Zixim opened this issue Feb 22, 2019 · 28 comments
Labels
Feature request 🏭 Raspberry Pi Testing/testers required 🔽 Workaround available 🆗 Workaround is available/has been implemented, but a definite solution should be found when possible.

Comments

@Zixim
Copy link

Zixim commented Feb 22, 2019

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)

  • Software title Chromium Autostart
  • installed freshly
  • Can this issue be replicated on a fresh installation of DietPi? Yes

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 MichaIng changed the title hide mouse in Chromium autostart kiosk mode DietPi-Software | Chromium: Hide mouse in autostart kiosk mode Feb 24, 2019
@MichaIng
Copy link
Owner

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

crawc commented Feb 28, 2019

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

Zixim commented Mar 1, 2019

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

MichaIng commented Mar 2, 2019

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

@MichaIng MichaIng added the Solution available 🥂 Definite solution has been done label Mar 2, 2019
@crawc
Copy link

crawc commented Mar 11, 2019

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

MichaIng commented Mar 12, 2019

@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"
  • However it has no effect. Only running unclutter -display :0 -idle 0.1 & e.g. from SSH session works.
  • Note that I did a default chromium + Xorg install outside of DietPi-Software, so this is not DietPi related but related to the way how xinit start scripts are pulled in.
  • E.g. calling startx (without desktop opens xterm) works well. The cursor hides always after 1 second idle as defined in the above scripts.
  • But when calling xinit, it does not work, xterm opens just the same, but the cursor does not hide.

Ah understand it now:

  • startx is a xinit wrapper that pulls in xinitrc, while xinit itself does not.
  • So in this case indeed it is cleaner to start unclutter manually with chromium start.

@MichaIng
Copy link
Owner

MichaIng commented Mar 12, 2019

Okay found the best two solutions based on use case

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

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

(Requires validation on RPi, since other Chromium package is used there, but works well on Debian...)

  • 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

So the question is now which one we want to implement by default, if any, or leave choice to user via dietpi.txt setting?

@crawc @Zixim
Any suggestion?

@crawc
Copy link

crawc commented Mar 12, 2019

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

MichaIng commented Mar 12, 2019

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

crawc commented Mar 13, 2019

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

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

  • The xserver is definitely initiated before it runs Chromium (inside), so unclutter should work without sleep. However you could try to add a sleep 1 && to verify.
  • You could as well check if -display :0 is required, but actually when running inside an xserver session it should apply the correct display automatically 🤔.

@crawc
Copy link

crawc commented Mar 13, 2019

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

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

@MichaIng MichaIng added this to the Planned for implementation milestone Mar 13, 2019
@crawc
Copy link

crawc commented Mar 14, 2019

I'm using the root user.

@MichaIng
Copy link
Owner

MichaIng commented Mar 14, 2019

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

crawc commented Mar 18, 2019

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

@MichaIng
Copy link
Owner

MichaIng commented Mar 18, 2019

@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 MichaIng modified the milestones: Planned for implementation, v6.23 Mar 18, 2019
@mrbluecoat
Copy link

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

@MichaIng
Copy link
Owner

MichaIng commented Jan 8, 2020

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

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

@MichaIng
Copy link
Owner

MichaIng commented Jan 8, 2020

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

@MichaIng MichaIng modified the milestones: v6.29, v6.30 Mar 19, 2020
@MichaIng MichaIng modified the milestones: v6.30, v6.31 May 10, 2020
@MichaIng MichaIng modified the milestones: v6.31, Planned for implementation Jun 24, 2020
@arahasya
Copy link

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

@Joulinar
Copy link
Collaborator

Joulinar commented Oct 19, 2020

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

@MichaIng MichaIng removed this from the Planned for implementation milestone May 27, 2021
@ghost ghost mentioned this issue Aug 27, 2022
@MDAR
Copy link

MDAR commented Dec 22, 2022

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

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

MichaIng commented Sep 1, 2023

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.

@MichaIng MichaIng added this to the v8.22 milestone Sep 1, 2023
@MichaIng MichaIng modified the milestones: v8.22, v8.23 Sep 23, 2023
@MichaIng MichaIng modified the milestones: v8.23, v8.24 Oct 21, 2023
@MichaIng MichaIng removed this from the v8.24 milestone Nov 19, 2023
@anandv85
Copy link

anandv85 commented Feb 6, 2025

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.

This solution is detailed enough and it worked fine for me. I was looking all comments and only this specifies exactly which file to update and which line to update. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request 🏭 Raspberry Pi Testing/testers required 🔽 Workaround available 🆗 Workaround is available/has been implemented, but a definite solution should be found when possible.
Projects
None yet
Development

No branches or pull requests

9 participants