libcarema-jpegで取得した画像をX(Twitter)に日付付きでアップロードするプログラム。
以下のOS(Archive)をRaspberry Pi 4 Model Bにインストールして動作確認済。
Raspberry Pi OS (Legacy) with desktop
Release date: March 12th 2024
System: 64-bit
Kernel version: 6.1
Debian version: 11 (bullseye)
Size: 853MB
Show SHA256 file integrity hash:
Release notes
Bunが必要です。従って、32bitのOSでは動作しません。(2024/3/24現在)
以下はOSをインストールしたRaspberry Pi上での操作です。
-
カメラが使えることを確認
libcamera-hello
-
環境変数の定義
以下を埋めた
.env
ファイルをプロジェクトルートに作成// Twitter API関係 X_API_KEY= X_API_KEY_SECRET= X_ACCESS_TOKEN= X_ACCESS_TOKEN_SECRET= // 撮影画像の画素数 WIDTH= HEIGHT=
-
実行ファイルの生成
プロジェクトディレクトリ内で以下を実行
bun install bun run build
[プロジェクトルート]/build/
に実行ファイルlibcamera_to_x
が生成される -
実行
$ /PATH/TO/EXECUTABLE/FILE/libcamera_to_x
cron
を使用することで、定期実行が可能になります。
crontab -e
でエディタを開いたあと、以下のように追記してください。
この例では、毎日0時、8時、16時に実行されます。
0 0,8,16 * * * /PATH/TO/EXECUTABLE/FILE/libcamera_to_x
現在cronやsystemdからの実行でのみエラーが発生していることを確認しています。
タスクランナーから起動するときは、実行ファイルでなくbun run
コマンドから起動してください。
0 0,8,16 * * * /PATH/TO/BUN/DIR/bun run /PATH/TO/PROJECT/ROOT/index.ts
cronの詳細についてはこちらを参照してください。