On Raspberry Pi - Auto start terminal after login? - raspberry-pi

I'm working on a small project right now. I want the python script to automatically run after loggin into the GUI.
I followed the steps here: https://www.raspberrypi.org/forums/view ... 91&t=65607
But it didn't work for me. What it did was whenever I open up the terminal, the script will run automatically, but not after loggin into the GUI.
So I figured a easy solution is to configure the system so terminal runs after loggin into GUI.
Any suggestions?

To auto-start the terminal on boot, open this file with nano:
nano ~/.config/lxsession/LXDE-pi/autostart
Add this line to the end of the file:
#lxterminal
Close, save and reboot
Reference and some other goodies to run a script on startup as well which may have been what you are actually looking for:
http://blog.startingelectronics.com/auto-start-a-desktop-application-on-the-rapberry-pi/

When you edit or create autostart file in your user space like
~/.config/lxsession/LXDE-pi/autostart
then, this file will override global lxsession autostart file in
/etc/xdg/lxsession/LXDE-pi/autostart
so you should copy everything from global file to your newly created file.
By this way , after reboot you won't get a blank screen running openbox.
So, your file should contain
#lxpanel --profile LXDE-pi
#pcmanfm --desktop --profile LXDE-pi
#xscreensaver -no-splash
point-rpi
And then add your necessary startup items at the bottom like
#lxterminal

In case you want to launch a terminal and automatically run a script inside it, you can do so by passing the --command parameter to the lxterminal command.
Open the autostart file
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Edit the autostart file
Right above the #xscreensaver line, add #lxterminal --command=/path/to/script"
My autostart file looks something like this.
#lxpanel --profile LXDE-pi
#pcmanfm --desktop --profile LXDE-pi
#lxterminal --command="/path/to/script"
#xscreensaver -no-splash
point-rpi
Note: In some places, it is suggested to use the -e flag instead of --command parameter in lxterminal, however that did not work for me. This did.

Related

Bun Not Found After Running Installation Script

I have ran the installation script by pasting this code:
$ curl https://bun.sh/install | bash
However, when I try to get the version of bun, it says it could not find it:
$ bun --version
Command 'bun' not found, did you mean:
command 'ben' from deb ben (0.9.0ubuntu2)
command 'bus' from deb atm-tools (1:2.5.1-4)
command 'zun' from deb python3-zunclient (4.0.0-0ubuntu1)
Try: sudo apt install <deb name>
I had the same issue running on Windows 10 WSL2 Ubuntu-22.04 with Bun v0.1.5.
The solution (and more detail just in case anyone needs it) below:
The executable for bun is in the directory "/home/username/.bun". You need to add this to your $PATH so that this can be found when typing bun commands such as "bun --help".
The bun setup process does not add this path so you need to do it yourself.
Two ways to do this :
(1) Manual method
Type in the terminal:
export BUN_INSTALL="/home/YOUR_USERNAME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
Replacing YOUR_USERNAME with your real username (the current username can be found by typing 'whoami' in the terminal).
Note: This process will have to be REPEATED for every new shell you open.
(2) Automatic method
Edit the .bashrc file :
nano ~/.bashrc
at the end of this file add
BUN_INSTALL="/home/YOUR_USERNAME/.bun"
PATH="$BUN_INSTALL/bin:$PATH"
Replacing YOUR_USERNAME with your real username (the current username can be found by typing 'whoami' in the terminal).
(Remember to save your changes with Ctrl-O)
Note: You will NEED TO OPEN A NEW SHELL for this to work OR type 'source ~/.bashrc' to use in the current terminal.
You should now be able to run bun commands in any new shell.
The installation script says a message at the end telling you how to add bun to your PATH manually. Here is that output:
Manually add the directory to your $HOME/.bashrc (or similar)
BUN_INSTALL="/home/sno2/.bun"
PATH="$BUN_INSTALL/bin:$PATH"
I advise you re-run the installation command and copy the environment variables and add them to your PATH.
export BUN_INSTALL="/Users/manendra/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
add these to your .bashrc, .zshrc or you can use export command to use for current session.
Note: Change your username place of (manendra) "/Users/manendra/.bun"
Manually add the directory to ~/.bashrc (or similar):
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
From the installer, last message is:
To get started, run
exec /bin/zsh
bun --help

Unwanted second command prompt opens when running mongo.exe via command prompt

I'm running a built meteor app on my local machine, and to quickly boot it up, I have a .bat file that runs the following:
start "C:\Program Files\MongoDB\Server\4.2\bin\mongo.exe"
set ROOT_URL=http://localhost
set MONGO_URL=mongodb://localhost:27017/myapp
set PORT=80
node main.js
When I run the cmd to start up mongo.exe it opens up a command prompt with nothing in it, as if I opened it manually.
So now, I really would like to know: why? and how to prevent this.
By default startopens up a new command line window since it assumes your command must be run with cmd.exe. If you do not like to see the window try adding /B to your start command.
See start /? on the command line to check on other options you might find interesting.

Creating a bat file to run raspberry pi commands on windows

I am trying to set up a simple bat file to help non-tech people execute scripts by just clicking a file on desktop.
I haven't used windows in a while, and don't have a real dev environment set up on the computers they are going to be using. I installed putty, and can manually ssh into the pi's and run commands, but I can't teach that process to the employees.
I would like to create a simple bat file that runs the following commands:
ssh pi#192.168.1.xxx
<enter password>: 'xxx'
sudo reboot
Is there a way to do this?
Thank you!
Downloaded Plink #
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
I moved it, AND putty to c:/windows/system32 instead of changing PATH
This doesn't seem necessary, as the next step will automatically locate the file and change the path.
On desktop, right click and create a new shortcut.
In the shortcut path, I typed:
plink -ssh username#192.16.1.xxx -pw raspberry sudo reboot
This worked.
if you recheck the shortcut again, it should automatically change the path to execute plink

Accessing Homestead Globally

So I've installed Homestead and Laravel going through the steps in Laravel Documentation.
One problem that occured throughout the process, is that I can't set "homestead" command, to be accessible globally.
The Documentation writes, that I should just paste that line into the temrinal:
alias homestead='function __homestead() { (cd ~/Homestead && vagrant $*); unset -f __homestead; }; __homestead'
But that only makes it accessible globally untill I restart my terminal.
I've also edited my bash_profile file, adding
export PATH="/Users/MacbookPro/.composer/vendor/bin:$PATH"
to the very bottom of the file, but that does not work either.
To make your alias works every time you open terminal, you've to put your alias into .bashrc file so it been executed every time you open a new terminal tab.
Just add youralias to ~/.bashrc file
or
If you're using ohmyz.sh add youralias to ~/.zshrc file instead.

Is there PostgreSQL profile file like .bash_profile

Everytime I enter PostgreSQL via Terminal (by "psql"), I have to run some certain meta commands, like "\pset null [null]".
So, is there any way to execute it automatically everytime I run "psql", just like the .bash_profile or .bashrc file in the bash shell?
As documented in man psql:
~/.psqlrc
Oh, finally I found a solution via the help information, edit my .bash_profile, add the line:
alias psql='psql --pset=null=[null]'
It works