|
#!/bin/bash |
|
#info0 |
|
echo "This shell script is from |
|
https://wiki.52pi.com/index.php?spm=a2g0o.detail.1000023.1.71427e02hq4nqq&title=ZP-0172 |
|
and carefully copied and optimized into single shell file. |
|
" |
|
|
|
#info1 |
|
echo "This shell script assume you've checked the command |
|
i2cdetect -y 1 |
|
after enabling it with raspi-config. |
|
|
|
To make sure I'm executing it:" |
|
i2cdetect -y 1 |
|
echo "" |
|
|
|
#info2 |
|
echo "You'll be asked some passwords to run some command. |
|
DO NOT RUN THIS SCRIPT AS SUPER USER! STUFF WILL BREAK! |
|
(If run as SUPER USER or SUDO the script will exit.) |
|
" |
|
#set $USERNAME to the output of whoami |
|
whoami | grep -q 'root' && exit |
|
USRNAME="$(whoami)" |
|
|
|
#step 3 |
|
sudo apt -y install python3 python3-pip python3-pil libjpeg-dev \ |
|
zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 |
|
|
|
#step 4 - grant privilleges to user |
|
sudo usermod -a -G gpio,i2c "$USERNAME" |
|
|
|
#step 5 - git clone and move to |
|
git clone https://github.com/geeekpi/luma.examples.git |
|
cd luma.examples |
|
|
|
#step 6 - install python script |
|
sudo -H pip3 install -e . --break-system-packages |
|
|
|
#step 7 - run examples |
|
cd examples |
|
echo "If you want to run the program, you can simply type |
|
cd $(pwd) |
|
and run one of the '.py' files listed here: |
|
" |
|
ls |
|
echo "If you want to edit service, type |
|
sudo nano /lib/systemd/system/minitower_oled.service |
|
(you can use your beloved editor if you want but should pass sudo) |
|
and edit the path after \"ExecStart=/bin/bash -c 'python3\" |
|
to $(pwd)/your-script.py |
|
and restart service with: |
|
|
|
sudo systemctl daemon-reload |
|
sudo systemctl restart minitower_oled.service |
|
|
|
Here is the basic clock display service. Please check the display." |
|
|
|
python3 clock.py |