網頁

顯示具有 Linux 標籤的文章。 顯示所有文章
顯示具有 Linux 標籤的文章。 顯示所有文章

2020年9月8日 星期二

GStreamer 安裝

依據說明文件安裝
sudo apt-get install libgstreamer1.0-0
sudo apt-get install gstreamer1.0-plugins-base
sudo apt-get install gstreamer1.0-plugins-good
sudo apt-get install gstreamer1.0-plugins-bad
sudo apt-get install gstreamer1.0-plugins-ugly
sudo apt-get install gstreamer1.0-libav
sudo apt-get install gstreamer1.0-doc
sudo apt-get install gstreamer1.0-tools
sudo apt-get install gstreamer1.0-x
sudo apt-get install gstreamer1.0-alsa
sudo apt-get install gstreamer1.0-gl
sudo apt-get install gstreamer1.0-gtk3
sudo apt-get install gstreamer1.0-qt5
sudo apt-get install gstreamer1.0-pulseaudio

還需另外安裝
sudo apt-get install libgstreamer1.0-dev
sudo apt-get install libgstreamer-plugins-base1.0-dev
sudo apt-get install libgtk2.0-dev
sudo apt-get install clutter-gst-3.0
sudo apt-get install libclutter-gst-3.0-0
sudo apt-get install libclutter-gst-3.0-dev

下載教學範例
git clone https://gitlab.freedesktop.org/gstreamer/gst-docs

Makefile 中
PKGS := gstreamer-1.0 gtk+-2.0 clutter-gst-3.0
CFLAGS += `pkg-config --cflags $(PKGS)`
LIBS += `pkg-config --libs $(PKGS)`

$(MAKECMDGOALS).o: $(MAKECMDGOALS).c Makefile
$(CC) -c -o $@ $(CFLAGS) $<

$(MAKECMDGOALS): $(MAKECMDGOALS).o Makefile
$(CC) -o $@ $@.o $(LIBS)

2020年5月27日 星期三

Connect Raspberry PI and Wii

以下以適用 Jetson Nano

搖桿, Gamepad, Joysticks
參考 Wiimote Controller Configuration for Raspberry Pi 2/3
參考 How to Connect Wiimotes to the Raspberry Pi
參考 wminput.list
參考 action_enum.txt
參考 pd-l2ork cwiid

$ cat mywminput
# Classic-Controller
#Classic.Dpad.X = ABS_X
#Classic.Dpad.Y = ABS_Y
#Classic.LStick.X = ABS_HAT0X
#Classic.LStick.Y = ABS_HAT0Y
#Classic.RStick.X = ABS_HAT1X
#Classic.RStick.Y = ABS_HAT1Y
Classic.A = BTN_A
Classic.B = BTN_B
Classic.X = BTN_X
Classic.Y = BTN_Y
Classic.Minus = BTN_SELECT
Classic.Plus  = BTN_START
Classic.Home  = BTN_MODE
Classic.L  = BTN_TL
Classic.R  = BTN_TR
Classic.ZL = BTN_TL2
Classic.ZR = BTN_TR2

# WiiMote
Wiimote.A = BTN_A
Wiimote.B  = BTN_B
Wiimote.Dpad.X = ABS_HAT0X
Wiimote.Dpad.Y = -ABS_HAT0Y
Wiimote.Minus = BTN_SELECT
Wiimote.Plus = BTN_START
Wiimote.Home = BTN_MODE
Wiimote.1 = BTN_X
Wiimote.2 = BTN_Y

# Nunchuk
Nunchuk.C = BTN_C
Nunchuk.Z = BTN_Z
Nunchuk.Stick.X = ABS_RX
Nunchuk.Stick.Y = -ABS_RY

Plugin.led.Led1 = 1
#Plugin.led.Led2 = 1
#Plugin.led.Led3 = 1
#Plugin.led.Led4 = 1

Plugin.ir_ptr.X = ABS_HAT1X
Plugin.ir_ptr.Y = ABS_HAT1Y

Plugin.acc.X = ABS_X
Plugin.acc.Y = ABS_Y
#Plugin.acc.Z = ABS_Z


$ cat connectwii.sh

#!/bin/bash
sleep 1 # Wait until Bluetooth services are fully initialized
hcitool dev | grep hci >/dev/null
if test $? -eq 0 ; then
    wminput -d -c  /home/pi/mywminput 00:1A:E9:EB:07:2A &
else
    echo "Blue-tooth adapter not present!"
    exit 1
fi

同時按下1,2 並放開
$ sudo ./connectwiimote.sh
$ sudo apt-get install jstest-gtk
$ jstest-gtk
$ ps -efa | grep wminput
$ sudo kill -9 pid


