Raspberry Pi 4 便利な機能の導入メモ:AFP/Samba、イヤホン、スクショ、exFAT対応
こんにちはAxifofです。Raspberry Pi 4B (raspi) はにあると便利だな、設定できていると便利だなと私が感じたもののインストールの仕方を書いておきます。ファイル共有システム netatalk、イヤホンジャックの利用設定、scrot でスクショの撮影、exFAT フォーマット HDD への対応を書きました。
この記事は 2020/07/27 のものです。
[目次]
環境等
raspi4
pi@raspberrypi:~ $ lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 10 (buster) Release: 10 Codename: buster pi@raspberrypi:~ $ uname -a Linuc raspberrypi 4.19.118-v71+ ~(略) pi@raspberrypi:~ $ cat /proc/cpuinfo ~ (略) Model: Raspberry Pi 4 model B Rev 1.4
何もインストールしていません。クリーンインストール直後の Raspbian buster です。
netatalk で Mac とファイル共有
Mac と UNIX/Linux 系 OS は afp 通信*1によってファイル共有をすることができます。便利極まりないので入れておいて損はないと思います( samba*2 と似たようなことができると思ってください)。
## on Raspbian buster $ sudo apt install netatalk $ sudo nano /etc/netatalk/afp.conf ... [Homes] basedir regex = /home ... $ ifconfig ... eth0: inet XXX.XXX.XX.XX ... ...
## on Raspbian buster 2回目以降の起動 $ sudo systemctl start netatalk ## Netatalk の再起動 $ sudo systemctl restart netatalk
## on Mac OS X Catalina 10.15 1. Finder 2. 「移動」タブ 3. 「サーバへ接続... ⌘K」 4. Raspberry Pi の IP アドレスの入力(XXX.XXX.XX.XX) 5. 名前:raspi の名前、パスワード:raspi のパスワード 6. 接続
注意
$ sudo apt-get install -y netatalk
netatalk のインストールです*3。netatalkはインストールした初期状態のままでは、Mac からのアクセスを拒否してしまいます(エラーが出ているようです)。/etc/netatalk/afp.conf
を編集することで解決可能です;
$ sudo nano /etc/netatalk/afp.conf
[Homes]
の部分を
... [Homes] basedir regex = /home ...
のように編集します。私の環境では
変更前 | 変更後 |
; [Homes] ; basedir regex = / |
[Homes] basedir regex = /home |
でした。
調べたところ、 netatalk 3.X 系はこの設定が必須みたいです。普通に導入する分には 3.X 系になるので編集必須ですね。あとは Mac の「移動(Go)」タブから「サーバへ接続...」で raspi のIPアドレスを入力し、raspi のユーザーネームとパスワードを入力すればアクセス可能です。楽ですねええ...
nano エディタ
今回のafp.conf
の編集は、管理者権限でしか編集ができないので、nano を使って編集しました。私は CUI エディタに慣れていないので編集の仕方を調べたんですが、一応載せておきます;
- ファイルの編集
- 普通に操作すればok (Backspace や Enter など)
- ファイルの保存
- 以下の順で入力する;
Ctrl + x
y
return
イヤホンジャックから音を出力させる
おそらくですが、raspi はデフォルトでイヤホンから音声を出力しないので、普通にイヤホンを接続しても音が鳴りません。
## on Raspbian buster $ sudo raspi-config
から
1. 7 Advanced Options 2. A4 Audio 3. 1 headphone
で音声のイヤホン出力可能です。HDMI出力は私はしないのでよくわかりませんが、その場合はAudio configuration - Raspberry Pi Documentationを参照すれば良さそうです。
scrot でスクリーンショットを取得する
$ sudo apt install -y scrot
で scrot を導入します。基本的には、
$ scrot -sb
で選択ウィンドウ(厳密には違う)のスクリーンショットを取得可能です。厳密には、指定したウィンドウの位置の画面のピクセルを読み取っているだけなので、システムがウィンドウのフォーカスが切り替わる前に画像を取得してしまい、画像に重なったウィンドウが入り込む場合があります(処理時間がかからない時は、ウィンドウフォーカスが外れる前に収録されてしまう)。
各コマンドについては下のような感じです。
pi@raspberrypi:~ $ scrot -h Usage : scrot [OPTIONS]... [FILE] Where FILE is the target file for the screenshot. If FILE is not specified, a date-stamped file will be dropped in the current directory. See man scrot for more details -h, --help display this help and exit -v, --version output version information and exit -a, --autoselect non-interactively choose a rectangle of x,y,w,h -b, --border When selecting a window, grab wm border too -c, --count show a countdown before taking the shot -d, --delay NUM wait NUM seconds before taking a shot -e, --exec APP run APP on the resulting screenshot -q, --quality NUM Image quality (1-100) high value means high size, low compression. Default: 75. For lossless compression formats, like png, low quality means high compression. -m, --multidisp For multiple heads, grab shot from each and join them together. -s, --select interactively choose a window or rectangle with the mouse -u, --focused use the currently focused window -t, --thumb NUM generate thumbnail too. NUM is the percentage of the original size for the thumbnail to be, or the geometry in percent, e.g. 50x60 or 80x20. -z, --silent Prevent beeping SPECIAL STRINGS Both the --exec and filename parameters can take format specifiers that are expanded by scrot when encountered. There are two types of format specifier. Characters preceded by a '%' are interpreted by strftime(2). See man strftime for examples. These options may be used to refer to the current date and time. The second kind are internal to scrot and are prefixed by '$' The following specifiers are recognised: $f image path/filename (ignored when used in the filename) $m thumbnail path/filename $n image name (ignored when used in the filename) $s image size (bytes) (ignored when used in the filename) $p image pixel size $w image width $h image height $t image format $$ prints a literal '$' \n prints a newline (ignored when used in the filename) Example: scrot '%Y-%m-%d_$wx$h_scrot.png' -e 'mv $f ~/images/shots/' Creates a file called something like 2000-10-30_2560x1024_scrot.png and moves it to your images directory. This program is free software see the file COPYING for licensing info. Copyright Tom Gilbert 2000 Email bugs to <scrot_sucks@linuxbrit.co.uk>