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

Wayfire Replaced - Do we know how the new environment works with the script now? #52

Open
andiohn opened this issue Oct 29, 2024 · 14 comments
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@andiohn
Copy link

andiohn commented Oct 29, 2024

I'm going to test it, but I was curious if we have some changes to make.

@gjobin
Copy link

gjobin commented Oct 29, 2024

Of course they will replace it just in time for my first setup! First time messing with a RPi and been struggling to understand why it was not working. Now I know. Watching this issue. TY.

@gjobin
Copy link

gjobin commented Oct 29, 2024

I was able to make it launch at startup with this :
sudo echo "~/piosk/scripts/browser.sh" > ~/.config/labwc/autostart

@debloper
Copy link
Owner

No changes would be needed if you stick with wayfire. But, that's swimming against the tide, and not a long term strategy.

We're better off changing the approach of how the browser & keyboard toggle is autostarted. Here's my proposal (feel free to share alternative ideas): #53

@debloper debloper added documentation Improvements or additions to documentation help wanted Extra attention is needed labels Oct 30, 2024
@kwetiaw-goreng
Copy link

the above command didnt work for me. what worked for me though,
sudo raspi-config > select option 6 > A6 > W2 Wayfire > Ok and reboot
After reboot, it launched great!
However, the webui to change the URL is not working, not sure what i can do to fix that though. For now I can manually update the config file.
Hope that helps anyone

@tismofied
Copy link

the above command didnt work for me. what worked for me though, sudo raspi-config > select option 6 > A6 > W2 Wayfire > Ok and reboot After reboot, it launched great! However, the webui to change the URL is not working, not sure what i can do to fix that though. For now I can manually update the config file. Hope that helps anyone

same exact issue here. the gui worked first boot then broke after reboot.

what's the location of the config file to add sites manually?

@debloper
Copy link
Owner

what's the location of the config file to add sites manually?

~/piosk/config.json

Seems like instead of starting nodejs with rc.local script, we should use systemd service unit. That's what breaking nodejs apparently. A lot of people complained about rc.local breaking after updates.

@timb33
Copy link

timb33 commented Dec 2, 2024

what's the last known working rpi OS, that will work as described on the main page? latest 24-11-19 32/64 bit versions don't work. thanks

@timb33
Copy link

timb33 commented Dec 3, 2024

kwetiaw-goreng
sudo raspi-config > select option 6 > A6 > W2 Wayfire > Ok and reboot

this worked for me too (thanks). To get the portal working again, I reran the curl script, which starts the portal. I have to do that every time I change config, but this is workable for me.

actually, every time the script is run, a new entry is added to the startup file. So, the script's not idempotent, and you end up with multiple instances started?

@SpiraMirabilis
Copy link

SpiraMirabilis commented Dec 15, 2024

The piosk needs to use systemd to manage its three scripts that are running.
I'm not really interested in actually submitting a PR but this is how you would do it:

Here is an example of a systemd service that should be used instead of the way piosk currently sets itself up to be autorun:

install in /etc/systemd/system/ and then run sudo systemctl daemon-reload, sudo systemctl enable piosk-browser and sudo systemctl start piosk-browser (repeat for other two)

piosk-browser.service

[Unit]
Description=Run piosk 'browser.sh' to launch chromium
After=default.target

[Service]
Type=simple
ExecStartPre=/usr/bin/sleep 5
ExecStart=/bin/bash /home/pi/piosk/scripts/browser.sh
WorkingDirectory=/home/pi
User=pi
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
Environment=XDG_RUNTIME_DIR=/run/user/1000
Restart=on-failure

[Install]
WantedBy=graphical.target


Note that it has a small sleep delay before the service fires, and it depends on graphical.target so it will launch (with a delay) after the GUI comes up, and it hijacks the pi user's environmental variables for the X display adapter. Note that this will only work if the user is named "pi".

If you configured the raspberry pi user with a different username then you'd have to adjust this. The savvy developer could include these three files as a template in the install script and then use sed to add in the actual user name so that it would always work.

You'd need a seperate version of this for the switcher.sh and also one to run the index.js if you wanted it to switch tabs and have the webserver running, here are the ones I used:

piosk-switcher.service

[Unit]
Description=Run piosk 'switcher.sh' to switch tabs
#After=piosk-browser.service
#Requires=piosk-browser.service

[Service]
Type=simple
ExecStartPre=/usr/bin/sleep 30
ExecStart=/bin/bash /home/pi/piosk/scripts/switcher.sh
WorkingDirectory=/home/pi
User=pi
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
Environment=XDG_RUNTIME_DIR=/run/user/1000
Restart=on-failure
RestartSec=5

[Install]
WantedBy=graphical.target


piosk-webserver.service

[Unit]
Description=Run piosk webserver

[Service]
Type=simple
ExecStartPre=/usr/bin/sleep 5
ExecStart=/usr/bin/node /home/pi/piosk/index.js
WorkingDirectory=/home/pi/piosk
User=root
Restart=on-failure

[Install]
WantedBy=graphical.target


Ideally you should have three of these, including one to run your index.js. Putting things in rc.local is ugly, there is no functionality to restart it if it fails and a bunch of other things.

This will solve the "after X hours the piosk stops switching tabs" issue which is undoubtedly the switcher.sh script failing for some random reason or another, but systemd will automatically restart it as long as "browser.sh" is running.

Edit: I removed the After/Requires section in piosk-switcher.service as this seems to get hung up on boot often and just replaced it with a 30 second delay and hoping for the best, which seems to work well!

@debloper
Copy link
Owner

@SpiraMirabilis you've already done the hard work, just go ahead and send a PR... That'd be great!

As I've said in some other issue... I will only get time by the last week of December (or early January), to clear my GitHub backlogs, depending on how many issues has Santa piled up for me.

@SpiraMirabilis
Copy link

@debloper I went ahead and did so. I had to re-write the setup.sh and cleanup.sh completely. In this new version the piosk package installs itself in and runs from /opt/piosk rather than ~/piosk. if you want to change that, feel free.

@alexjv89
Copy link

alexjv89 commented Dec 31, 2024

Just a thought: these scripts can also be run via pm2. I feel this is simpler, as nodejs is already installed.

as part of setup:

# install pm2 globally
sudo npm install pm2 -g 

# Start the browser service and switcher service
pm2 start /home/cf_pi5/piosk/scripts/browser.sh --name "browser" --interpreter bash
pm2 start /home/cf_pi5/piosk/scripts/switcher.sh --name "switcher" --interpreter bash

# Save this processes to startup
pm2 save
# will save in /home/cf_pi5/.pm2/dump.pm2

# To make it start on system boot
pm2 startup

running pm2 startup will give you instructions to setup pm2 on boot specific to your system.

[PM2] Init System found: systemd
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u cf_pi5 --hp /home/cf_pi5

copy paste execute that and you are good to go.

pm2 unstartup systemd - use this to cancel pm2 from running on boot.

@SpiraMirabilis
Copy link

Since pm2 uses systemd itself, this is just using systemd with extra steps and extra points of failure, though?

@alexjv89
Copy link

hmmm, I guess it's a familiarity thing then - "What library are you more familiar with?". I am sure there are equivalents to pm2 logs switcher & pm2 monit via systemd. I dont have strong opinions about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants