Hiding cursor on raspbian stretch chromium - raspbian

I'm running a RPi 3 as an infoscreen. Im just starting chromium with the xinit command from rc.local, so far so good. I'm having trouble to hide the cursor. When i do this from command line (SSH) when the screen is running this works just fine:
DISPLAY="0.0 ; export DISPLAY
unclutter -idle 0.1 -root
But I cant find out where to put this so this starts automaticly. It seems that setting DISPLAY in the rc.local file doesnt work. When i try to run unclutter without setting DISPLAY it can't open the display. Where do I set the DISPLAY variable at startup?

I would find it better for the script to run at login, and this is how you would do it:
You can add your script executable command to the bottom of .bashrc that will run your script every time you log in.
Make sure you are in the pi folder:
$ cd ~
Create a file and write the script to run in the file:
$ sudo nano superscript
Save and exit: Ctrl+X, Y, Enter
Open up .bashrc for configuration:
$ sudo nano .bashrc
Scroll down (Down arrow key) to the bottom and add the line: ./superscript
Save and exit: Ctrl+X, Y, Enter

Related

Raspberry Pi Zero W start script on startup

I'm creating a time-lapse camera to attach to a pair of glasses.
I tried out my script (python 3) and it works, but I need to get my script to work upon startup up since it will powered by a powerbank and I can't manually start the script because of that. (filename is "GlassCam.py" in the folder named "GlassCam")
This is what I've tried in the command line:
sudo nano ~/.config/lxsession/LXDE-pi/autostart
then in the menu
sudo /usr/bin/python3 /home/pi/GlassCam/GlassCam.py
(control+x and then y to save)
yet it won't start when I reboot it or shut it down and plug it back in
Try creating a cron job: sudo crontab -e and then add your script at the end of the file (to be executed on reboot) like this: #reboot python /home/pi/GlassCam/GlassCam.py &

Chromium pop up on Raspbian

I'm running Chromium 16 on a Raspberry Pi 3 with the latest Raspbian. My purpose is to launch a Chromium page in --kiosk mode on start-up.
The Pi will always be shut down by switching the power off, so on start-up Chromium shows the "Chromium didn't shut down properly" pop-up. I need to disable this pop-up. I already looked for a bunch of solutions on the web, especially on this thread: https://superuser.com/questions/873381/how-can-i-disable-the-chromium-didn-t-shut-down-correctly-message-when-my-brow
Sadly, none of these work for me. I also tried to set the permissions for the chromium preferences file to read only, but permissions seem to be restored on boot.
Any ideas?
I was looking for a long time, here is my solution:
#!/bin/bash
#Set CrProfile to the value of your startup profile's config folder
CrProfile="Default"
HomeFolder="/home/myhome"
#Set URL to the URL that you want the browser to start with
URL="http://www.apple.com"
#Delete SingletonLock
rm -f $HomeFolder/.config/chromium/SingletonLock
rm -f $HomeFolder/.cache/chromium
#Clean up the randomly-named file(s)
for i in $HomeFolder/.config/chromium/$CrProfile/.org.chromium.Chromium.*; do
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' $i
sed -i 's/"exit_state": "Crashed"/"exit_state": "Normal"/' $i
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' $i
done
#Clean up Preferences
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' $HomeFolder/.config/chromium/$CrProfile/Preferences
sed -i 's/"exit_state": "Crashed"/"exit_state": "Normal"/' $HomeFolder/.config/chromium/$CrProfile/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' $HomeFolder/.config/chromium/$CrProfile/Preferences
#Clean up Local State
sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' $HomeFolder/.config/chromium/"Local State"
/usr/bin/X11/chromium-browser --no-first-run --kiosk $URL
In most recent version (v60 here), I fix this by running with the following argument
chromium-browser --kiosk --app=http://www.example.com
For those arriving here from Google:
The best way to now perform this task, without having to use incognito, is to adjust two settings in the Chromium preferences. They are:
exited_cleanly
exit_type
From what I have gathered from personal tests, just changing the "exited_cleanly" setting may not always work at preventing the Chromium prompt on startup. Other flags such as "-disable-infobars" will also not work.
To adjust these settings, please add the following in your startup file, before launching Chromium (depending on how you have set up Chromium to automatically run in kiosk mode, this file can either be located at "/etc/xdg/lxsession/LXDE-pi/autostart", "/etc/xdg/openbox/autostart", "~/.Xsession", or another file, depending on what you have already installed).
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/Default/Preferences
sed -i ‘s/”exit_type”: “Crashed”/”exit_type”: “Normal”/’ ~/.config/chromium/Default/Preferences
For example, with my setup (using Xsession), the procedure would go as follows:
Enter "sudo ~/.Xsession" into the console
Insert the above 2 lines into the file, before Chromium is run (You should see a line starting with "chromium-browser", so insert them above this)
Press ctrl + X to exit the file
Type "Y"
Press enter
Reboot the machine
Again, the file used to start up Chromium may be located in a different location, depending on how you have setup your pi, but after changing these two settings, Chromium should start up without displaying the crashing prompt.

