Raspberry Pi Setup

A guide for setup a new raspberry pi

stem raspberry pi linux
Created on 2018-06-26 Last Modified 2018-08-30


Setup for a new Pi

Download the latest version of Raspbian Stretch and download Etcher app to flash the raspbian image to SD card. Plug the flashed SD card to your raspberry and power it on.

Update and upgrade

Open terminal app and run the following command to update and upgrade the packages and OS.

sudo apt-get update
sudo apt-get upgrade

Config the localisation options

Run sudo raspi-config for changing the following settings. - locale (zh-HK UTF, english UTF) - time zone - keyboard layout (English US) - wifi country

Change username

# add user
sudo adduser username

# add user to sudo group
sudo adduser username sudo

# logout
sudo reboot

# ... login with new username

# remove pi user and its home folder
sudo deluser --remove-home pi

Installation of packages

Here is the list of useful packages suggested to install to your pi

  • vim
  • git
  • zsh
sudo apt-get install vim zsh git

Basic zsh config

Install oh-my-zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Custom theme

mkdir -p ~/.zsh-custom/themes && cd "$_"
curl -O https://raw.githubusercontent.com/cyrusn/cyrusn-terminal-setting/master/zsh-custom/themes/cyrusn.zsh-theme 

Setting in .zshrc

ZSH_THEME="cyrusn"
export UPDATE_ZSH_DAYS=13
plugins=(
  git
  z
)

ZSH_CUSTOM=/$HOME/.zsh-custom

alias ls='ls --classify -ahNF --group-directories-first --color=auto --time-style=+"%e/%m/%y %T"'

Setting for Touch led

Rotation

# lcd_rotate=0 Normal 
# lcd_rotate=1 90 degrees 
# lcd_rotate=2 180 degrees 
# lcd_rotate=3 270 degrees 
# ask sh to run the string as programme
sudo sh -c 'echo "lcd_rotate=2" >> /boot/config.txt'

# or rotate for hdmi display
sudo sh -c 'echo "display_rotate=2" >> /boot/config.txt'

brightness

# turn it on
echo 0 > /sys/class/backlight/rpi_backlight/bl_power

# and off
echo 1 > /sys/class/backlight/rpi_backlight/bl_power

# where n is some value between 0 and 255
echo n > /sys/class/backlight/rpi_backlight/brightness

Using openbox

Using openbox to maximise and undecorate the application window by default.

Use text editor to open ~/.config/openbox/lxde-pi-rc.xml. Scroll to bottom and add the following code within <applications></applications> tag.

<!-- 
  This is an example to let LXTerminal open with undecorated mode
  and maximize the screen by default
-->
<application name='lxterminal'>
  <decor>no</decor>
  <maximized>yes</maximized>
</application>
<application name='chromium-browser'>
  <decor>no</decor>
  <maximized>yes</maximized>
</application>

Install chinese input method

sudo apt-get install scim scim-gtk2-immodule scim-tables-zh

Now you can run scim-setup and configure SCIM after reboot.

Install the text editor

Connect to bluetooth

Restart your bluetooth devices before connecting to Raspberry Pi.

$ sudo bluetoothctl
[bluetooth]# power on
[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]# scan on
[bluetooth]# pair MAC_ADDRESS
[bluetooth]# quit

Sometime bluetooth daemon stopped. You may use the script below to start the bluetooth daemon.

sudo /etc/init.d/bluetooth start

References


comments powered by Disqus