使用 python 控制
參考 Raspberry Pi 4 bluetooth scale
參考 wiiweigh
參考 xwiimote

export PYTHONPATH=/usr/lib/python2.7/site-packages
sudo visudo
Defaults env_keep += "PYTHONPATH"
加入上一行

同時按下1,2 並放開
$ bluetoothctl
[bluetooth]# connect 00:1A:E9:EB:07:2A
[bluetooth]# exit
$ xwiishow list
Listing connected Wii Remote devices:
  Found device #1: /sys/devices/platform/soc/fe201000.serial/tty/ttyAMA0/hci0/hci0:12/0005:057E:0306.0004
End of device list
$ xwiishow 1
$ bluetoothctl
[bluetooth]# disconnect 00:1A:E9:EB:07:2A
[bluetooth]# exit
$ cd src/xwiimote-bindings/examples/python
$ sudo python xwiimote_test.py

可以加入下列程式
        elif evt.type == xwiimote.EVENT_NUNCHUK_KEY:
            code, state = evt.get_key()
            print "Nunchuk Key:", code, ", State:", state
        elif evt.type == xwiimote.EVENT_NUNCHUK_MOVE:
            x, y, z = evt.get_abs(0)
            #print "Nunchuk controller move 1:", x, y
        elif evt.type == xwiimote.EVENT_ACCEL:
            x, y, z = evt.get_abs(0)
            #print "Accelerometer move 1:", x, y, z


Wii Balance Board
參考 chaosbiber / wiiweigh
參考 Raspberry Pi Smart Scale
參考 Disassembling Wii Balance Board
參考 Wii Balance Board Smart Scale ( w/ ESP32 )

HX711接腳
青-E+
綠-E-
紅-A-
白-A+

雙黑 開關
LED 白P 青N

2020年5月18日 星期一

備份

顯示硬碟掛載狀況
# df -h

分割硬碟,若硬碟超過2TB, 就無法使用 fdisk, 改用 parted
# fdisk -l
# fdisk -l /dev/sda
parted 似乎比較好用

格式化
# mkfs.ext4 /dev/sda1

若格式化出現
warn: had trouble writing out superblocks
# mkfs.ext4 -S /dev/sda1

掛載硬碟
# mkdir /mnt/backup
# mount /dev/sda1 /mnt/backup

檢查及修復檔案系統
# esfsck -a /dev/sda1

備份
# rsync -av /mnt/source /mnt/destination
備份 頻寬限制 1000KB/s
# rsync -av --bwlimit=1000 /mnt/source /mnt/destination

測試 SD Card 速度

釋放Linux記憶體
# echo 1 > /proc/sys/vm/drop_caches
釋放dentries、inodes所用的 cache memory。
# echo 2 > /proc/sys/vm/drop_caches
釋放pagecache、dentry、inode 所用的 cache memory。
# echo 3 > /proc/sys/vm/drop_caches
完全釋放cache memory,必須先執行sync,避免錯誤。
# sync

Write speed
# sync; time dd if=/dev/zero of=~/test.tmp bs=500K count=1024
Read speed
# sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
# sync; time dd if=~/test.tmp of=/dev/null bs=500K count=1024

SanDisk microSDHC 32GB Extreme U3 90MB/s
Arduino 寫速度測試
root@arduino:/mnt/sda1# sync; time dd if=/dev/zero of=test.tmp bs=500K count=1024
1024+0 records in
1024+0 records out
real    2m 25.16s
user    0m 0.04s
sys     0m 20.11s
Arduino 讀速度測試
root@arduino:/mnt/sda1# sync; echo 3|tee /proc/sys/vm/drop_caches
3
root@arduino:/mnt/sda1# sync; time dd if=test.tmp of=/dev/null bs=500k count=1024
1024+0 records in
1024+0 records out
real    0m 30.68s
user    0m 0.00s
sys     0m 8.86s
root@arduino:/mnt/sda1# uname -a
Linux arduino 3.3.8 #1 Thu Jun 2 12:28:33 CEST 2016 mips GNU/Linux
root@arduino:/mnt/sda1#
Arduino 拍照測試(不下載)
root@arduino:/# time gphoto2 --port usb:001,003 --capture-image
New file is in location /capt0000.jpg on the camera
real    0m 4.92s
user    0m 1.74s
sys     0m 0.36s
Arduino 拍照測試,下載到 Flash
root@arduino:/# time gphoto2 --port usb:001,003 --capture-image-and-download --no-keep
New file is in location /capt0000.jpg on the camera
Saving file as capt0000.jpg
Deleting file /capt0000.jpg on the camera
Deleting 'capt0000.jpg' from folder '/'...
real    0m 22.88s
user    0m 1.23s
sys     0m 8.77s
root@arduino:/#
Arduino 拍照測試,下載到 SD Card
root@arduino:/mnt/sda1# time gphoto2 --port usb:001,003 --capture-image-and-down
load --no-keep
New file is in location /capt0000.jpg on the camera
Saving file as capt0000.jpg
Deleting file /capt0000.jpg on the camera
Deleting 'capt0000.jpg' from folder '/'...
real    0m 6.53s
user    0m 1.81s
sys     0m 0.58s
root@arduino:/mnt/sda1#
RaspberryPi 寫速度測試
pi@raspberrypi:~ $ sync; echo 3| sudo tee /proc/sys/vm/drop_caches
3
pi@raspberrypi:~ $ sync; time dd if=/dev/zero of=test.tmp bs=500k count=1024
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 27.8328 s, 18.8 MB/s