How to start a Rails server with an .sh script in a directory of choice

I've been developing with rails for a year now, and although rails is pretty well automated, I'd like to take it one step further.
Every time i start working on a project, i open the terminal, cd to a project folder, than new tab in the terminal, then start the server with "rails s" then back to the first tab to run "sublime ." so that i load the folder in my text editor, Sublime Text.
What i would like is to create a .sh script that would do all that for me, but so far i haven't been able to make it start the server.
So, how to start rails server with a .sh script in a directory of choice?
#Manolo gave me an idea, so I've come up with this:
I modified my .bashrc as the following answer illustrates:
https://superuser.com/a/198022
Basically i added
eval "$BASH_POST_RC"
At the end of my .bashrc so i could run arbitrary commands after it was executed.
Next, i made a following script:
#launch_project.sh
#/bin/bash
cd <PROJECT DIR GOES HERE>;
firefox -P "development";
sublime . &;
gnome-terminal \
--tab --title="Server" -e 'bash -c "export BASH_POST_RC=\"rails s\";exec bash"' \
--tab -e 'bash -c "export BASH_POST_RC=\"git s\"; exec bash"';
That launches my development profile on firefox, my editor with a project root, and terminal window with two tabs - one that runs a WEBrick server, and another one which runs git status for me.
I made a desktop shortcut to the script so i have my own custom IDE of sorts :)
Try this:
#!/bin/sh
cd your_project_folder
nohup rails s > /tmp/rails_server.log 2>&1 &
sublime .
you can see the ouput of your rails server at the /tmp/rails_server.log file

bash script for screen -r

I want to make a bash script that echo's something into one of the screens that I have running (screen -r is how I get to it in SSH).
I was wondering how I would make the script execute itself in screen -r?
I basically just want the script to say something on a minecraft server through the console and would set up a cronjob to say it every x minutes.
Cheers,
You can use the -X option of screen to send commands to a running screen session.
Also the -p option is useful in this case, as you can use it to preselect a window
As an example you can run a script in a running screen session on windows 0 via:
screen -p 0 -X stuff './fancy_script.sh^M'
Note, that you have to append the return key-code to execute the script.
You can look in /dev/pts. I don't have screen here to test, but you can echo something to an opened terminal with, for example, echo "toto" > /dev/pts/0 (it will be echoed on the first opened terminal).

Is there a way to configure PuTTY or other terminal to flash the taskbar on next output to stdout?

I'm specifically looking for a solution for PuTTY but also interested for other terminal emulators, like Gnome Terminal.
My thought is it would be useful if I start a tar zxvf to be able to set a trigger on the terminal emulator, minimize it, and on next output to stdout/stderr I get a notification in the task bar that the command has finished.
This works for me:
echo -e "\a"
Then update your PuTTY session to use the Visual Bell, and set "Taskbar/caption indication on bell" to Flashing or Steady.
Then run this command after your tar completes:
tar xvzf file ; echo -e "\a"
Here is a screenshot: Save these settings as the default settings and/or the sessions' settings you have