2

I have a Chromium running in Kiosk mode. I want to change the URL of the page via SSH

If it weren't in Kiosk mode I'd use xdotool:

export DISPLAY=":0"
WID=$(xdotool search --onlyvisible --class chromium|head -1)
xdotool windowactivate ${WID}
xdotool key ctrl+l
xdotool type 'www.example.org'
xdotool key Return

But this doesn't work. Probably because it's in kiosk mode.

Apart from that, my xdotools is working fine

export DISPLAY=":0"
WID=$(xdotool search --onlyvisible --class chromium|head -1)
xdotool windowactivate ${WID}
xdotool key ctrl+F5

Does refresh my page

Perhaps xdotool is not the way to go for this very case?

EDP
  • 309
  • 1
  • 6
  • 18
  • Did you try just issuing the command "chromium-browser $URL"? Often, the window is attached to the existing one (in a new tab) and opens the specified URL. – Nemo Aug 15 '16 at 08:34

4 Answers4

2

Just leave kiosk mode

 !#/bin/sh
    export DISPLAY=":0"
    WID=$(xdotool search --onlyvisible --class chromium|head -1)
    xdotool windowactivate ${WID}
    xdotool key F11
    xdotool key ctrl+l
    xdotool type 'www.google.com'
    xdotool key Return 
    xdotool key F11
1

You might try xdotool getmouselocation on a ssh session, experimenting locations via VNC viewer. The output is like: x:543 y:21 screen:0 window:20975913

Then automate mouse clicks eg xdotool mousemove 543 21 xdotool click 1 xdotool mousemove 543 136 xdotool click 1

Jose Alban
  • 7,286
  • 2
  • 34
  • 19
1

I found a way to do it using node.js

  1. Launch chromium with remote debugger option: chromium-browser --kiosk --remote-debugging-port=9222

  2. Install node

  3. Use this script passing the url you want to display as first arg

const WebSocket = require("ws");
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, label, printf } = format;

const myFormat = printf(({ level, message, label, timestamp }) => {
    return `${timestamp} [${label}] ${level}: ${message}`;
});

const logger = createLogger({
    level: 'info',
    format: combine(
        label({ label: 'right meow!' }),
        timestamp(),
        myFormat
    ),
    defaultMeta: { service: 'user-service' },
    transports: [
        new transports.Console(),
        new transports.File({ filename: 'changUrl.log', level: 'error' }),
        new transports.File({ filename: 'changUrlCombined.log' }),
    ],
});

const axios = require('axios')

var args = process.argv.slice(2);
console.log("args:" + args)
axios.get('http://127.0.0.1:9222/json')
    .then(resp => {
        const data = resp.data;
        if (data.length > 0) {
            const firstTab = data[0];
            const wsUrl = firstTab.webSocketDebuggerUrl;
            if (wsUrl) {
                //open websocket
                const wsChrome = new WebSocket(wsUrl);

                wsChrome.on('open', function open() {
                    const dataChangeUrl= {
                        id: 2,
                        method: "Page.navigate",
                        params: {
                            url: args[0] || "http://yahoo.com"
                        }
                    }

                    wsChrome.send(JSON.stringify(dataChangeUrl))
                    //You can use promise-ws to exit the program
                    //.then(() => process.exit())
                });
            }
        }
        else {
            logger.error("No tabs open")
            console.log(resp.data);
        }
    })
    .catch(err => {
        // Handle Error Here
        logger.error(err);
    });

Then you can run "sudo node ./changeurl.js https://facebook.com"

0

the reason it doesn't work in Kiosk mode is that there is no Address bar in this mode.

So the xdotool is working but when you press Ctrl+L nothing is opening up and so no address can be typed and therefore loaded.

I am currently also looking for a way to change the url in Kiosk mode without having to restart the PI

Hope this helps

Dave
  • 9
  • 2
  • That makes so much sense! For the moment I'm bypassing it through a html file with a javascripted meta refresh iframe. If interested I can share this code. – EDP Jul 29 '15 at 07:32
  • Please do i am interested – Dave Jul 29 '15 at 07:42