real 0m27.847s
user 0m0.020s
sys 0m3.360s
RaspberryPi 讀速度測試
pi@raspberrypi:~ $ sync; echo 3| sudo tee /proc/sys/vm/drop_caches
3
pi@raspberrypi:~ $ sync; time dd if=test.tmp of=/dev/null bs=500k count=1024
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 22.8695 s, 22.9 MB/s

real 0m22.877s
user 0m0.050s
sys 0m1.340s
pi@raspberrypi:~ $ 
RaspberryPi 拍照測試(不下載)
pi@raspberrypi:~ $ time gphoto2 --port usb:001,004 --capture-image
New file is in location /capt0000.jpg on the camera                            

real 0m3.011s
user 0m0.150s
sys 0m0.100s
RaspberryPi 拍照測試(下載)
pi@raspberrypi:~ $ time gphoto2 --port usb:001,004 --capture-image-and-download --no-keep
New file is in location /capt0000.jpg on the camera                            
Saving file as capt0000.jpg
Deleting file /capt0000.jpg on the camera
Deleting 'capt0000.jpg' from folder '/'...

real 0m3.037s
user 0m0.140s
sys 0m0.140s
pi@raspberrypi:~ $ 


SanDisk ExtremePRO microSDHC UHS-I(V30) 32GB
Arduino 寫速度測試
root@arduino:/mnt/sda1# sync; time dd if=/dev/zero of=test.tmp bs=500K count=1024
1024+0 records in
1024+0 records out
real    2m 32.46s
user    0m 0.01s
sys     0m 20.18s
Arduino 讀速度測試
root@arduino:/mnt/sda1# sync; echo 3|tee /proc/sys/vm/drop_caches
3
root@arduino:/mnt/sda1# sync; time dd if=test.tmp of=/dev/null bs=500k count=1024
1024+0 records in
1024+0 records out
real    0m 30.80s
user    0m 0.00s
sys     0m 8.52s
root@arduino:/mnt/sda1#
Arduino 拍照測試(不下載)
root@arduino:/# time gphoto2 --port usb:001,003 --capture-image
New file is in location /capt0000.jpg on the camera
real    0m 4.92s
user    0m 1.74s
sys     0m 0.45s
Arduino 拍照測試,下載到 Flash
root@arduino:/# time gphoto2 --port usb:001,003 --capture-image-and-download --no-keep
New file is in location /capt0000.jpg on the camera
Saving file as capt0000.jpg
Deleting file /capt0000.jpg on the camera
Deleting 'capt0000.jpg' from folder '/'...
real    0m 22.96s
user    0m 1.19s
sys     0m 9.09s
root@arduino:/#
Arduino 拍照測試,下載到 SD Card
root@arduino:/mnt/sda1# time gphoto2 --port usb:001,003 --capture-image-and-download --no-keep
New file is in location /capt0000.jpg on the camera
Saving file as capt0000.jpg
Deleting file /capt0000.jpg on the camera
Deleting 'capt0000.jpg' from folder '/'...
real    0m 5.89s
user    0m 1.80s
sys     0m 0.45s
root@arduino:/mnt/sda1#


RaspberryPi 寫速度測試
pi@raspberrypi:~ $ sync; echo 3| sudo tee /proc/sys/vm/drop_caches
3
pi@raspberrypi:~ $ sync; time dd if=/dev/zero of=test.tmp bs=500k count=1024
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 27.6452 s, 19.0 MB/s

real 0m27.657s
user 0m0.000s
sys 0m4.020s
RaspberryPi 讀速度測試
pi@raspberrypi:~ $ sync; echo 3| sudo tee /proc/sys/vm/drop_caches
3
pi@raspberrypi:~ $ sync; time dd if=test.tmp of=/dev/null bs=500k count=1024
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 23.0098 s, 22.8 MB/s

