How can I launch a program (Chromium) from within Octoprint via a plugin? I have an Octoprint box that contains a large touch screen, and I want to bring up Chromium to log into Octoprint so I can control the printer locally.
I can manually bring up Chromium with site 127,0,0,1, but I want to do it automatically though a plug-in.
OctoPrint isn't the OS & doesn't control the screen, so doing this through a plugin is not really what you want to do. To open a browser on the screen, you need to do this separately.
I would setup a systemd service file to open chromium automatically on startup, so you don't have to do it manually.
now that I think about it, if you get the commands needed to open chromium browser the way you like from the command line, you could probably use the bundled event manager plugin to do this for you on startup event. just make sure you use the full path to chromium-browser executable.
can't you run a kiosk chromium browser without a desktop. you still have to have a desktop manager, but I don't think you have to have an actual desktop. Basically what the TouchUI script would do IIRC.
Yeah, the install script runs through these additional scripts....
I understand TouchUI may be outdated and definitely no longer being maintained, but the repo I linked was specifically just getting chromium browser to run automatically. It more than likely doesn't work anymore in bullseye (and maybe not buster), but may have some good pointers to what it would take to have the browser start automatically.
Why does it need to be done from within a plugin? Are you wanting a button in the UI, that you can click on another device to open it on the touchscreen? Or just to autostart it with OctoPrint?
I appreciate it is possible to run system commands from within Python and within a plugin. But depending on how you setup OctoPrint, it could be more difficult to open a desktop & browser environment than if it was done separately. If OctoPrint is setup to run automatically in the background using systemd for example, it may not have the context required to open the browser on the screen. It's been a while since I messed with this kind of thing so not 100% sure.
You may run into issues restarting OctoPrint, potentially having to also close the browser as it will be treated as a child process and wait for it to exit before restarting.
If you must do it from within a plugin, plugins are written with Python so you can put the code you referenced above (or any other code that calls OS system commands) within a plugin.
I don't care if it is run as a plugin. My only concern is that I cannot make mods to an existing plugin and expect it to run under someone else's code. Here's what I want to do:
I currently run the plugins: Automatic Shutoff, GPIO Shutdown (abandoned), and Enclosure (soon to be abandon). With the Enclosure plugin, I am only interested in turning on and off lights with a GPIO pin and having a button on the main screen of Octoprint to do that (I can do it with the Enclosure plugin. With the Automatic Shutoff plugin, I have a button on the main screen asking if I want to shutdown the system after the print job has ended.
Needless to say, since two of the plugins I use are abandon, I am considering writing a new plugin, combining what I need from the ones I use, and adding the invoking of the Chromium browser. To do all of that in Octodash would be unwieldy and would probably not happen. When I launch the Chromium browser, I get a replication of what I would see if I logged onto Octoprint as a conventional browser, which would be useful.
I have built special hardware to shutdown both the Pi and the printer (by turning on a GPIO pin) if the print job ends (if that option is selected).
I would like to be able to control the printer from Octoprint directly, and not have to run over to a computer with a browser. That's why I want things to be displayed locally on my Octoprint box.
I am not very Linux literate, but I know C and somewhat know Python.
Ok. Abandoned plugins just don't stop working (tho they will eventually if they check python versions or python versions mess things up). What I want to know is "What do you see on the touch screen when you turn on the Pi?"
Ok so the Pi is already auto-running chromium and auto-logging into OctoPrint when booted. At least that is what your screen shot is telling us. Usually you get a text boot screen or a desktop when booted depending on setup. So from the browser, to get another tab, try Control-T.
The pi is NOT auto running chromium. That screenshot came from Brave on a Windows machine. The Pi boots into Octoprint and the UI. From there I manually load Chromium, and use bookmarks to log into Octoprint.
Don't know what another tab will do for me.
My original intent was to automatically launch Chromium, and have it auto-log into Octoprint. I wanted to do this through a plugin so I could insure Octoprint is fully up.
And you sent a screen shot from a Windows machine - thanks makes my day...
Really, I think we have a failure to communicate...
Open Chromium on the Pi.
Click the 3 dots on the far right to Customize and control Chromium.
Settings > On Startup > Open a specific set of pages.
Site Url: localhost whatever for your setup.
Close Chrome.
Using your editor make a file - the name is up to you.
It should contain the line:
"DISPLAY=:0 chromium-browser -start-maximized"
Save it, chmod 755 whatever filename
Go to a browser with your OctoPrint running and load the Cmd Exec plugin. Add the command and icon.
Icon up to you and command "cd ~ && ./filename"
From now on, you click that icon on any OctoPrint UI and it will open a browser on your Pi.