-->
BLANTERWISDOM101

autorun autostart command script di linux Raspbian raspberry pi 2

Wednesday, March 27, 2019


1. run program by click (shortcut .desktop)

# buat file .sh di /home/pi misal namafile-sh.sh
#! /bin/bash
source /home/pi/.profile
workon py3cv3
#cd direktory
cd /home/pi

#arahkan ke file python
python3 pi_ngantuk.py

exit 0

#permission
chmod +x filenya.sh

#membuat shortcut atau launcer di desktop

sudo apt-get install --no-install-recommends gnome-panel
gnome-desktop-item-edit ~/Desktop/ --create-new

arahkan ke file .sh, selesai

2. run program auto ketika booting

# buat file .sh di /home/pi
#! /bin/bash
source /home/pi/.profile
workon py3cv3
#cd direktory
cd /home/pi

#change YourProgramExactName to Exact name of your program that you want to aut$
python3 pi_ngantuk.py

exit 0
# masuk dir .config
cd .config
#buat folder lxsession
mkdir lxsession
#buat folder LXDE-pi didalam lxsession
mkdir LXDE-pi
#buat file autostart, sehingga total dirnya .config/lxsession/LXDE-pi/autostart
nano autostart
masukkan data
@lxterminal

#edit data di ~/.bashrc
sudo nano ~/.bashrc
masukkan data di line terakhir
bash /home/pi/namafile-sh.sh
reboot. lalu autostart work Properly 😼




*Note :
dengan adanya  folder lxsession , maka sementara GUI desktop tidak bisa diakses. untuk mengaksesnya folder lxsession dihapus.

sumber : https://blog.startingelectronics.com/auto-start-a-desktop-application-on-the-rapberry-pi/
bisa juga  pake sumber ini https://www.raspberrypi-spy.co.uk/2014/05/how-to-autostart-apps-in-rasbian-lxde-desktop/
Share This :

0 comments