real 0m23.020s
user 0m0.000s
sys 0m1.610s
pi@raspberrypi:~ $ 
RaspberryPi 拍照測試(不下載)
pi@raspberrypi:~ $ time gphoto2 --port usb:001,004 --capture-image
New file is in location /capt0000.jpg on the camera                          

real 0m3.053s
user 0m0.160s
sys 0m0.140s
RaspberryPi 拍照測試(下載)
pi@raspberrypi:~ $ time gphoto2 --port usb:001,004 --capture-image-and-download --no-keep
New file is in location /capt0000.jpg on the camera                          
Saving file as capt0000.jpg
Deleting file /capt0000.jpg on the camera
Deleting 'capt0000.jpg' from folder '/'...

real 0m2.994s
user 0m0.170s
sys 0m0.070s
pi@raspberrypi:~ $ 

2019年12月15日 星期日

Ubuntu 建立桌面捷徑 和 桌面啟動時自動執行

建立桌面捷徑
sudo apt-get install --no-install-recommends gnome-panel
gnome-desktop-item-edit ~/Desktop/ --create-new


桌面啟動時自動執行
開始/Startup Applications/Add

(sleep 10; shellcommand.sh)&

2019年9月8日 星期日

Ubuntu 設定預設聲音輸出


vidia@nvidia-desktop:~$ pactl list short
sources 0 alsa_output.platform-3510000.hda.hdmi-stereo-extra2.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 
1 alsa_output.platform-sound.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz SUSPENDED 
2 alsa_input.platform-sound.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED

nvidia@nvidia-desktop:~$ sudo vi /etc/pulse/default.pa  
### Make some devices default 
#set-default-sink output 
set-default-sink 0 
#set-default-source input

nvidia@nvidia-desktop:~$ pacmd list-sinks
2 sink(s) available.
  * index: 0
name: <alsa_output.platform-3510000.hda.hdmi-stereo-extra2>
driver: <module-alsa-card.c>
    index: 1
name: <alsa_output.platform-sound.analog-stereo>
driver: <module-alsa-card.c>

nvidia@nvidia-desktop:~$ pacmd set-default-sink 1
nvidia@nvidia-desktop:~$ pacmd set-default-sink 0


2019年8月27日 星期二

nethogs
Monitor Per Process Network Bandwidth Usage in Real Time

iotop
simple top-like I/O monitor

2019年7月27日 星期六

apt-get

sudo apt-get install chromium-browser-l10n
chromium-browser
chromium-codecs-ffmpeg-extra
unity-scope-chromiumbookmarks
apt list --installed
sudo apt-get remove chromium-browser
apt-cache madison chromium-browser
sudo apt-get install chromium-browser=75.0.3770.90-0ubuntu0.18.04.1


2019年6月24日 星期一

Ubuntu 鍵盤 滑鼠大小設定

因為買了 Mircosoft 的小鍵盤,在鍵盤上找不到 Home End 和 PtrSc 鍵

修改功能鍵
System Settings/Keyboard/Shortcuts

還原方法
執行 dconf Editor
/org/gnome/settings-deamon/plugins/media-keys
點選修改過的功能
按下 Use default value

但是最後發現
Home = Ctrl + ← 或  Fn + ←
End = Ctrl + → 或 Fn + →
Print Screen (full screen): Fn + Windows Key + Space
Print Screen (current window) :Fn + Alt + Space


設定滑鼠大小
$ gsettings get org.gnome.desktop.interface cursor-size
24
$ gsettings set org.gnome.desktop.interface cursor-size 48
重新開機

nvidia@jetson-0423418048807:~$ cat cursor.sh
(sleep 10; gsettings set org.gnome.desktop.interface cursor-size 48)&
nvidia@jetson-0423418048807:~$

開始/Startup Applications/Add
cursor.sh








2019年1月23日 星期三

tsseract 訓練 在 Unbuntu 上

https://github.com/tesseract-ocr/tesseract/wiki/Compiling
https://github.com/tesseract-ocr/tesseract/wiki/Compiling-%E2%80%93-GitInstallation

sudo apt-get install g++
sudo apt-get install autoconf automake libtool
sudo apt-get install pkg-config
sudo apt-get install libpng-dev
sudo apt-get install libjpeg8-dev
sudo apt-get install libtiff5-dev
sudo apt-get install zlib1g-dev

sudo apt-get install libicu-dev
sudo apt-get install libpango1.0-dev
sudo apt-get install libcairo2-dev

sudo apt-get install libleptonica-dev

sudo apt install git

git clone https://github.com/tesseract-ocr/tesseract.git tesseract-ocr
git clone https://github.com/tesseract-ocr/langdata.git langdata
git clone https://github.com/tesseract-ocr/tessdata_best.git tessdata_best
git clone https://github.com/tesseract-ocr/tessdata_fast.git tessdata_fast
cd tesseract-ocr
./autogen.sh
./configure
make
sudo make install
sudo ldconfig
make training
sudo make training-install

