Navigate chromium kiosk to new url from command line

Has anyone come up with a way to change the chromium kiosk url via the command line?

I’d like to be able to navigate to a new url by running something from the command line via ssh.

You already set up kiosk mode with an URL?
Or do you want to start it like

chromium-browser --kiosk ""


I’m already using kiosk mode and it’s correctly booting up and loading the url set as SOFTWARE_CHROMIUM_AUTOSTART_URL in /boot/dietpi.txt. That works great.

And I can ssh in and run chromium <new_url> and that will open a new tab in chromium and navigate to the new url. However, the old url will still remain open in a background tab.

I’m wanting something like dietpi-kiosk-navigate <new_url> which navigates the current chromium kiosk tab to the new url instead of opening a new tab. A command like that could be used over and over on a long running chromium without accumulating a lot of background tabs that waste resources.

My specific use case is that I’m using several low end devices running dietpi to send hdmi signals to TVs in my house that are showing home assistant dashboards that proxy unifi camera feeds via go2rtc. It’s a very nice setup but wasteful to constantly stream video feeds to every TV because the low end devices run hot at nearly max cpu load when they are streaming. I’m trying to automate things a bit so that I only stream video feeds at appropriate times and then navigate away to simpler urls when I don’t need to stream the video.

A command like dietpi-kiosk-navigate <new_url> would give functionality similar to on Android where navigation commands can be remotely pushed to the device.

Note that I can make all this work in home assistant by just making the dashboard more complex to automatically hide and show video feeds and I’ll probably just go that route if I can’t come up with a simple way to navigate chromium from the command line without opening a new tab.

So the easiest way doing this would be closing chrome and restart it in kiosk mode with a new URL. Maybe this is also quite good in your use case, since memory get’s cleaned up.

If you want to manipulate directly the one tab of chrome it get’s a bit trickier and you should have a look into and, to manipulate x server and chrome from command line.

I asked chatGPT :sweat_smile: but I did not test it nor evaluated how legit this answer is:

  1. These tools are necessary for controlling the Chromium window and sending keyboard inputs.
sudo apt-get update
sudo apt-get install xdotool wmctrl
  1. Create a script named dietpi-kiosk-navigate (or any name you prefer) and make it executable.
sudo nano /usr/local/bin/dietpi-kiosk-navigate

Add the following content to the script:

   if [ -z "$1" ]; then
       echo "Usage: $0 <new_url>"
       exit 1
   # Get the window ID of the Chromium browser
   WINDOW_ID=$(wmctrl -l | grep "Chromium" | awk '{print $1}')
   if [ -z "$WINDOW_ID" ]; then
       echo "Chromium window not found"
       exit 1
   # Focus the Chromium window
   wmctrl -ia $WINDOW_ID
   # Send Ctrl+L to focus the address bar
   xdotool key --window $WINDOW_ID ctrl+l
   # Type the new URL
   xdotool type --window $WINDOW_ID "$NEW_URL"
   # Press Enter to navigate to the new URL
   xdotool key --window $WINDOW_ID Return
  1. Make the script executable:
sudo chmod +x /usr/local/bin/dietpi-kiosk-navigate
  1. Usage:
    You can now use the script to navigate the current Chromium tab to a new URL.

This script works by focusing the Chromium window, sending the keyboard shortcut to focus the address bar (Ctrl+L), typing the new URL, and then pressing Enter to navigate to the new URL.

This approach should help you manage the Chromium tabs more efficiently and avoid accumulating background tabs that waste resources.

I don’t think that in kiosk mode adress bar is visible/accesible.

Ah yes.
Hmm then you could start it in remote-debugging mode and send the commands via curl to it

1 Like

Thanks for the suggestions! I got something to work:

chromium <new_url>
DISPLAY=:0 xdotool key ctrl+1
DISPLAY=:0 xdotool key ctrl+w

This opens the new url in a new tab, switches back to the first tab and closes it.