Using Gnome-Schedule to run shell script that opens Chromium browser - linux

I have a Raspberry Pi running Raspbian 8.0. I have a shell script that triggers a Chromium Browser to open and go to a specified URL that changes every day. The shell script works when executed from the terminal. How would I get this to work through Gnome Schedule's GUI? I would like this to trigger everyday at a specified time. I've tried setting the command to /home/pi/test.sh, sh /home/pi/test.sh. I read something about needing to specify the display output since I'm running Gnome Schedule from root which isn't the current user logged in. So for that I tried export DISPLAY=:0 && /home/pi/test.sh. Is this going to be possible?

If you put
export DISPLAY=:0.0 at the top of your script rather than export DISPLAY=:0, this should work.

Related

Raspberry Pi tkinter app blank screen when run from script, works fine when run directly from terminal

I have created a weather forecast display application using Python and tkinter for Raspberry pi zero. The app pulls the weather from a weather api using requests and displays the forecast using images and labels. I run the app using python3 ./myappname.py and everything works fine.
I want this app to display automatically every time Raspberry Pi restarts. So I am writing a bash script that starts the application. The next step is to run the bash script on startup using cron or autostart. I have created a script with this code:
/bin/sleep 10 && /usr/bin/python3 /home/pi/myappname.py
I am running it using sh myscript
When I run this script, the app loads but there are no images or labels on the page, its a blank white screen. There are no error messages.
What could be causing the app to render fine when I directly run it but blank white screen when running with a script?
Most probably your script is loading images in relative path.
python ./myappname.py indicates that the current directory is the directory where the script is, so it works.
However the current directory may not be the python script directory when running the bash script at startup.
You need to change directory to the python script directory before running the python script inside the bash script:
#!/bin/bash
cd /home/hi
/bin/sleep 10
/usr/bin/python myappname.py

How to get a terminal for output when running a .sh script?

I am new to Linux. I have a simple .sh file that help me to run an application from a directory.
#!/bin/bash
/home/nick/TestApp/app.x86_64
when I run the .sh file, I can observed that the console app is running in the background from System Monitor. However, there is no terminal showing up and I could not see the output of the program. How do I get it to work like it was executed from a terminal manually? I want to see the output.
P.S. I am running the .sh from Desktop with double click.

Run Google Assistant SDK on boot (Raspbian)

I am currently trying to get a cron job working, so that the google assistant starts automatically after boot. For that I created this cron job which executes on reboot.
SHELL=/bin/sh
PATH=/usr/bin:/bin:/home/pi/Desktop:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#Reboot lxterminal -t "Google Assistant" -e /bin/bash /home/pi/Desktop/init.sh
lxterminal will open a window with google assistant running within.
Here is my full cron job:
#!/bin/bash
SHELL=/bin/sh
PATH=/usr/bin:/bin:/home/pi/Desktop:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
source /home/pi/env/bin/activate
python3 /home/pi/assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/grpc/pushtotalk.py
I already tried answers from similar problems and even specified the path variable for cron, but it still won't work for me. The script isn't the fault, when I execute it manually it runs fine.
The problem wasn't with cron, though I settled for using a systemd service instead.
What I didn't know was, that Lxterminal needed a initalized screen to work and due to the script running on boot it wasn't.
This is an easy fix. Either add an delay of 30 Seconds or other values, depending on your system, to the beginning of your script or simulate the display beeing initalized already with export DISPLAY=:1

Invoke node.js from Linux desktop menu

This may be related to how Linux desktop menu items are invoked.
I have a script like this:
#!/bin/bash
cd ~/mydir/
node server.js
which works fine when I run it inside a terminal shell, but when I put it into the Linux desktop menu, the server was not executed (the process 'node' is not present).
I changed it to:
node ~/mydir/server.js
but it is still not working (but it works in the shell terminal).
Strangely, when I was using other non-Node.js servers, such as http-server, it works even when the script is invoked from the desktop menu.
Any ideas?

Using script to automatically start program when the system boot up (linux, shell)

Here is the situation, I'm planning to use a simple script to start a program call "STAF", when the Suse system is fully booted. I have achieved this by putting it in the "/etc/init.d/", but this script is basically executed at the background, which means that I cannot see its progress.
When the "STAF" is started this way it works but it doesn't show any working progress when its running service (for example ping, or system backup), instead if I start the "STAF" manually by running the same script whit a terminal, the working progress of "STAF" can be seen on the terminal. Its sort of like the program needs to be started with a interactive terminal, but how can I make this starting process automatic and it should imitate human opening a terminal and run the script?
Sorry if I explained it poorly because its a confusing situation. Thanks.
First, go to the KDE Startup and Shutdown options under System Settings. Then add this command as a new startup script:
konsole -e bash nameofyourscript.sh
I believe the screen utility can do what you describe. Instead of running STAF on startup, you would run screen STAF. To open that terminal, you would run screen -ls to get the screen ID, and screen -r ... to open it.
(Disclaimer: I have not tried this.)

Resources