https://github.com/tesseract-ocr/tesseract/wiki/Data-Files

sudo apt install curl
sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless
sudo apt install default-jdk
sudo apt install openjdk-11-jdk-headless
sudo apt install openjdk-8-jdk-headless

cd java
make ScrollView.jar

https://github.com/tesseract-ocr/tesseract/wiki/ViewerDebugging

text2image --find_fonts \
--fonts_dir /usr/share/fonts \
--text ./langdata/plate/plate.
--min_coverage .9  \
--outputbase ./langdata/plate/plate \
|& grep raw \
 | sed -e 's/ :.*/@ \\/g' \
 | sed -e "s/^/  '/" \
 | sed -e "s/@/'/g" >./langdata/plate/fontslist.txt

text2image --font="aakar Medium" \
--fonts_dir /usr/share/fonts \
--text ./langdata/plate/plate.txt \
--min_coverage .9  \
--outputbase ./langdata/plate/plate.aakar_Medium.exp0

text2image --font="Abyssinica SIL" \
--fonts_dir /usr/share/fonts \
--text ./langdata/plate/plate.txt \
--min_coverage .9  \
--outputbase ./langdata/plate/plate.Abyssinica_SIL.exp0

mkdir training
cd training
mkdir -p langdata/eng
準備 langdata/eng/eng.traning_text
拷貝 langdata/radical-stroke.txt
mkdir -p tessdata/configs
拷貝 tessdata/eng.traineddata
拷貝 tessdata/configs/lstm.train

~/ocr/tesseract-ocr/src/training/tesstrain.sh --fonts_dir /usr/share/fonts \
 --lang eng --linedata_only \
 --noextract_font_properties --langdata_dir langdata \
 --tessdata_dir tessdata \
 --output_dir train

若字型不存在 (Could not find font named 'xxx xxx')
編輯 src/training/language-specific.sh 刪除不存在的字型

tif 檔產生到一半停住了, 原因是利用背景處理加速
let rem=counter%par_factor 為零時出錯
修改 src/training/tesstrain_utils.sh, 不要使用背景處理
有以下兩段, 刪除命令後面的 &
phase_I_generate_image()
  generate_font_image "${font}"
phase_E_extract_features()
  run_command tesseract ${img_file} ${img_file%.*} ${box_config} ${config} &
並刪除相關的 let, if, wait

combine_tessdata -e ../tessdata_best/eng.traineddata train/eng.lstm

lstmtraining --model_output model \
 --continue_from train/eng.lstm \
 --traineddata train/eng/eng.traineddata \
 --old_traineddata ../tessdata_best/eng.traineddata \
 --train_listfile train/eng.training_files.txt \
 --max_iterations 3600

lstmtraining --stop_training \
 --continue_from model_checkpoint \
 --traineddata train/eng/eng.traineddata \
 --old_traineddata ../tessdata_best/eng.traineddata \
 --model_output new.traineddata

若要直接使用 tif 和 box
修改 src/training/tesstrain_utils.sh, 固定 tif, box 檔案的目錄
    #TRAINING_DIR=${TMP_DIR}
    TRAINING_DIR=/tmp/images
修改 src/training/tesstrain.sh, 不要自動產生圖形
#phase_I_generate_image 8

2017年4月17日 星期一

更改 arduino.local 網址

Arduino Yun ,不須設定 DNS 即可透過 arduino.local 連接上
它是透過 zeroconf  連上 arduino
目前使用 zeroconf 產品有 Apple 的 Bonjour 和 Linux 的 Avahi
Arduino Yun 就是使用 Avahi, 設定檔在 /etc/avahi/avahi-daemon.conf
其中
#host-name=foo

因為沒有設定,所以是使用主機的 host name
可以透過網頁設定

2016年8月19日 星期五

Arch Linux on EeePC 701

進入 Arch Linux 官網,選擇 HTTP 方式下載映像檔(archlinux-2016.08.01-dual.iso)
使用 Rufus 製作可開機的  USB/SD Card
連上有線網路,安裝會由網路下載資料
選擇由 SD 卡進入安裝程序

分割硬碟,因為硬碟不大,使用單一分割
# cgdisk /dev/sda
引號很重要,失敗很多次才知道
# mkfs.ext4 -O "^64bit" /dev/sda1
# mount /dev/sda1 /mnt
 將台灣的伺服器移到前面
vi /etc/pacman.d/mirrorlist
## Taiwan
Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
Server = http://shadow.ind.ntou.edu.tw/archlinux/$repo/os/$arch
Server = http://ftp.tku.edu.tw/Linux/ArchLinux/$repo/os/$arch
Server = http://ftp.yzu.edu.tw/Linux/archlinux/$repo/os/$arch
# pacstrap /mnt base
# genfstab -p -U /mnt >> /mnt/etc/fstab
# arch-chroot /mnt
# passwd
# echo ArchLinux > /etc/hostname
開啟 DHCP service
# systemctl enable dhcpcd@enp3s0.service
# vi /etc/locale.gen
解開下列3項
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
zh_TW.UTF-8 UTF-8
# locale-gen
# ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime
# date
開機程序有一些不同的選擇,我後來使用 syslinux,另外有 GRUB, LILO 等
# mkinitcpio -p linux
# pacman -S gptfdisk
# pacman -S syslinux
# syslinux-install_update -i -a -m
# vi /boot/syslinux/syslinux.cfg
改 APPEND root=/dev/sda3 rw
為 APPEND root=/dev/sda1 rw
# exit
# umount /mnt
# reboot

login by root若之前已經開啟 DHCP Service,就不需執行下列命令
# dhcpcd enp3s0

安裝觸控板# pacman -S xf86-input-synaptics

安裝音效
# pacman -S alsa-utils
# alsamixer
# aplay /usr/share/sounds/alsa/Front_Center.wav
# arecord -d 5 test-mic.wav
# aplay test-mic.wav

安裝顯示卡驅動
# pacman -S xf86-video-intel

安裝圖形介面 Openbox, LXDM, Tint2
# pacman -S wget
# pacman -S sudo
# wget http://web.dhjh.tc.edu.tw/~gzqbyr/obtint.zip
# pacman -S unzip
# unzip obtint.zip
vi ./botint
在執行 obtint 前,將 firefox 改成 chromium
# ./obtint

設定 NumLock# vi /etc/lxdm/lxdm.conf
numlock=0

安裝 Mount 工具# pacman -S udevil

安裝 firefox 之 flash (安裝 chrome 之 flash 會移除這個 plugin)
# pacman -S flashplugin

安裝 chrome,若以利用 obtint 安裝過,不須執行下列命令# pacman -S chromium
安裝 chrome 之 flash
# pacman -S binutils
# pacman -S fakeroot
https://aur.archlinux.org/packages/adobe-flashplugin/
下載 adobe-flashplugin.tar.gz
$ tar xvfz adobe-flashplugin.tar.gz
$ cd adobe-flashplugin
$ makepkg -s
# pacman -U adobe-flashplugin-22.0.0.192-1-i686.pkg.tar.xz
重開機後使用 chrome 開啟 chrome://plugins 使用 Adobe Flash Player

設定 x-win 之 Menu/Browser
# vi ~/.config/openbox/menu.xml 改
<item label="Browser"><action name="Execute">
<execute>chromium -disk-cache-dir="/tmp"</execute>
</action></item>
設定 x-win 之 shortcut key
# vi ~/.config/openbox/rc.xml 改
<keybind key="W-w">
  <action name="Execute">
    <command>chromium -disk-cache-dir="/tmp"</command>
    <startupnotify>
      <enabled>yes</enabled>
      <name>Web Browser</name>
    </startupnotify>
  <action>
</keybind>

安裝 Network Manager 圖形化網路管理
# pacman -S networkmanager
# pacman -S network-manager-applet
# pacman -S wireless_tools
# systemctl stop dhcpcd@enp3s0
# systemctl disable dhcpcd.service
# systemctl enable NetworkManager.service
# reboot

顯示電池狀態$ vi ~/.config/tint2/tint2rc
battery_hide = never

切換 consoleAlt+Fn
有 X-Win 時切換 consoleCtrl+Alt+Fn
切換中文輸入法
Ctrl+Space

螢幕解析度設定
# pacman -S xorg-xrandr
# xrandr
# xrandr --output LVDS1 --panning 800x480 --scale 1.4x1.4
# xrandr --output LVDS1 --mode 800x480 --fb 800x600 --panning 800x600
# xrandr --output LVDS1 --mode 800x480 --fb 800x600 --panning 800x600 --scale 1x1
scale 最好是 1x1,這樣才看得清楚
fb 是桌面,panning 是滑鼠座標

修改桌面資訊顯示
# vi ~/.conkyrc
${top_io name 1}${top_io io_write 1} // io 最高的 process
${top_mem name 1}${top_mem mem 1}% // 佔最多記憶體的 process

偵測 CPU溫度,風扇
# pacman -Ss lm-sensors
# pacman -Ss sensors
# pacman -S lm_sensors
# sensors-detect // 它會問你一堆問題,最好是回答預設值
# cat /etc/modules
# sensors
# vi ~/.conkyrc
override_utf8_locale yes // 沒有設定,°C前會有亂碼
CPU Temp:$alignr${execi 10 sensors | grep ^"temp1:" | awk '{print $2}'}
Fan:$alignr${execi 10 sensors | grep ^"fan1:" | awk '{print $2}'}RPM

風扇控制# sensors-detect // 會在 /etc/modules 內加入感測器模組
# pwmconfig // 會去偵測 pwm 控制器,和風扇的關係,並產生 /etc/fancontrol
模組的位置
/sys/class/hwmon/hwmon?/device 主裝置,如CPU,主機板,顯卡等
/sys/class/hwmon/hwmon?/device/pwm? 裝置內可用 pwm
/sys/class/hwmon/hwmon?/device/fan?_input 裝置內可用風扇
/etc/fancontrol 說明
FCTEMPS=hwmon0/device/pwm1=hwmon0/device/temp1_input // PWM 裝置對映到的溫度感測器
FCFANS=hwmon0/device/pwm1=hwmon0/device/fan1_input // PWM 裝置對映到的風扇轉速計
MINTEMP 低於此溫度,風扇使用最小速度轉動
MAXTEMP 高於此溫度,風扇使用最高速度轉動
MINSTART 高於此 PWM,風扇開始轉動,通常大於 MINSTOP
MINSTOP 低於此 PWM,風扇停止轉動
MINPWM 當溫度低於 MINTEMP,使用此 PWM 轉動
MAXPWM 當溫度高於 MAXTEMP,使用此 PWM 轉動
# systemctl enable fancontrol.service
原本由 pwmconfig 產生的 fancontrol 是可以運作
但偶而會因為開機模組載入次序產生問題
# systemctl status fancontrol.service
所以改用下列設定檔
# vi /etc/fancontrol
# Configuration file generated by pwmconfig, changes will be lost
INTERVAL=10
FCTEMPS= /sys/devices/platform/eeepc/hwmon/hwmon[[:print:]]*/pwm1=/sys/devices/virtual/hwmon/hwmon[[:print:]]*/temp1_input
FCFANS= /sys/devices/platform/eeepc/hwmon/hwmon[[:print:]]*/pwm1=/sys/devices/platform/eeepc/hwmon/hwmon[[:print:]]*/fan1_input
MINTEMP= /sys/devices/platform/eeepc/hwmon/hwmon[[:print:]]*/pwm1=30
MAXTEMP= /sys/devices/platform/eeepc/hwmon/hwmon[[:print:]]*/pwm1=55
MINSTART= /sys/devices/platform/eeepc/hwmon/hwmon[[:print:]]*/pwm1=150
MINSTOP= /sys/devices/platform/eeepc/hwmon/hwmon[[:print:]]*/pwm1=100
MINPWM= /sys/devices/platform/eeepc/hwmon/hwmon[[:print:]]*/pwm1=100
MAXPWM= /sys/devices/platform/eeepc/hwmon/hwmon[[:print:]]*/pwm1=255

解決開機時沒插網路線,等待 1min 34s
# systemctl status dhcpcd@enp3s0.service // 錯誤訊息
# systemd-analyze critical-chain // 開機載入模組的相依
若開機時有使用 enable dhcpcd@enp3s0.service
# vi /etc/systemd/system/dhcpcd@.service.d/timeout.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dhcpcd -w -q -t 10 %I
若開機時使用 systemctl enable NetworkManager.service
# vi /usr/lib/systemd/system/dhcpcd@.service
ExecStart=/usr/bin/dhcpcd -w -q -t 10 %I

使用 ramdisk
# findmnt --target /tmp // 查詢 /tmp 的實體位置
手動加入 ramdisk
# mkdir /tmp
# chmod 777 /tmp
# mount -t tmpfs -o size=1G tmpfs /tmp // 使用 1G 的記憶體
開機時自動加入 ramdisk
# vi /etc/fstab // add a line
tmpfs /tmp tmpfs size=1G, mode=1777 0 0
chrome 使用 ramdisk
$ chromium --disk-cache-dir="/tmp/chrome"
# vi /usr/share/applications/chromium.desktop
Exec=/usr/bin/chromium -disk-cache-dir="/tmp/chrome" %U


下面是安裝時所遇到的一些困難過程

安裝 SD 開機時顯示
:: mounting '/dev/disk/by-label/ARCH_201608' to '/run/archiso/bootmnt'
Waiting 30 seconds for device /dev/disk/by-label/ARCH_201608 ...
ERROR '/dev/disk/by-label/ARCH_201608' device did not show up after 30 seconds...
You can try to fix the problem manually, log out when you are finished
我使用下列命令去修正它,但後來幾次就沒遇到,懷疑是接上有線網路,一切皆會順暢
ln -s /dev/sdb1 /dev/disk/by-label/ARCH_201608
mount /dev/sdb1 /run/archiso/bootmnt
rm /dev/disk/by-label/ARCH_201608
exit

使用 cgdisk 不用選擇開機磁區,試過下列命令
lsblk // 列出可用的儲存裝置
cgdisk /dev/sda
cfdisk /dev/sda
fdisk
spfdisk
parted /dev/sda print
parted /dev/sda set 1 bios_grub on
parted /dev/sda set 1 legacy_boot on
parted /dev/sda set 1 boot on
mkfs.ext4 /dev/sda1
mkfs.ext4 -O "^64bit" /dev/sda1
mkfs.ext4 -O "^has_journal" /dev/sda1

安裝網路時,試過下列命令
lspci -v // 查詢 PCI 裝置
Kernel moudles: ath5k
Kernel moudles: atl2
dmesg | grep ath5k // 在開機訊息中尋找,網路裝置名稱
ip link
iw dev
iw dev wlp1s0 link
ip link set wlp1s0 up
ip link show wlp1s0
iw dev wlp1s0 scan
iw dev wlp1s0 connect "your_essid"
iw dev wlp1s0 link
ip addr add 192.168.1.73/24 dev wlp1s0
ip route add default via 192.168.1.1
dhcpcd enp3s0
ping 192.168.1.1
vi /etc/resolv.conf // 設定 DNS
nameserver 192.168.1.1
ping www.google.com

設定安裝時,網路下載不穩定
vi /etc/pacman.conf // 使用 wget 下載,但使用有線網路時,一切順暢,不需要
#XferCommand /usr/bin/wget --passive-ftp -c -O %o %u

開機程序有一些不同的選擇,我後來使用 syslinux

查詢磁碟分割是否對齊,對齊返回0
# blockdev --getalignoff /dev/sda1
使用 TRIM 指令,加入 discard 旗標
取消檔案 atime 的修改,加入 noatime 旗標
vi /etc/fstab
/dev/sda1 / ext4 defaults,noatime,discard 0 1
I/O Scheduler 使用 NOOP
cat /sys/block/sda/queue/scheduler
noop deadline [cfq]
# vi /boot/syslinux/syslinux.cfg
APPEND root=/dev/sda1 elevator=noop
關閉 journal
tune2fs -O "^has_journal" /dev/sda1
查詢寫入最多的 process
iotop -oPa

2016年2月16日 星期二

apt 指令

apt-get update
軟體資料庫同步:apt-get update 會根據 /etc/apt/sources.list 中設定到 APT Server 去更新軟體資料庫,在任何更新之前最好都先做這一個動作,讓軟體資料保持在最新的狀況之下。/etc/apt/sources.list 可以用 apt-setup 來設定。

apt-get install
軟體安裝:安裝軟體最怕的就是軟體間的相依、相斥關係,但是在 Debian 裡頭安裝軟體是一件非常愉悅的事情,只要 『 apt-get install 』一行指令簡簡單單輕輕鬆鬆即可完成,所有相依、相斥 Debian 都會幫我們自動解決,您只要回答 『 Y 』就可以。依照預設值,透過 sudo apt-get install 安裝軟體時,會將檔案暫存在 /var/cache/apt/archives/ 目錄裡

apt-get install vsftpd=2.3.5-3ubuntu1
安裝指定版本

apt-cache showpkg
顯示套件資訊

apt-cache pkgnames
查詢所有可安裝的軟件包

apt-cache pkgnames mingw
查詢包含特定開頭名稱的軟件包

sudo apt-cache search mingw
查詢包含特定名稱的軟件包,並且簡略說明

apt-cache show gcc-mingw-w64-x86-64
顯示軟件包的詳細說明

apt-cache madison gcc-mingw-w64-x86-64
顯示軟件包的所有版本

apt-cache showpkg gcc-mingw-w64-x86-64
顯示軟件包的相依資料


2016年1月29日 星期五

unix shell command

for i in `find .. -name '*.c' -print`
> do
> echo $i
> grep "vlm_ExecuteCommand" $i
> if [ ${?} == "0" ]
> then
> read -p $i any
> fi
> done

aaa.sh >a.out 2>&1

tail -f a.out

常用 vi 命令
移動游標 h, j, k, l
輸入 i, a
連接兩行 J
刪除 dd
拷貝 yy
貼上 p
紀錄位置 ma
跳到先前紀錄的位置 `a
暫時跳到 :!sh
不存檔離開 :q!
存檔離開 :wq
自動加入內縮:set ai
取消自動加入內縮:set noai

使用UTF-8編碼,且有 BOM
~/.vimrc
set bomb
set fileencoding=utf-8