Debian – matoken's blog https://matoken.org/blog Is there no plan B? Tue, 30 Dec 2025 22:45:10 +0000 ja hourly 1 https://wordpress.org/?v=6.9 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg Debian – matoken's blog https://matoken.org/blog 32 32 Cloudflareの速度テストをTUIで https://matoken.org/blog/2025/12/31/cloudflare-speed-test-with-tui/ https://matoken.org/blog/2025/12/31/cloudflare-speed-test-with-tui/#respond Tue, 30 Dec 2025 22:45:08 +0000 https://matoken.org/blog/?p=5121

Cloudflare の速度計測サイトのspeed.cloudflare.com をTUI で計測できるcloudflare-speed-cli というものを知ったので試してみました.
cloudflare-speed-cli はRust 製でGPL-3.0 license です.

類似のもので,speedtest.net を計測できるspeedtest-cli をよく使っていますが,Cloudflare も使えると便利そうです.

cloudflare-speed-cli はGitHub Releases にはLinux x86_64, aarch64, macOS aarch64, x86_64, Windows x86_64 のバイナリがあります.しかし例によってRaspberry Pi bookworm armhf(Arm 32bit)でも試してみます.

Rust 関連はasciimena 3.0 をbuild したときに入れたものからrustup で1.92.0 にしたものを使います.

cargo install で時間が掛かりますが特につまづいたりせずbuild できました.

$ cargo --version
warning: `/home/matoken/.cargo/config` is deprecated in favor of `config.toml`
  |
  = help: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
cargo 1.92.0 (344c4567c 2025-10-21)
$ cargo install --git https://github.com/kavehtehrani/cloudflare-speed-cli --features tui
$ cloudflare-speed-cli --help
Cloudflare-based speed test with optional TUI

Usage: cloudflare-speed-cli [OPTIONS]

Options:
      --base-url <BASE_URL>
          Base URL for the Cloudflare speed test service [default: https://speed.cloudflare.com]
      --json
          Print JSON result and exit (no TUI)
      --text
          Print text summary and exit (no TUI)
      --download-duration <DOWNLOAD_DURATION>
          Download phase duration [default: 10s]
      --upload-duration <UPLOAD_DURATION>
          Upload phase duration [default: 10s]
      --idle-latency-duration <IDLE_LATENCY_DURATION>
          Idle latency probe duration (pre-test) [default: 2s]
      --concurrency <CONCURRENCY>
          Concurrency for download/upload workers [default: 6]
      --download-bytes-per-req <DOWNLOAD_BYTES_PER_REQ>
          Bytes per download request [default: 10000000]
      --upload-bytes-per-req <UPLOAD_BYTES_PER_REQ>
          Bytes per upload request [default: 5000000]
      --probe-interval-ms <PROBE_INTERVAL_MS>
          Probe interval in milliseconds [default: 250]
      --probe-timeout-ms <PROBE_TIMEOUT_MS>
          Probe timeout in milliseconds [default: 800]
      --experimental
          Enable experimental features (TURN fetch + UDP-like loss probe)
      --export-json <EXPORT_JSON>
          Export results as JSON
      --export-csv <EXPORT_CSV>
          Export results as CSV
      --auto-save <AUTO_SAVE>
          Use --auto-save true or --auto-save false to override (default: true) [default: true] [possible values: true, false]
      --interface <INTERFACE>
          Bind to a specific network interface (e.g., ens18, eth0)
      --source <SOURCE>
          Bind to a specific source IP address (e.g., 192.168.10.0)
      --certificate <CERTIFICATE>
          Path to a custom TLS certificate file (PEM or DER format)
  -h, --help
          Print help
  -V, --version
          Print version
$ cloudflare-speed-cli --version
cloudflare-speed-cli 0.3.1

早速試してみます.cloudflare-speed-cli をオプションなしで実行するとTUI で実行されます.起動してすぐに計測が始まり,既定値では計測結果が保存されます.tab key でHistory ページに遷移すると過去の計測結果を閲覧したりエクスポートしたりできます.

cloudflare speed cli TUI

--text オプションでcli モードですが,プログレスが大量に出てちょっと使いづらい感じです.

プロスレス部分はSTDERR なのでそれを捨ててしまってもいいかもしれません

$ cloudflare-speed-cli --text 2>/dev/null
IP/Colo/ASN: 133.106.160.49 / NRT / 138384 (-)
Download: 23.73 Mbps
Upload:   2.47 Mbps
Idle latency p50/p90/p99: 98.9/110.7/110.7 ms (loss 0.0%, jitter 10.2 ms)
Loaded latency (download) p50/p90/p99: 438.0/578.6/755.2 ms (loss 0.0%, jitter 130.1 ms)
Loaded latency (upload) p50/p90/p99: 654.8/794.1/794.1 ms (loss 45.5%, jitter 144.4 ms)

こんな感じで定期的に計測するのにも便利かもと思いましたが,cli モードでは既定値では結果を保存しないようです.

$ watch -n 3600 -- cloudflare-speed-cli --text

--auto-save true も追加すると結果が保存されます.

$ watch -n 3600 -- cloudflare-speed-cli --text --auto-save true

ただ,以下のようにTUI モードの計測時のログには --interface を指定してもInterface やAP 名は保存されないようです.

│ 3.   2025-12-31 06:30:11 +09:00  DL   20.69 Mbps  UL    4.66 Mbps  Idle p50  103.7 ms  -  (1)
│ 4.   2025-12-31 06:08:33 +09:00  DL   21.73 Mbps  UL    3.16 Mbps  Idle p50  100.7 ms  wlan0  TP-L13💻 (2)
  1. --text でcli モードで実行したときの結果

  2. TUI モードで実行したときの結果

SEE ALSO

$ speedtest-cli
Retrieving speedtest.net configuration...
Testing from Rakuten Mobile Network (133.106.160.42)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by GSL Networks (Tokyo) [0.26 km]: 60.882 ms
Testing download speed................................................................................
Download: 12.70 Mbit/s
Testing upload speed......................................................................................................
Upload: 2.69 Mbit/s
Speedtest CLI: Internet speed test for the command line ※Ookla公式だがプロプライエタリ
$ speedtest

   Speedtest by Ookla

      Server: IPA CyberLab 400G - Tokyo (id: 48463)
         ISP: Rakuten Mobile Network
Idle Latency:    50.15 ms   (jitter: 1.41ms, low: 48.98ms, high: 52.36ms)
    Download:    20.75 Mbps (data used: 19.9 MB)
                262.40 ms   (jitter: 71.32ms, low: 72.73ms, high: 398.26ms)
      Upload:     2.96 Mbps (data used: 1.6 MB)
                779.27 ms   (jitter: 95.79ms, low: 75.05ms, high: 1148.99ms)
 Packet Loss:     0.0%
  Result URL: https://www.speedtest.net/result/c/e1a349cf-53eb-4d63-b8f4-8550dabd772d
n8henrie/fastcli: Python3 speed test via Fast.com fast.com を使いcli で計測……2025-12-27にarchived されていた
$ python -m fastcli -v
Approximate download speed: 17.48 Mbps
]]>
https://matoken.org/blog/2025/12/31/cloudflare-speed-test-with-tui/feed/ 0
プロセスの情報をわかりやすく表示してくれるwitr https://matoken.org/blog/2025/12/29/witr_-why-is-this-running/ https://matoken.org/blog/2025/12/29/witr_-why-is-this-running/#respond Mon, 29 Dec 2025 12:31:39 +0000 https://matoken.org/blog/?p=5113

witr (why-is-this-running) はプロセス名,PID,ポート番号からそれがなぜ実行されているかを調べて表示してくれます.

witr ssh

例えば以下はport 22 を調べています.sshd が実行されていることなどがわかります.

$ sudo ./witr -port 22
Target      : sshd

Process     : sshd (pid 581)
User        : root
Command     : sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
Started     : 4 days ago (Thu 2025-12-25 18:10:39 +09:00)

Why It Exists :
  systemd (pid 1)   sshd (pid 581)

Source      : systemd service (supervisor)

Working Dir : /
Listening   : 0.0.0.0:22
              :::22

Warnings    :
    Process is listening on a public interface
    Process is running as root
    Process is running from a suspicious working directory: /

メモリをたくさん使っている(1GB+)と警告が表示されたりもします

$ sudo ~/usr/local/bin/witr -pid 10522
Target      : firefox.real

Process     : firefox.real (pid 10522) [high-mem]
User        : matoken
Command     : /usr/bin/firefox.real
Started     : 2 days ago (Sat 2025-12-27 05:39:41 +09:00)

Why It Exists :
  systemd (pid 1) → firefox.real (pid 10522)

Source      : systemd service (supervisor)

Working Dir : /home/matoken

Warnings    :
  • Process is using high memory (>1GB RSS)

以下はプロセスID 524 からglance がcron から起動しているのがわかります.

$ ./witr -pid 524
Target      : glance

Process     : glance (pid 524) {forked}
User        : matoken
Command     : /home/matoken/bin/glance -config /home/matoken/.config/glance.yml
Started     : 4 days ago (Thu 2025-12-25 18:10:36 +09:00)
Restarts    : 1

Why It Exists :
  systemd (pid 1) → cron (pid 448) → cron (pid 492) → sh (pid 523 glance (pid 524)

Source      : systemd service (supervisor)

Working Dir : /home/matoken
Listening   : :::8080

Warnings    :
    Process is listening on a public interface

ポートスキャンしてopen しているポート全てに対してwitr を実行してみたりも.

$ sudo nmap -p 0-65535 localhost | grep open | cut -f1 -d\/ | xargs -n1 sudo ./witr -port

witr の導入

witr の導入はinstall.sh がおすすめされていますがあまり好みの方法ではありません.中を見るとGitHub Releases から環境にあったバイナリをダウンロードして, /usr/local/bin 以下にインストールしています.バイナリはLinux amd64, arm64 が用意してあります.
amd64 環境でには以下のような手順で手動で導入しました.

Note
v0.1.1 でmacOS amd64/arm64 も追加されました.
$ wget -c https://github.com/pranshuparmar/witr/releases/latest/download/witr-linux-amd64 (1)
$ install -m 755 ./witr-linux-amd64 ~/usr/local/bin/witr (2)
$ which witr
/home/matoken/usr/local/bin/witr
$ rm witr-linux-amd64
$ witr (3)
Usage: witr [--pid N | --port N | name] [--short] [--tree] [--json] [--warnings] [--no-color] [--env] [--help] [--version]
  --pid <n>         Explain a specific PID
  --port <n>        Explain port usage
  --short           One-line summary
  --tree            Show full process ancestry tree
  --json            Output result as JSON
  --warnings        Show only warnings
  --no-color        Disable colorized output
  --env             Show only environment variables for the process
  --help            Show this help message
  --version         Show version and exit
$ witr --version
witr v0.1.1 (commit b50f08b, built 2025-12-28)
  1. witr の最新のlinux amd64 バイナリ版をダウンロード

  2. 好みの場所にインストール

  3. USAGE

Linux armhf(arm 32bit) でも動かす

Raspberry Pi bookworm armhf でも動かしたいと思います.
build しようとしたらまずgolang が古いと言われたのでまずは新しいgolang の入手から.

package版golang は1.23 だが1.25.5+ が必要
$ /usr/bin/go build -ldflags "-X main.version=0.1.0 -X main.commit=$(git rev-parse --short HEAD) -X 'main.buildDate=$(date +%Y-%m-%d)'" -o witr-linux-arm32 ./cmd/witr
go: errors parsing go.mod:
/home/matoken/src/witr/go.mod:3: invalid go version '1.25.5': must match format 1.23
go.dev からarmv6 バイナリを入手してパスを通す
$ wget -c https://go.dev/dl/go1.25.5.linux-armv6l.tar.gz (1)
$ mkdir -p ~/usr/local
$ tar -C ~/usr/local -xzf go1.25.5.linux-armv6l.tar.gz (2)
$ rm go1.25.5.linux-armv6l.tar.gz
$ PATH=~/usr/local/go/bin:$PATH (3)
$ which go
/home/matoken/usr/local/go/bin/go
$ go version (4)
go version go1.25.5 linux/arm
$ cat << EOF > hello.go (5)
package main
import "fmt"
func main() {
	fmt.Println("Hello World")
}
EOF
$ go run hello.go (6)
Hello World
  1. Linux armv6l のバイナリをダウンロード

  2. アーカイブを適当な場所に展開

  3. パスを通しておく(一時的な例)

  4. バージョン確認

  5. hello world を用意

  6. 動作確認

witr をビルド
$ git clone https://github.com/pranshuparmar/witr/
$ cd witr
$ go build -ldflags "-X main.version=0.1.0 -X main.commit=$(git rev-parse --short HEAD) -X 'main.buildDate=$(date +%Y-%m-%d)'" -o witr-linux-arm32 ./cmd/witr
$ ./witr-linux-arm32 --version
witr 0.1.0 (commit a2dc413, built 2025-12-28)
]]>
https://matoken.org/blog/2025/12/29/witr_-why-is-this-running/feed/ 0
ターミナル特化MisskeyクライアントのsayakaちゃんとBlurHash https://matoken.org/blog/2025/12/24/sataka-and-blurhash/ https://matoken.org/blog/2025/12/24/sataka-and-blurhash/#respond Wed, 24 Dec 2025 13:37:08 +0000 https://matoken.org/blog/?p=5089

ターミナルに特化した Misskey ストリームクライアントのsayaka ちゃんというソフトウェアがあります.Sixel 対応端末で実行すると画像付きでMisskey をストリーミングしてとても楽しいです.

このsayaka ちゃんに --force-blurhash オプションが実装されたので少し試してみました.

BlurHash?

BlurHash はフードデリバリーサービスのWolt の開発した画像読み込みのプレースホルダーなどに利用できるコンパクトな20〜30文字で表せるぼかした画像です.
この容量の小さい画像をプレースホルダーに埋め込むと空っぽより彩りが豊かになったり,NSFW 画像をモザイクする代わりに使ったり出来ます.
BlurHash はJSON, HTML, Shell で安全な次のキャラクタを使ったBase 83 で表現されます.

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~

BlurHash はMITライセンスでたくさんの言語で実装されています.

以下はDebian logo をC 実装のBlurHash にコンポーネント数ごとにかけてみています.コンポーネント数により7〜133byteで表されています.

$ git clone https://github.com/woltapp/blurhash (1)
$ cd blurhash/C/
$ make blurhash_encoder (2)
$ make blurhash_decoder (3)
$ wget https://www.debian.org/logos/openlogo-nd-100.png (4)
$ file openlogo-nd-100.png
openlogo-nd-100.png: PNG image data, 101 x 124, 8-bit colormap, non-interlaced
$ for i in {1..8}; do ./blurhash_encoder $i $i openlogo-nd-100.png; done (5)
00SFLy
AJSFLyixHXx]
KJSFLyixR5HXx]kCWBj[%#
UJSFLyixR5xuHXx]kCofWBj[%#yDeTV@yXR5
eJSFLyixR5xuVsHXx]kCofj[WBj[%#yD%#eTV@yXR5tRV@o|%}kCRP
oJSFLyixR5xuVsiwHXx]kCofj[VsWBj[%#yD%#tleTV@yXR5tRofV@o|%}kCRPMJ%gV@ozozRPoz
yJSFLyixR5xuVsiwtlHXx]kCofj[VsozWBj[%#yD%#tlkCeTV@yXR5tRofkCV@o|%}kCRPMJMd%gV@ozozRPozRPozaytlR5H?kBRP
:JSFLyixR5xuVsiwtlt7HXx]kCofj[VsozVsWBj[%#yD%#tlkCj[eTV@yXR5tRofkCtRV@o|%}kCRPMJMdV@%gV@ozozRPozRPozozaytlR5H?kBRPtRxukCtRVsR5kCfkae
$ for i in {1..8}; do ./blurhash_encoder $i $i openlogo-nd-100.png | wc -c; done (6)
7
13
23
37
55
77
103
133
$ for i in {1..8}; do ./blurhash_decoder $( ./blurhash_encoder $i $i openlogo-nd-100.png ) 101 124 blur-$i.png; done (7)
$ lsix (8)
  1. BlurHash のsource 入手

  2. encoder build

  3. decoder build

  4. Debian logo file 入手

  5. プレースホルダー枚にBlurHash に変換

  6. バイト数確認

  7. BlurHash をpng に変換

  8. png に変換したBlurHash を表示

blurhash debian logo

昔はhtml のimg タグにlowsrc でサイズの小さい代替画像を指定したりしていましたが(現在は非推奨)それよりも小さくなると思います.

sayaka の –force-blurhash オプションを試す

sayaka ちゃんの –force-blurhash オプションを試してみます.
まずはbuild.
Linux でのbuild 時に引っかかりやすいのがGNU Make ではなくbmake を使うところ.

$ git checkout a4e143d50ceee29a61610d1ee76e4030b0bba273
Previous HEAD position was d76cb2c ver 3.8.1 (2024/09/21)
HEAD is now at a4e143d src/misskey: --force-blurhash オプションを実装してみる。 画像表示を Blurhash だけにするモード。
$ ./configure
$ bmake -DRELEASE all
$ src/sayaka
usage: sayaka <command> [<options...>]
 <command>
  -h,--home           : Home timeline mode (needs --server and --token)
  -l,--local          : Local timeline mode (needs --server)
  -p,--play=<file|->  : Playback mode
 <options>
  -s,--server=<host>  : Set misskey server
  -t,--token=<file>   : Set misskey access token file
  -c,--color=<color>  : 256,16,8,2,1 and gray[2-256] (default:256)
  --show-cw           : Open CW(Contents Warning) part
  --nsfw=<show|blur|alt|hide> : How to show NSFW contents (default:blur)
  --show-image=<yes|no|auto>  : Whether to show image or not (default:auto)
  -r,--record=<file>  : Record JSON to <file>
  --help-all          : More details

build 出来たので早速 --force-blurhash を試してみます.例えば misskey.io をこんな感じで.

$ src/sayaka --force-blurhash -l -s misskey.io

これまでは既定値ではNSFW コンテンツがBlurHash で表示されていましたが,--force-blurhash では全てのアイコン画像も添付画像もBlurHash になります.

sayaka blurhash

Note
アカウントや本文にはモザイクを掛けてあります.

BlurHash で画像サイズが小さくなるってことは通信料もデータ量も小さくなっていてプアな回線でもいい感じにストリーミングできそうな気がします.

BlurHash とSixel を60秒ずつ --record オプションでファイルに保存してみました.期待に反してBlurHash のほうが大分大きいです.

$ timeout 60 src/sayaka --record=blurhash.rec --force-blurhash -l -s misskey.io
$ timeout 60 src/sayaka --record=sixel.rec -l -s misskey.io
$ ls -s *.rec
436 blurhash.rec   44 sixel.rec

ttyrec でも同じような感じ.

$ ttyrec -f blurhash.ttyrec -- timeout 60 src/sayaka --force-blurhash -l -s misskey.io
$ ttyrec -f sixel.ttyrec -- timeout 60 src/sayaka -l -s misskey.io
$ ls -s *.ttyrec
1768 blurhash.ttyrec   228 sixel.ttyrec

通信量はどうだろうとnethogs コマンドで $ sudo nethogs -P $(pgrep sayaka) -l な感じで見てみるとやはりBlurHash のほうが通信量が多いような?

BlurHash
NetHogs version 0.8.8

    PID USER     PROGRAM          DEV                   SENT      RECEIVED
      ? root     unknown TCP                          435.079      11.067 kB/s
2782477 matoken  src/sayaka -..   enx349971e11a0f       0.252       6.934 kB/s

  TOTAL                                               435.331      18.001 kB/s
Sixel
NetHogs version 0.8.8

    PID USER     PROGRAM          DEV                   SENT      RECEIVED
      ? root     unknown TCP                          432.206      11.271 kB/s
2787797 matoken  src/sayaka -..   enx349971e11a0f       0.150       0.885 kB/s

  TOTAL                                               432.356      12.156 kB/s

録画データを見ると件数が違います.Sixel のときになにかボトルネックがありそうです.回線の問題?
後でVPS でも確認してみようと思います.

$ jq .body.type blurhash.rec | wc -l
119
$ jq .body.type sixel.rec | wc -l
10
]]>
https://matoken.org/blog/2025/12/24/sataka-and-blurhash/feed/ 0
ターミナルエミュレータのkittyで日本語入力 https://matoken.org/blog/2025/12/23/japanese-input-with-kitty/ https://matoken.org/blog/2025/12/23/japanese-input-with-kitty/#respond Tue, 23 Dec 2025 10:02:19 +0000 https://matoken.org/blog/?p=5082

icon 32x32

マルチプラットホーム,GPUベースなkitty というターミナルエミュレータがあります.

ターミナルグラフィックのkitty や同じターミナル内での文字サイズ変更など面白い機能もあったりしてGUI 環境でよく使っています.

新規環境でkitty で日本語入力が出来ず設定したのでこちらにもメモしておきます.

今回の環境はDebian trixue amd64 のほぼ初期環境,Wayland ではなくX.org にしてあります.kitty はDebian パッケージマネージャから導入して,日本語入力環境はfcitx + mozc です.
kitty 以外の環境では日本語入力は出来ていますが,kitty ではうまく行きません.

以下のissue を見ると GLFW_IM_MODULE=ibus をせっていすることでibus/fcitx 環境で日本語入力できるようです.

GLFW_IM_MODULE=ibus works for me with fcitx5.

とりあえず別の端末からこんな感じで環境変数を指定してkitty を起動すると日本語入力できます.

$ GLFW_IM_MODULE=ibus kitty

kitty の.desktop ファイルに環境変数を加えてGUI からのkitty 起動時に日本語入力できるようにしておきます.

$ dpkg -L kitty | grep desktop
/usr/share/applications/kitty.desktop
/usr/share/doc/kitty/examples/kitty-open.desktop
$ cp /usr/share/applications/kitty.desktop ~/.local/share/applications/
$ diff -u /usr/share/applications/kitty.desktop ~/.local/share/applications/kitty.desktop
--- /usr/share/applications/kitty.desktop       2025-06-23 03:52:56.000000000 +0900
+++ /home/matoken/.local/share/applications/kitty.desktop       2025-12-23 18:21:14.623247581 +0900
@@ -6,7 +6,7 @@
 Comment=Fast, feature-rich, GPU based terminal
 TryExec=kitty
 StartupNotify=true
-Exec=kitty
+Exec=env GLFW_IM_MODULE=ibus kitty
 Icon=kitty
 Categories=System;TerminalEmulator;
 X-TerminalArgExec=--

これでGUI からkitty を起動して日本語入力できるようになりました.

kitty im toot

環境
$ dpkg-query -W fcitx kitty
fcitx   1:4.2.9.9-2
kitty   0.41.1-2+b1
$ lsb_release -dr
Description:    Debian GNU/Linux 13 (trixie)
Release:        13
$ arch
x86_64
]]>
https://matoken.org/blog/2025/12/23/japanese-input-with-kitty/feed/ 0
snacとBluesky連携 https://matoken.org/blog/2025/12/20/snac-bluesky-bridge/ https://matoken.org/blog/2025/12/20/snac-bluesky-bridge/#comments Sat, 20 Dec 2025 12:53:53 +0000 https://matoken.org/blog/?p=5033

snac susie

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はsnac とBluesky 連携について.

Bluesky はポストTwitter の一つでAT Protocol を利用した分散型SNS です.とはいえ現時点ではActivityPub ほど分散している感じはしません.
このBluesky とfediverse (snac のActivityPub も含む)とWeb を連携させるブリッジとしてBridgy Fed というサービスがあります.
Bridgy Fed を使ってsnac とBluesky を連携してみます,

ActivityPub から連携するには https://fed.brid.gy/login で認証後,「Enable」ボタンを押すとなっているのですがログインしてもボタンが見当たりません.Mastodon としてsnac のアカウントを認証したのでなにかAPI の違いや不足があるのかもしれません.

以下のページを見ると別の方法も紹介されています.

if login isn't supported for your fediverse server, search for and follow @bsky.brid.gy@bsky.brid.gy in the fediverse. That account will then follow you back. Accept its follow to make sure your fediverse posts get sent the bridge and make it into Bluesky. You can unfollow it afterward if you want, you'll still stay bridged. (Here's how to disable.)

snac の該当アカウントで @bsky.brid.gy@bsky.brid.gy をfollow します.するとこのアカウントからfollow が返されるので承認すると連携完了です.この後は unfollow しても連携は維持されるそうです.

このときの連携元アカウントが, @[user]@[instance] の場合Bluesky ブリッジアカウントのハンドルは [user].[instance].ap.brid.gy になります.

なにか投稿して確認しましょう.

snac bsky bridge

Bridgy Fed は単に投稿を転送するだけでなく返信やlikes, (元の投稿がブリッジされている場合は)repost なども連携されるようです.元の投稿を削除した場合も反映されます.

Which stuff of mine from the fediverse will get bridged?

Once you’ve enabled the bridge, anything that’s fully public and interacts with Bluesky users. This includes your posts, replies, likes, and reposts if the original post was bridged. Posts on Bluesky are limited to 300 characters, so longer posts from the fediverse are truncated and ellipsized. Hashtags, links, link previews, images, videos, and even alt text are also included.

ブリッジアカウントの削除を行いたい場合は,Bridgy Fedボットユーザー( @bsky.brid.gy@bsky.brid.gy )をブロックすることで削除できるようです.

If you’re on the fediverse or Bluesky, and you’ve opted in but now want to opt out, block the Bridgy Fed bot user for the network you want to opt out of. For example, on the fediverse, block @bsky.brid.gy@bsky.brid.gy. On Bluesky, block @ap.brid.gy.

(However, if you’re on a Pixelfed instance, DM the word stop to @bsky.brid.gy@bsky.brid.gy instead. Pixelfed doesn’t yet send the ActivityPub Block activity, so blocking won’t work. Hopefully they’ll fix that soon!)

If you’re on the web, email us from an address at your web site’s domain to show that you own it, or you can put the text #nobridge in the profile on your home page and then update your profile on your user page.

Once you’ve done this, Bridgy Fed will deactivate your bridged profile in that network, and it will no longer bridge any of your posts or interactions there.

You can undo this later and reactivate bridging for your account, but depending on the network, not everything will be perfectly restored. For example, when you disable bridging into the fediverse, the bridged fediverse account is deleted and all followers are disconnected. If you later re-enable it, fediverse users will have to search for your account by address manually to find and follow it again.

]]>
https://matoken.org/blog/2025/12/20/snac-bluesky-bridge/feed/ 1
snacの自動投稿機能 https://matoken.org/blog/2025/12/19/implementing-post-bots/ https://matoken.org/blog/2025/12/19/implementing-post-bots/#respond Fri, 19 Dec 2025 14:57:13 +0000 https://matoken.org/blog/?p=5024

snac susie

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はsnac のbot 向け投稿機能について.

bot やアナウンスなど向けのアカウントで自動投稿をしたいことがあります.
例えばいま考えているのはCalDav から今日のイベントを投稿するアカウント.現在はWebhook 経由でDiscord にpost したりしています.
snac でもいくつか自動投稿する機能があります.

Implementing post bots

snac makes very easy to post messages in a non-interactive manner. This example posts a string:

uptime | snac note $SNAC_BASEDIR $SNAC_USER –

You can setup a line like this from a crontab(5) or similar. Take note that you need a) command-line access to the same machine that hosts the snac instance, and b) write permissions to the storage directories and files.

You can also post non-interactively using the Mastodon API and a command-line http tool like curl(1) or similar. This has the advantage that you can do it remotely from any host, anywhere; the only thing you need is an API Token. This is an example:

curl -X POST https://$SNAC_HOST/api/v1/statuses \
–header “Authorization: Bearer ${TOKEN}” -d “status=$(uptime)”

You can obtain an API Token by connecting to the following URL:

— man(1) より
note basedir uid text [file file ... [-r inReplyTo [-d YYYYmmddHHMMSS]]]
        Enqueues a Create + Note message to all followers. If the text argument is -e, the external editor defined by  the  EDITOR  environment  variable
        will  be invoked to prepare a message; if it's - (a lonely hyphen), the post content will be read from stdin.  The rest of command line arguments
        are treated as media files to be attached to the post. The LANG environment variable (if defined) is used as the post language. An  optional  URL
        to  a  Fediverse post, prefixed by -r, can be specified for this note to be a reply to. If a date in YYYYmmddHHMMSS format is followed by -d, the
        note is scheduled for that moment instead of immediately posted (this date must be in the same timezone the user has configured in the web UI).
note_unlisted basedir uid text [file file ... [-r inReplyTo [-d YYYYmmddHHMMSS]]]
        Like the previous one, but creates an "unlisted" (or "quiet public") post.
note_mention basedir uid text [file file ... [-r inReplyTo [-d YYYYmmddHHMMSS]]]
        Like the previous one, but creates a post only for accounts mentioned in the post body.
block basedir instance_url
— man(1) より

snac note コマンドでの投稿

snac の動作している環境で実行できるのであればお手軽なsnac のnote コマンドがあります.
man(1) にある例を真似してみます.

uptime | snac note $SNAC_BASEDIR $SNAC_USER –

$ uptime | pee "./snac note snac-test test -" cat
 23:32:36 up 4 days, 10:17,  1 user,  load average: 1.56, 1.90, 1.69
23:32:36 [test] enqueue_message http://127.0.0.1:8001/test/p/1766154756.511450/Create
8       /�

投稿を確認するとこんな感じ.

snac note 1

日本語もそのままでok でした.

snac note 2

pfetch を流し込んでみるとこんな感じで整形を考えないとダメそう.

snac note 3

curl を使ってAPI 経由で投稿

こちらは一般的なネットワーク経由でリモートで投稿可能な方法です.token を入手してcurl コマンドで投稿します.

まず以下のようなURL でtoken を取得します.

以下のような画面になるので対象アカウントの情報を入手します.

snac get token

以下のようなトークンが取得できるのでメモします.

1f3ea50e9ab7cc85f5ff01b8f43fb1ae

後はcurl などで以下のようにPOST.
json で返り値が帰ってきます.

$ curl -X POST http://127.0.0.1:8001/api/v1/statuses --header "Authorization: Bearer 1f3ea50e9ab7cc85f5ff01b8f43fb1ae" -d "status=$(uptime)"
{
    "id": "1766155742b0f5ed692a273ff5b6ef59b696ddde76",
    "uri": "http://127.0.0.1:8001/test/p/1766155742.788170",
    "url": "http://127.0.0.1:8001/test/p/1766155742.788170",
    "account": {
        "id": "488d5ffe15e31aa0be5002853e8006f7",
        "username": "test",
        "display_name": "test",
        "discoverable": true,
        "group": false,
        "hide_collections": false,
        "indexable": true,
        "noindex": false,
        "roles": [
        ],
        "acct": "test@127.0.0.1:8001",
        "created_at": "2025-11-14T19:38:38Z",
        "last_status_at": "2025-12-19",
        "bot": false,
        "note": "<br>",
        "url": "http://127.0.0.1:8001/test",
        "uri": "http://127.0.0.1:8001/test",
        "avatar": "http://127.0.0.1:8001/susie.png",
        "avatar_static": "http://127.0.0.1:8001/susie.png",
        "header": "",
        "header_static": "",
        "emojis": [
        ],
        "locked": false,
        "followers_count": 0,
        "following_count": 0,
        "statuses_count": 0,
        "fields": [
        ]
    },
    "created_at": "2025-12-19T14:49:02.000Z",
    "content": "23:49:02 up 4 days, 10:34,  1 user,  load average: 1.48, 1.57, 1.68<br>",
    "visibility": "public",
    "sensitive": false,
    "spoiler_text": "",
    "media_attachments": [
    ],
    "mentions": [
    ],
    "tags": [
    ],
    "emojis": [
    ],
    "favourites_count": 0,
    "favourited": false,
    "reblogs_count": 0,
    "reblogged": false,
    "replies_count": 0,
    "in_reply_to_id": null,
    "in_reply_to_account_id": null,
    "reblog": null,
    "card": null,
    "language": "en",
    "filtered": [
    ],
    "muted": false,
    "text": " 23:49:02 up 4 days, 10:34,  1 user,  load average: 1.48, 1.57, 1.68",
    "edited_at": null,
    "poll": null,
    "bookmarked": false,
    "pinned": false
}
]]>
https://matoken.org/blog/2025/12/19/implementing-post-bots/feed/ 0
snacの通知について https://matoken.org/blog/2025/12/18/snac-notifigcations/ https://matoken.org/blog/2025/12/18/snac-notifigcations/#respond Thu, 18 Dec 2025 11:28:14 +0000 https://matoken.org/blog/?p=5007

snac susie

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はsnac の通知について.

snac の通知は以下のように「notifications」の横に数字で通知されます.「notifications」リンクをクリックすることで詳細が表示されます.

snac notifications

しかしこの通知はsnac のページが読み込まれたタイミングにならないと通知がわかりません.
しかし代替の通知がいくつか実装されています.これらを利用することでほぼリアルタイムな通知が可能となります.

e-mail

一般的なe-mail です.サーバーのメールシステムが設定済であればユーザーの「User Settings…​」から「Email address for notifications:」に宛先のe-main address を入力するることで利用可能です.
サーバーのメールシステムの設定がされていなかったり,外部のメールシステムを利用したい場合 server.json の以下の項目を設定することでもメールが送信できます.

Email address for notifications
        If this field is not empty, an email message will be sent to this address whenever a post written by you is liked, boosted or replied to.
— snac(1)より
smtp_url    Since version 2.76, email notifications can be sent via direct connection to an SMTP server instead of the traditional behaviour of piping the mes‐
            sage to /usr/sbin/sendmail.  Set this value to the SMTP url to be used for sending email notifications (for example, smtp://localhost). It may  in‐
            clude a port number if it's not running on the usual one, like in smtp://mail.example.com:587.
smtp_user
smtp_password
            To be filled if the SMTP server defined by the previous directive needs credentials.
— snac(8)より

snac notification email

Telegram で通知

インスタントメッセージアプリケーションのTelegram にも対応しています.ただ,Telegram bot を作成して利用する必要があるので期設定が少し初面倒です.

Telegram notifications
        To  enable  notifications  via Telegram, fill the two provided fields (Bot API key and Chat id). You need to create both a Telegram channel and a
        bot for this; the process is rather cumbersome but it's documented everywhere. The Bot API key is a long string of  alphanumeric  characters  and
        the chat id is a big, negative number.
— snac(1)より

以前Telegram bot をNextcloud のTOTP の通知設定に利用するために書いたエントリがあります.

Telegram bot が作成できたら各ユーザの「User Settings…​」の「Telegram notifications (bot key and chat id):」に設定することで利用できます.

ntfy で通知

OSS でセルフホスト可能でウェブブラウザやスマートフォンに通知ができるntfy というサービスがあります.これを利用してsnac の通知を行うことも可能です.

ntfy notifications
        To  enable  notifications  via  ntfy  (both self-hosted or standard ntfy.sh server), fill the two provided fields (ntfy server/topic and, if pro‐
        tected, the token).  You need to refer to the https://ntfy.sh web site for more information on this process.
— snac(1)より

セルフホスト可能ですが,とりあえずntfy.sh を利用して試すと良さそうです.

「User Settings…​」の「ntfy notifications (ntfy server and token):」に設定することで通知できるようになります.

Webhook で通知

色々なサービスが対応しているWebhook も利用可能です.

Notify webhook
        If this is set to an URL, an HTTP POST will be sent to it whenever a new notification happens (see the 'Webhook for notifications' section  below
        for more information).
— snac(1)より

例えばDiscord であれば,「チャンネルの編集」→「連携サービス」→「ウェブフックを作成」で生成されるURL を利用して通知できます.
これを「User Settings…​」の「Notify webhook:」に入力することで通知可能です.

mastodon アプリケーションでの通知

snac はmastodon API に対応しています.そのためmastodon アプリケーションが利用可能です.
mastodon アプリケーションの通知機能を使って通知を受けることが可能です.

]]>
https://matoken.org/blog/2025/12/18/snac-notifigcations/feed/ 0
snacのthemeを設定 https://matoken.org/blog/2025/12/17/snac-theme/ https://matoken.org/blog/2025/12/17/snac-theme/#respond Wed, 17 Dec 2025 12:04:10 +0000 https://matoken.org/blog/?p=4987

snac susie

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はsnac のtheme 変更.

snac はCSS ファイルを編集することでテーマを設定することが出来ます.
CSS ファイルは2種類あり,インスタンス全体のスタイルを設定する, {basedir}/style.css と,各ユーザー用のプライベートCSSファイルの {basedir}/user/{ユーザー名}}/static/style.css です.

Tip

手元のsnac 2.8.5 で試したところ,各ユーザーのプライベートCSSファイルはログインした状態でないと効かないようです.
つまり,各ユーザーの公開ページはグローバル設定が反映されます.
そして,設定にはtheme ファイルを該当場所に設定する必要がありますが,ウェブ上からは出来ないので管理者にお願いするなどの手間がかかります.

自分で設定しなくても, README.mdIncredibly awesome CSS themes for snac 部分にいくつかのtheme が紹介されているのでこれを使わせてもらったりそれを元にカスタマイズするのでも良さそうです.

$ grep -A5 'Incredibly awesome CSS themes for snac' README.md
## Incredibly awesome CSS themes for snac

- [A compilation of themes for snac (by Во )](https://codeberg.org/voron/snac-style).
- [A cool, elegant theme (by Haijo7)](https://codeberg.org/Haijo7/snac-custom-css).
- [A terminal-like theme (by Tetra)](https://codeberg.org/ERROR404NULLNOTFOUND/snac-terminal-theme).

以下は Pika というtheme を設定した例です.3ペインになり,PC等の横長画面での操作性が良さそうです.

snac theme pika

]]>
https://matoken.org/blog/2025/12/17/snac-theme/feed/ 0
snacのWelcome pageを設定ファイルでカスタマイズ https://matoken.org/blog/2025/12/16/snac-welcome-page-costomsetting/ https://matoken.org/blog/2025/12/16/snac-welcome-page-costomsetting/#respond Tue, 16 Dec 2025 10:19:40 +0000 https://matoken.org/blog/?p=4973

snac susie

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はsnac でのWelcome pageのカスタマイズについてその2.
以前のカスタマイズではhtml ファイルの書き換えを行いましたが今回は設定ファイルでの書き換えです.

snac のtop page は以下のような挨拶ページが表示されます. greeting.html ファイルを書き換えることでこのページをカスタマイズ出来ますが,他にもサーバー設定ファイルの server.json でもカスタマイズ項目があります.

$ w3m -dump https://snac.kagolug.org/
snac.kagolug.org is a Fediverse instance that uses the ActivityPub protocol. In
other words, users at this host can communicate with people that use software
like Mastodon, Pleroma, Friendica, etc. all around the world.

This server runs the snac software and there is no automatic sign-up process.

The following users are part of this community:

    @info@snac.kagolug.org (info)
    @matoken@snac.kagolug.org (matoken)

This site is powered by snac.

snac greeting page

show_instance_timeline これを true に設定するとWelcome page に最新のユーザーが投稿したタイムラインが表示されるようになります.
また,以下の設定項目が設定されていた場合それも表示されます.

admin_email
インスタンス管理者の電子メールアドレス

admin_account
インスタンス管理者のアカウント

title
インスタンスのタイトル

short_description
インスタンスに対する短い説明

short_description_raw
short_description を生の文字列として解釈するか,HTML に変換するか

例えばこの様に設定すると,

$ grep -A5 show_instance_timeline snac-data/server.json
    "show_instance_timeline": true,
    "admin_email": "",
    "admin_account": "matoken",
    "title": "🐈🐈🐈",
    "short_description": "matokenの個人ActivityPub インスタンスです.",
    "short_description_raw": false,

こんな感じになりました.

snac welcome page customsettings

注意点として,show_instance_timelinetrue にすると greeting.html は無視されるようです.用途や好みに合わせてどちらかを利用する感じでしょうか.

]]>
https://matoken.org/blog/2025/12/16/snac-welcome-page-costomsetting/feed/ 0
snacでのSPAM対策 https://matoken.org/blog/2025/12/15/snac-spam-mitigation/ https://matoken.org/blog/2025/12/15/snac-spam-mitigation/#respond Mon, 15 Dec 2025 10:50:27 +0000 https://matoken.org/blog/?p=4962

snac susie

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はsnac でのSPAM 対策について.

SPAM が来ないに越したことはありませんがActivityPub でも偶に見かけます.もしSPAM が来るときのことを考えて対策を確認しておきます.
snac では2つの対策があるようです.

SPAM Mitigation
    There have been some SPAM attacks on the Fediverse and, as too many instances and server implementations out there still allow automatic account creation, it will only get worse.  snac includes some (not very strong) tools for try‐
    ing to survive the SPAM flood that will eventually happen.
The  min_account_age field in the main configuration file allows setting a minimum age (in seconds) to consider too recently created accounts suspicious of being a potential source of SPAM. This is a naïve assumption, because spam‐
mers can create accounts, let them dormant for a while and then start to use them. Also, some ActivityPub implementations don't even bother to return a creation date for their accounts, so this is not very useful.
From version 2.50, post content can be filtered out by regular expressions.  These weapons of mass destruction can be written into the filter_reject.txt file in the server base directory, one per line;  if  this  file  exists,  all
posts'  content  will  be  matched (after being stripped of HTML tags) against these regexes, one by one, and any match will make the post to be rejected. Use lower case, the regex will be case insensitive by default.  If you don't
know about regular expressions, don't use this option (or learn about them inw some tutorial, there are gazillions of them out there), as you and your users may start missing posts. Also, given that every regular expression  imple‐
mentation supports a different set of features, consider reading the documentation about the one implemented in your system.
— snac(8) より

アカウント作成から日の浅いアカウントを拒否

1つ目はメイン設定ファイルの server.json で設定できる min_account_age で,投稿を受け付けるアカウントが作成されてからの時間が設定できます.
ただし,SPAM アカウントを作成して寝かせてから運用したり,アカウントの作成日を返さない実装もあるらしいのであまり役に立たないようです.
既定値は 0 になっています.

$ jq .min_account_age server.json
0

投稿内容を正規表現でフィルタリング

2つめは投稿内容を正規表現でフィルタリングできるようです.snac データディレクトリに filter_reject.txt を用意してこのファイル中に1行ずつ記述できるようです.これにより全ての投稿をHTML タグを取り除いた後正規表現と1つずつ照合され一致する投稿は拒否されます.
正規表現なのでテストを十分して設定したほうが良さそうです.

Reverse proxy やFirewall などsnac の外で対策も考えられます.その他以下のようなものもあるようです.e-mail もこんな感じで多段にしたりしますね.そうなるとReceived のようなものが見たいなと思ったりも.

]]>
https://matoken.org/blog/2025/12/15/snac-spam-mitigation/feed/ 0
snacのrobots.txt https://matoken.org/blog/2025/12/14/snac-robots-txt/ https://matoken.org/blog/2025/12/14/snac-robots-txt/#respond Sun, 14 Dec 2025 09:26:00 +0000 https://matoken.org/blog/?p=4953

susie64 cool

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はsnac でのrobots.txt について.

検索エンジンで「site:snac.kagolug.org」のように検索してみると何も出てきません.運用開始からそう時間が経っていないからかな?と思いつつ念の為 robots.txt を確認するとこんな感じで全て拒否るすようになっていました.

$ w3m -dump https://snac.kagolug.org/robots.txt
User-agent: *
Disallow: /

source を確認すると httpd.c の中でハードコーディングされているようです.

$ grep -n -A5 robots.txt httpd.c
321:    if (strcmp(q_path, "/robots.txt") == 0) {
322-        status = HTTP_STATUS_OK;
323-        *ctype = "text/plain";
324-        *body  = xs_str_new("User-agent: *\n"
325-                            "Disallow: /\n");
326-    }

snac の設定でどうにかできればいいですが恐らく無理.ISSUE を探すと以下のものが.404エラーが邪魔なので用意しているだけでカスタマイズしたい人は前段のhttp proxy でルールを追加する感じのようです.

ISSUE を立てた方はnginx でカスタムrobots.txt を返すようにしているようです.

Actually, I am able to work around this by returning a custom robots.txt with nginx:

location = /robots.txt {
		return 200 'User-agent: FediFetcher\nAllow: /\nUser-agent: *\nDisallow: /\n';
}

自分の環境はApache2 httpd ですが同じような設定はできるので設定してみます.

Apache2 httpd のAlias でrobots.txt を設定

以前Nitter を公開していたときにもやっていたのでこれを参考に設定します.

Apache2 httpd のsnac 部分の設定を以下のように修正しました.これでLinux ファイルシステム内の /var/lib/snac2/robots.txt/robots.txt になるはずです.

$ sudo git diff /etc/apache2/sites-available/011-snac.kagolug.org.conf
diff --git a/apache2/sites-available/011-snac.kagolug.org.conf b/apache2/sites-available/011-snac.kagolug.org.conf
index f5b5c7f..7bb72c1 100644
--- a/apache2/sites-available/011-snac.kagolug.org.conf
+++ b/apache2/sites-available/011-snac.kagolug.org.conf
@@ -58,6 +58,11 @@
        </Location>

        Alias /static /var/www/static
+       Alias /robots.txt /var/lib/snac2/robots.txt
+       <Location "/robots.txt">
+               ProxyPass !
+               Require all granted
+       </Location>

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.

設定を確認してから反映します.

$ sudo apache2ctl configtest
$ sudo systemctl reload apache2

このファイルが,

$ sudo -u www-data cat /var/lib/snac2/robots.txt
User-agent: *
Allow: /

/robots.txt に反映されました.

$ w3m -dump https://snac.kagolug.org/robots.txt
User-agent: *
Allow: /

これで各種bot からのアクセスが許可されました.

source 書き換え

source からbuild している環境ではsource 書き換えでもrobots.txt をカスタマイズできました.でもアップデートのたびにパッチを当てるのは面倒なのでやはりproxy で設定するほうが良さそうです.

robots.txt を無くす(404 エラーがたくさんなのであまり良く無さそう)
$ git diff httpd.c
diff --git a/httpd.c b/httpd.c
index a8cd849..976fdd6 100644
--- a/httpd.c
+++ b/httpd.c
@@ -318,13 +318,6 @@ int server_get_handler(xs_dict *req, const char *q_path,
         *body  = xs_json_dumps(j, 4);
     }
     else
-    if (strcmp(q_path, "/robots.txt") == 0) {
-        status = HTTP_STATUS_OK;
-        *ctype = "text/plain";
-        *body  = xs_str_new("User-agent: *\n"
-                            "Disallow: /\n");
-    }
-    else
     if (strcmp(q_path, "/style.css") == 0) {
         FILE *f;
         xs *css_fn = xs_fmt("%s/style.css", srv_basedir);
$ w3m -dump https://snac.matoken.org/robots.txt
404 Not Found (snac/2.85)
全て許可に書き換え
$ git diff httpd.c
diff --git a/httpd.c b/httpd.c
index a8cd849..c0bcaef 100644
--- a/httpd.c
+++ b/httpd.c
@@ -322,7 +322,7 @@ int server_get_handler(xs_dict *req, const char *q_path,
         status = HTTP_STATUS_OK;
         *ctype = "text/plain";
         *body  = xs_str_new("User-agent: *\n"
-                            "Disallow: /\n");
+                            "Allow: /\n");
     }
     else
     if (strcmp(q_path, "/style.css") == 0) {
$ w3m -dump https://snac.matoken.org/robots.txt
User-agent: *
Allow: /
]]>
https://matoken.org/blog/2025/12/14/snac-robots-txt/feed/ 0
snacのWelcome pageのhtmlファイルカスタマイズ https://matoken.org/blog/2025/12/13/snac-welcome-page/ https://matoken.org/blog/2025/12/13/snac-welcome-page/#respond Sat, 13 Dec 2025 09:43:34 +0000 https://matoken.org/blog/?p=4937

snac susie

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はsnac でのWelcome page のhtml ファイルカスタマイズについて.

snac のtop page は以下のような挨拶ページが表示されます.このページをカスタマイズしてみます.

$ w3m -dump https://snac.kagolug.org/
snac.kagolug.org is a Fediverse instance that uses the ActivityPub protocol. In
other words, users at this host can communicate with people that use software
like Mastodon, Pleroma, Friendica, etc. all around the world.

This server runs the snac software and there is no automatic sign-up process.

The following users are part of this community:

    @info@snac.kagolug.org (info)
    @matoken@snac.kagolug.org (matoken)

This site is powered by snac.

snac greeting page

このページは greeting.html を読み込んでいるようです.

greeting.html
<!DOCTYPE html>
<html><head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="icon" type="image/x-icon" href="https://%host%/favicon.ico"/>
<style>*{color-scheme:light dark}body{margin:auto;max-width:50em}</style>
<title>Welcome to %host%</title>
</head>
<body>
<p><b>%host%</b> is a <a href="https://en.wikipedia.org/wiki/Fediverse">Fediverse</a> instance that uses the <a href="https://en.wikipedia.org/wiki/ActivityPub">ActivityPub</a> protocol. In other words, users at this host can communicate with people that use software like Mastodon, Pleroma, Friendica, etc. all around the world.</p>
<p>This server runs the <a href="https://comam.es/what-is-snac">snac</a> software and there is no automatic sign-up process.</p>
<p>The following users are part of this community:</p>

%userlist%

<p>This site is powered by <abbr title="Social Networks Are Crap">snac</abbr>.</p>
</body></html>

例えば日本語にしたり,ユーザーリストを隠したりといったカスタマイズが出来ます.このhtml ファイルを保存した時点で反映されます.

$ w3m -dump https://snac.kagolug.org/
snac.kagolug.orgはActivityPubプロトコルを利用したFediverseインスタンスです.こ
のホストのユーザーは世界中のMastodon, Pleroma, Friendica, などのソフトウェアを
利用している人々とコミニュケーションを取ることが出来ます.

このサーバーはsnac ソフトウェアを利用しています.自動登録プロセスはありません.

以下のユーザーがこのコミュニティに参加しています:

    @info@snac.kagolug.org (info)
    @matoken@snac.kagolug.org (matoken)

This site is powered by snac.

snac greeting page ja

今回とりあえず日本語にしましたが,LUG の説明なども入れたいところです.

]]>
https://matoken.org/blog/2025/12/13/snac-welcome-page/feed/ 0
Debian 13 trixieでbackportsを使い最新のsnacを利用 https://matoken.org/blog/2025/12/11/latest-snac-using-debian-backports/ https://matoken.org/blog/2025/12/11/latest-snac-using-debian-backports/#respond Thu, 11 Dec 2025 09:35:57 +0000 https://matoken.org/blog/?p=4909

snac susie

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はDebian trixie backports のsnac パッケージを使うよう設定してみます.

Debian でのsnac2 パッケージのバージョン

snac2 はDebian パッケージになっています.しかし,stable のDebian 13 trixie のsnac2 パッケージのバージョンは 2.75-2 で少し古いバージョンです.
stable-backports のパッケージのバージョンは現在の上流の最新と同じ 2.85 なのでこれを利用してみます.

$ rmadison snac2| grep -v debug
snac2      | 2.75-2~bpo12+1 | oldstable-backports       | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
snac2      | 2.75-2         | stable                    | source, amd64, arm64, armel, armhf, i386, ppc64el, riscv64, s390x
snac2      | 2.84-3~bpo13+1 | stable-backports          | source, riscv64
snac2      | 2.85-1~bpo13+1 | stable-backports          | source, amd64, arm64, armel, armhf, i386, ppc64el, s390x
snac2      | 2.85-1         | testing                   | source, amd64, arm64, armhf, i386, ppc64el, riscv64, s390x
snac2      | 2.85-1         | unstable                  | source, amd64, arm64, armhf, i386, ppc64el, riscv64, s390x

Debian 13 trixie に backports を設定

Debian backports はDebian stable で一部のtesting パッケージを利用できるよう調整されたもので対応したパッケージであればstable より新しいバージョンが利用できます.

これを利用するためにはbackports 情報を sources.list に追加する必要があります.
ここでは公式ドキュメントと同じ /etc/apt/sources.list.d/debian-backports.sources としてファイルを作成しました.

/etc/apt/sources.list.d/debian-backports.sources を作成
Types: deb deb-src
URIs: http://deb.debian.org/debian
Suites: trixie-backports
Components: main
Enabled: yes
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

続いてパッケージ情報をbackports を含む最新状態にします.

パッケージ情報更新
$ sudo apt update

backports の snac を導入

backpots のパッケージは通常のインストールでは導入されません.backports のパッケージを導入するにはパッケージ名に /trixie-backports を付けて導入します.

$ sudo apt install snac2/trixie-backports

もしくは -t trixie-backports を付けて導入すると不足した依存関係も導入されるようです.

$ sudo apt install -t trixie-backports snac2
$ dpkg-query -W snac2
snac2   2.85-1~bpo13+1
$ snac version
snac 2.85 - A simple, minimalistic ActivityPub instance
Copyright (c) 2022 - 2025 grunfink et al. / MIT license

upgrade {basedir}                    Upgrade to a new version

導入されたbackports パッケージは通常と同じ優先度100に固定されるので導入後はいつもの apt upgrade でbackports パッケージも更新されます.つまり通常の運用で大丈夫です.

snac アップグレード操作

snac のバージョンアップ時にディスク構成が変わることがあり,その場合snac が起動しないようです.その場合snac の upgrade コマンドを実行する必要があるようです.
自分は念の為毎回実行しています.

snac(8)より
Upgrading to a new version
    Sometimes, the data storage disk layout changes between versions. If there is such a change, snac will refuse to run and require an upgrade. Do this by running
snac upgrade $HOME/snac-data
Take special care to execute this upgrade operation without any snac processes serving on the same folder. You can break everything. I know this because Tyler knows this.
$ snac | grep upgrade
upgrade {basedir}                    Upgrade to a new version

upgrade コマンドはデーモンが起動していない状態で実行する必要があるので一旦snac を停止してから実行,その後snac を起動します.

$ sudo service snac2 stop (1)
$ sudo -u debian-snac snac upgrade /var/lib/snac2/ (2)
19:45:50 Linux sandbox not compiled in
19:45:50 OK
$ sudo service snac2 start (3)
$ w3m -dump https://snac.kagolug.org/info | tail -1 (4)
about this site - powered by snac/2.83
  1. snac 停止

  2. snac upgrade

  3. snac 起動

  4. バージョン確認

という感じでDebian stable でも最新のsnac が利用できています.一旦設定すると通常のDebian パッケージ更新操作で追従してくれるので運用もいつもと変わりません.更新タイミングも公式と見比べると結構すぐ対応してくれているようです.

]]>
https://matoken.org/blog/2025/12/11/latest-snac-using-debian-backports/feed/ 0
snac でカスタム絵文字を利用 https://matoken.org/blog/2025/12/10/snac-emoji/ https://matoken.org/blog/2025/12/10/snac-emoji/#respond Wed, 10 Dec 2025 10:09:41 +0000 https://matoken.org/blog/?p=4889

snac susie

さくらのナレッジに軽量ActivityPub Server のsnac についての記事を寄稿しました.

ここに書かなかったsnac のことをいくつか書いていこうと思います.
今日はカスタム絵文字について.

ActivityPub 各インスタンスでよく使われているカスタム絵文字というものがあります.misskey.io なんかでは特に多用されているようです.
snac もカスタム絵文字に対応しています.

既定値で設定されているものとして例えばtoot 本文中に :-) と入力することで「🙂」が, :beer: と入力することで「🍺」が表示されます.他に :shrug2: で「¯\_(ツ)_/¯」なんでものも.でもこのあたりのUnicode絵文字などは日本語入力環境があるとあまり有り難みは感じなそうです.でも画像ファイルも利用できます.

自分で用意した絵文字を追加してみましょう.

カスタム絵文字を追加するにはsnac のデータディレクトリにある emojis.json を編集することでカスタマイズできます.

emojis.json の既定値はこんな感じです.
toot 本文中に記述するkey と,実際に評される値の組み合わせです.key は保管性を保つために : で囲むことが推奨されています.値は以下では数値文字参照及び文字列ですが,URL を指定することも出来ます.

{
    ":-)": "&#128578;",
    ":-D": "&#128512;",
    "X-D": "&#128518;",
    ";-)": "&#128521;",
    "B-)": "&#128526;",
    ">:-(": "&#128545;",
    ":-(": "&#128542;",
    ":-*": "&#128536;",
    ":-/": "&#128533;",
    "8-o": "&#128562;",
    "%-)": "&#129322;",
    ":_(": "&#128546;",
    ":-|": "&#128528;",
    "<3": "&#10084;&#65039;",
    ":facepalm:": "&#129318;",
    ":shrug:": "&#129335;",
    ":shrug2:": "&#175;\\_(&#12484;)_/&#175;",
    ":eyeroll:": "&#128580;",
    ":beer:": "&#127866;",
    ":beers:": "&#127867;",
    ":munch:": "&#128561;",
    ":thumb:": "&#128077;"
}

ここにsnac デフォルトアイコンを追加してみます.snac のベースurl の下の /susie.png (kagolug では https://snac.kagolug.org/susie.png )にアクセスするとsnac デフォルトアイコンのsusie が表示されます.これを利用してみます.

emojis.json を以下のように書き換えます.

     ":beer:": "&#127866;",
     ":beers:": "&#127867;",
     ":munch:": "&#128561;",
-    ":thumb:": "&#128077;"
+    ":thumb:": "&#128077;",
+    ":susie:": "https://snac.kagolug.org/susie.png"
 }
Tip

emojis.json は保存した時点で内容が反映されます.中途半端な状態で保存すると全てのカスタム絵文字が利用できなくなったりするので注意しましょう.

これで :susie: と入力することで snac susie が表示されるようになります.

更にペンギンのTux とタスマニアデビルのTuz を追加してみます.
アイコンの画像ファイルを用意し,静的環境に設置,そのurl をemojis.json ファイルに記述します.
今回以下のようになりました.

     ":beer:": "&#127866;",
     ":beers:": "&#127867;",
     ":munch:": "&#128561;",
-    ":thumb:": "&#128077;"
+    ":thumb:": "&#128077;",
+    ":susie:": "https://snac.kagolug.org/susie.png",
+    ":tux:": "https://www.kagolug.org/snac-emoji/Tux.png",
+    ":tuz:": "https://www.kagolug.org/snac-emoji/Tuz.png"
 }

これで :susie:, :tux:, :tuz: の3つの絵文字が利用できるようになりました.
toot して確認できます.
もしくは以下のようなサイトでMastodon カスタム絵文字API経由で絵文字一覧を確認することも出来ます.

snac emojos.in ]

snac のカスタム絵文字についての詳細はsnac(8) を参照してください.

Custom Emojis
    From version 2.51, support for customized Emojis in posts is available (previously, they were hardcoded). Emojis are read from the emojis.json file in the instance base directory, as a JSON object of key / value pairs (if this file
    does not exist, it will be created with the predefined set). Each key in the object contains the text to be found (e.g., the :-) for a smiling face), and its associated value, the text string that will replace it (in  this  example
    case, the HTML entity for the Unicode codepoint for the smiley or the Emoji itself as text).
Emoji values can also be URLs to image files; in this case, they will not be substituted in the post content, but added to the 'tag' array as an ActivityPub standard 'Emoji' object (it's recommendable that the Emoji key be enclosed
in colons for maximum compatibility with other ActivityPub implementations, like e.g. :happydoggo:). These images can be served from an external source or from the static directory of the instance admin.
If you want to disable any Emoji substitution, change the file to contain just an empty JSON object ({}).
]]>
https://matoken.org/blog/2025/12/10/snac-emoji/feed/ 0
コマンドラインシステム観察,情報表示,ベンチマークツールのsot https://matoken.org/blog/2025/12/08/sot/ https://matoken.org/blog/2025/12/08/sot/#respond Sun, 07 Dec 2025 15:02:11 +0000 https://matoken.org/blog/?p=4819

sot logo

top みたいなシステム観察の他にscreenfetch のようなシステム情報,更にベンチマーク機能のあるsot というツールを試してみました.

sot 導入

sot はいくつかの導入方法があります. curl | bash が最初にお勧めとして紹介されていますが個人的にこれは好きではないのでuv で導入しました.

$ uv tool install sot
$ which sot
/home/matoken/.local/bin/sot
$ sot --version
╭──────────────────── System Observation Tool ────────────────────╮
│                                                                 │
│        ▄▀▀  ▄▀▀▄  ▀█▀                                           │
│        ▀▀▄  █  █   █                                            │
│        ▄▄▀  ▀▄▄▀   █                                            │
│                                                                 │
│  System Observation Tool                                        │
│                                                                 │
╰─────────────────────────────────────────────────────────────────╯

╭──────────────────── 📋 Version Information ─────────────────────╮
│                                                                 │
│   Version:      5.0.0                                           │
│   Python:       3.13.11                                         │
│   Platform:     Linux (Debian GNU/Linux n/a)                    │
│   Architectur…  x86_64                                          │
│                                                                 │
╰─────────────────────────────────────────────────────────────────╯

╭─────────────────────────────────────────────────────────────────╮
│  MIT License © 2024-2025 Kumar Anirudha                         │
│  🔗 https://github.com/anistark/sot | 📖 sot --help | 🚀 sot    │
╰─────────────────────────────────────────────────────────────────╯

sot version

Note

sot 4.4.2 で試したときはuv 及びpipx での導入時にシステム情報表示機能の info option や
benchmark 機能の bench option が出てこず使えませんでした.source から導入したらok.

sot: error: unrecognized arguments: info
sot: error: unrecognized arguments: bench

sot 実行

まずはオプション無しでsot 実行.top のような動きです.
o key で並べ替えモードになり矢印キーで設定,Enter で総巡航順変更, q で並べ替えモードから抜けます.
Ctrl+q で終了です.
カラフルで楽しいです.

sot top

sot システム情報表示(info)

次にシステム情報表示の info オプションを試します.

$ sot info
       _,met$$$$$gg.            Host        -  matoken@tp-l13
    ,g$$$$$$$$$$$$$$$P.
  ,g$$P"     """Y$$."`.         OS          -  Debian GNU/Linux n/a
 ,$$P'              `$$$.       Kernel      -  6.17.10+deb14-amd64
',$$P       ,ggs.     `$$b:     DE          -  i3
`d$$'     ,$P"'   .    $$$      WM          -  x11
 $$P      d$'     ,    $$P      Shell       -  bash
 $$:      $$.   -    ,d$$'      Terminal    -  xterm-kitty
 $$;      Y$b._   _,d$P'
 Y$$.    `.`"Y$$$$P"'           Memory      -  9 GiB / 15 GiB
 `$$b      "-.__
  `Y$$
   `Y$$.                        Uptime      -  8h 53m
     `$$b.                      Battery     -  100% & Discharging
       `Y$$b.

Battery があるのは珍しいですね.でも値は間違っていそう?
logoの種類は以下の通り.少し少なめ.

macOS: Apple logo

Linux Distributions:

Ubuntu
Debian
Fedora
Red Hat / RHEL
Arch Linux
Manjaro
Pop!_OS
CentOS
Generic Linux/Tux (fallback)

Windows: Windows logo

sot ベンチマーク(bench)

次にベンチマークの bench オプション.
実行時にシステム内のディスクが表示されるのでベンチ対象をカーソルで選択しベンチマークを実行します.

Use arrow keys (↑↓) to navigate, Enter to select, or 'q' to quit:

  ❯ 0: System - 450.9 GiB total, 4.6 GiB free
    1: efi - 511.0 MiB total, 501.9 MiB free
    2: boot - 455.1 MiB total, 338.7 MiB free
    3: 068d2d0a-235d-4c86-839e-4d37081979a2 - 457.4 GiB total, 197.5 MiB free

✓ Selected: System
  Using partition: /dev/mapper/tp--l13--vg-root (/)

Running benchmarks on System...

Per-benchmark duration: 10.0s

Benchmarking... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 00:01:31.39


╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────── System ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────│ Disk ID: /dev/mapper/tp--l13--vg-root (System)                                                                                                                                                                                              │
│ Total Capacity: 450.9 GiB                                                                                                                                                                                                                   │
│ Free Space: 4.6 GiB                                                                                                                                                                                                                         │
│ Cache Directory: /home/matoken/.sot/bench                                                                                                                                                                                                   │
│                                                                                                                                                                                                                                             │
│ Partitions:                                                                                                                                                                                                                                 │
│   • /dev/mapper/tp--l13--vg-root → /                                                                                                                                                                                                       │   • /dev/mapper/tp--l13--vg-root → /run/schroot/mount/bookworm-i386-53c15ea2-b9a4-4693-b02b-be7786ca929f                                                                                                                                   │   • /dev/mapper/tp--l13--vg-root → /run/schroot/mount/bookworm-i386-53c15ea2-b9a4-4693-b02b-be7786ca929f/home                                                                                                                              ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────                                     Benchmark Results
┏━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Test              ┃ Throughput/IOPS ┃ Avg Latency ┃ p95 Latency ┃ p99 Latency ┃ Duration ┃
┡━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ Sequential Read   │ 245.9 MB/s      │ 4.06 ms     │ 11.76 ms    │ 24.01 ms    │ 10.00 s  │
│ Sequential Write  │ 177.7 MB/s      │ 5.59 ms     │ 9.13 ms     │ 12.46 ms    │ 10.00 s  │
│ Random Read IOPS  │ 40.61 KIO/s     │ 20.43 µs    │ 107.53 µs   │ 211.48 µs   │ 10.00 s  │
│ Random Write IOPS │ 834.60 IO/s     │ 1.18 ms     │ 2.59 ms     │ 5.12 ms     │ 10.00 s  │
└───────────────────┴─────────────────┴─────────────┴─────────────┴─────────────┴──────────┘

✓ Benchmarking completed successfully

簡易的なベンチに良さそうです.

sot ディスク情報(disk)

もう一つdisk オプション.これは最近追加されたオプションのようでディスク情報をインタラクティブに表示するもののようです.
カーソルでディスクを選択してEnter で情報が見れます.

$ sot disk

sot disk

]]>
https://matoken.org/blog/2025/12/08/sot/feed/ 0
pdfファイルを直接grepできるpdfgrep https://matoken.org/blog/2025/12/05/pdfgrep/ https://matoken.org/blog/2025/12/05/pdfgrep/#respond Fri, 05 Dec 2025 11:27:51 +0000 https://matoken.org/blog/?p=4794

Terminal Trove でpdfgrep というツールを知ったので試してみました.

pdfgrep はpdf ファイルをgrep と同様パターンにマッチする行を表示してくれるものです.オプションは GNU grep をある程度踏襲しています.

Debian sid 環境でsource からbuild する例
$ sudo apt install libgcrypt20-dev libpoppler-cpp-dev
$ git clone https://gitlab.com/pdfgrep/pdfgrep
$ cd pdfgrep
$ ./autogen.sh
$ ./configure --prefix=$HOME/usr/local
$ make
$ make install
help
$ pdfgrep --help
Usage: ./src/pdfgrep [OPTION]... PATTERN FILE...

Search for PATTERN in each FILE.
PATTERN is, by default, an extended regular expression.

Commonly used options:
 -i, --ignore-case              Ignore case distinctions
 -P, --perl-regexp              Use Perl compatible regular expressions (PCRE)
 -H, --with-filename            Print the file name for each match
 -h, --no-filename              Suppress the prefixing of file name on output
 -n, --page-number              Print page number with output lines
 -c, --count                    Print only a count of matches per file
     --color WHEN               Use colors for highlighting;
                                WHEN can be `always', `never' or `auto'
 -p, --page-count               Print only a count of matches per page
 -m, --max-count NUM            Stop reading after NUM matching lines (per file)
 -q, --quiet                    Suppress normal output
 -r, --recursive                Search directories recursively
 -R, --dereference-recursive    Likewise, but follow all symlinks
     --cache                    Use cache for faster operation
     --help                     Print this help
 -V, --version                  Show version information

The above list is only a selection of commonly used options. Please refer
to the man page for a complete list.
適当なpdf ファイルをgrep
$ pdfgrep raspberry ~/Downloads/MagPi128.pdf | head
raspberrypi.com
                       magpi@raspberrypi.com
                       forums.raspberrypi.com
                                                     lucy@raspberrypi.com
                                                     rob@raspberrypi.com
                                                     charlotte.milligan@raspberrypi.com
                                                     brian.jepson@raspberrypi.com
 Learn Sense HAT             magpi@raspberrypi.com             (CC BY-NC-SA 3.0).
GNU grep でよく使うオプションを利用
$ pdfgrep -m5 -n -i raspberry ~/Downloads/MagPi128.pdf
1:Issue 128     April 2023   magpi.cc    The official Raspberry Pi magazine
1:   Discover coding with Raspberry Pi
1:            NEW! RASPBERRY PI GLOBAL SHUTTER CAMERA
2: Industrial Raspberry Pi
3:(page 44) can help you out on this journey. I hope you take it.                 Raspberry Pi office
                                     This Month in Raspberry Pi
日本語もok
$ pdfgrep -r -m1 -n サーバー ~/Nextcloud_matoken\@files.matoken.org/Linux/2025/
/home/matoken/Nextcloud_matoken@files.matoken.org/Linux/2025//sakura-cominuty-2025/snac-kagolug.pdf:2:サーバー設定ファイルの server.json を編集します。 "protocol" を
/home/matoken/Nextcloud_matoken@files.matoken.org/Linux/2025//kagolug2025.08/slide/slide.pdf:1:  ルサーバーの
/home/matoken/Nextcloud_matoken@files.matoken.org/Linux/2025//kagolug2025.09/slide/slide.pdf:19:ActivityPubも少し探したが,自分とサーバーの落ちているものしか
/home/matoken/Nextcloud_matoken@files.matoken.org/Linux/2025//kagolug2025.09/slide/matoken-slide.pdf:19:ActivityPubも少し探したが,自分とサーバーの落ちているものしか
/home/matoken/Nextcloud_matoken@files.matoken.org/Linux/2025//kagolug2025.10/slide/slide.pdf:10:     2     サーバー設定ファイルを編集."protocol" を "http"

オプションの詳細は以下を.

これまではpdf ファイルをpdftotext などでテキストに変換しつつgrep などしていましたがこれだとどのページ化が分かりづらかったです.pdfgrep だと -n オプションが行数ではなくページ数になるのでこのあたりがわかりやすくなって良さそうです.

$ pdftotext ~/Downloads/RetroBSD_and_LiteBSD.pdf - | grep -m5 -n -i retro
1:RetroBSD and LiteBSD:
15:  Contributing to RetroBSD since 2013
30:  RetroBSD: an OS from the past in 128k RAM
35:
   RetroBSD and LiteBSD: an overview
39:  RetroBSD: PIC32MX
$ pdfgrep -m5 -n -i retro ~/Downloads/RetroBSD_and_LiteBSD.pdf
1:RetroBSD and LiteBSD:
3:  Contributing to RetroBSD since 2013
4:  RetroBSD: an OS from the past in 128k RAM
5:RetroBSD and LiteBSD: an overview
5:     RetroBSD: PIC32MX

と,一通り遊んでから気づいたのですが,debian にはpdfgrep パッケージが結構前から存在していました.

$ apt-cache search pdfgrep
pdfgrep - 正規表現にマッチする文字列を pdf ファイル内で検索
$ rmadison pdfgrep
pdfgrep    | 2.1.2-1       | oldoldstable   | source, amd64, arm64, armhf, i386
pdfgrep    | 2.1.2-1       | oldstable      | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
pdfgrep    | 2.2.0-0.1     | stable         | source
pdfgrep    | 2.2.0-0.1     | testing        | source
pdfgrep    | 2.2.0-0.1     | unstable       | source
pdfgrep    | 2.2.0-0.1     | unstable-debug | source
pdfgrep    | 2.2.0-0.1+b2  | stable         | amd64, arm64, armel, armhf, i386, ppc64el, riscv64, s390x
pdfgrep    | 2.2.0-0.1+b2  | testing        | amd64, arm64, armhf, i386, ppc64el, riscv64, s390x
pdfgrep    | 2.2.0-0.1+b2  | unstable       | amd64, arm64, armhf, i386, ppc64el, riscv64, s390x
$ sudo apt install pdfgrep
$ /usr/bin/pdfgrep -V
This is pdfgrep version 2.2.0.

Using poppler version 25.03.0
Using libpcre2 version 10.46 2025-08-27
環境
$ pdfgrep -V
This is pdfgrep version 2.2.0.

Using poppler version 25.03.0
Using libpcre2 version 10.46 2025-08-27
Built from git-commit v2.2.0-7-gaa71955
$ /usr/bin/pdfgrep -V
This is pdfgrep version 2.2.0.

Using poppler version 25.03.0
Using libpcre2 version 10.46 2025-08-27
$ dpkg-query -W poppler-utils
poppler-utils   25.03.0-11.1+b1
$ pdftotext -v
pdftotext version 25.03.0
Copyright 2005-2025 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011, 2022 Glyph & Cog, LLC
$ lsb_release -dr
Description:    Debian GNU/Linux forky/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2025/12/05/pdfgrep/feed/ 0
PCManFM-Qt のコンテキストメニューにカスタム項目を追加 https://matoken.org/blog/2025/12/04/pcmanfm-qt-custom-actions/ https://matoken.org/blog/2025/12/04/pcmanfm-qt-custom-actions/#respond Thu, 04 Dec 2025 11:00:13 +0000 https://matoken.org/blog/?p=4778

pcmanfm qt icon

最近ファイルマネージャーにPCManFM-Qt を利用しています.

naitilus だとコンテキストメニューにカスタムスクリプトを設定できて便利だったのでPCManFM-Qt でも出来ないかなと調べてみました.

公式ドキュメントが見えたら無かったので以下のあたりを参考にしました.

~/.local/share/file-manager/actions/ 以下に .desktop ファイルを作成して実現できるようです.

ディレクトリの作成
$ mkdir -p ~/.local/share/file-manager/actions/

次にやりたいことを.decktop ファイルに書きます.

~/.local/share/file-manager/actions/fuse-archive.desktop
[Desktop Entry]
Type=Action
Profiles=profile_id
Name=archive file mount
Icon=application-default-icon

[X-Action-Profile profile_id]
MimeTypes=application/*;
Exec=fuse-archive %f

MimeTypes に書いたtype に一致するときに表示されるようなのでちゃんと書いたほうがいいのですが,今回は対象がアーカイブファイルで対象ファイルが大量ですとりあえず MimeTypes=application/*; にしておきました.

この後PCManFM-Qt を起動し直すと該当の .desktop が認識され,利用できるようになります.
nautilug は即反映されていたので少し面倒ですね.

pcmanfm qt fuse archive

環境
$ dpkg-query -W pcmanfm-qt
pcmanfm-qt      2.2.0-1
$ fuse-archive --version
fuse-archive version: 1.7
libarchive version: libarchive 3.7.4
bzlib version: 1.0.8, 13-Jul-2019
liblz4 version: 1.10.0
liblzma version: 5.8.1
libzstd version: 1.5.7
zlib version: 1.3.1
FUSE library version: 2.9.9
fusermount3 version: 3.17.4
using FUSE kernel interface version 7.19
$ lsb_release -dr
Description:    Debian GNU/Linux forky/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2025/12/04/pcmanfm-qt-custom-actions/feed/ 0
かわいいcli 天気アプリのstarlit https://matoken.org/blog/2025/12/03/cute-cli-weather-app-starlit/ https://matoken.org/blog/2025/12/03/cute-cli-weather-app-starlit/#respond Tue, 02 Dec 2025 21:22:00 +0000 https://matoken.org/blog/?p=4769

小さく可愛いCLI 天気アプリケーションのstarlit を少し試してみました.
starlit はPython製,ライセンスは不明です.

pipx で導入しました.

$ pipx install starlit-cli
  installed package starlit-cli 0.2.3, installed using Python 3.13.9
  These apps are now globally available
    - starlit
done! ✨ 🌟 ✨
$ starlit --help

Starlit is a minimal, cute and customizable weather cli.
Weather forecasts, beautifully styled for your terminal!

USAGE


  starlit [city] [--flags]


EXAMPLES


   # Get weather for default city
   starlit

   # Get weather for a specific city
   starlit tokyo

   # Start interactive mode
   starlit --interactive


FLAGS

  -s --setup                Create configuration folder with .env file
  -e --edit                 Open configuration file in default editor
  -c --config               View configuration settings in terminal
  -i --interactive          Start interactive mode
  -v --version              Show starlit version
  -h --help                 Show this help message

--setup オプションで設定ファイルを設定します.設定ファイルは $HOME/.config/starlit/.env に作られます.

$ starlit --setup

 DONE  Config created at `/home/matoken/.config/starlit/.env`

Would you like to edit the config now? (y/n): y

 EDIT  Opened .env file in default editor

設定ファイルを編集して最低限 API_KEY (OpenWeatherMap API key) と DEFAULT_CITY (既定値の都市)を指定します.

OpenWeatherMap API key は以下から,

都市は以下のあたりで確認します.

実行します.実際はカラフルでアニメーションで表示されます.

$ starlit

Forecast for Kanoya, JP ☁

               weather  ›   cloudy (16.1°C)
    .--.      sunset   ›   05:13 PM
  .-(    ).    wind     ›   13.6 km/h ↖
 (___.__)__)   humidity ›   72%
               precip   ›   0mm | 0%

Tue. Dec 2  07:26 PM (gmt+9)

 🐻 MSG  a chill playlist kinda day

starlit

オプションや環境変数で都市を指定すると特定の都市が表示されます.

starlit shibushi

その他interactive mode も.

いつもは類似アプリとしてwego を利用することが多いのですがstarlit も良さそうです.天気プロバイダが増えると便利かもです.

環境
$ starlit --version

 V0.2.3  starlit version
$ dpkg-query -W pipx python3
pipx    1.8.0-1
python3 3.13.7-1
$ lsb_release -dr
Description:    Debian GNU/Linux forky/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2025/12/03/cute-cli-weather-app-starlit/feed/ 0
Pandoc 3.8.3 でasciidoc 入力に対応 https://matoken.org/blog/2025/12/01/pandoc-3-8-3-now-supports-asciidoc-input/ https://matoken.org/blog/2025/12/01/pandoc-3-8-3-now-supports-asciidoc-input/#respond Mon, 01 Dec 2025 14:20:48 +0000 https://matoken.org/blog/?p=4747

たくさんの文章形式に対応した文章変換ツールのPandoc のバージョン3.8.3 がリリースされました.
個人的にはasciidoc 形式の入力対応が嬉しいです.

Add asciidoc as an input format (#1456).

個人的にasciidoc 形式は好きなのですが,これまでPandoc ではasciidoc への変換は出来てもasciidoc からの変換が出来ないという一方通行でしたがこれで相互変換できそうです.

これまでのpandoc のasciidoc 対応状況
$ pandoc --version
pandoc 3.1.11.1
Features: -server +lua
Scripting engine: Lua 5.4
User data directory: /home/matoken/.local/share/pandoc
Copyright (C) 2006-2023 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
$ pandoc --list-input-formats | grep -i asciidoc
$ pandoc --list-output-formats | grep -i asciidoc
asciidoc
asciidoc_legacy
asciidoctor

早速pandoc 3.8.3 を試します.
とりあえずGitHub Releases の.deb を’もらってきて導入.

$ wget -c https://github.com/jgm/pandoc/releases/download/3.8.3/pandoc-3.8.3-1-amd64.deb (1)
$ sha256sum pandoc-3.8.3-1-amd64.deb  (2)
d7fac78b58b8c8da39254955eff321233ab97d74e8b2d461c0f0719a1fb5f357  pandoc-3.8.3-1-amd64.deb
$ sudo apt install ./pandoc-3.8.3-1-amd64.deb (3)
$ which pandoc
/usr/bin/pandoc
$ pandoc -v (4)
pandoc 3.8.3
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/matoken/.local/share/pandoc
Copyright (C) 2006-2025 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
$ pandoc --list-input-formats | grep -i asciidoc (5)
asciidoc
$ pandoc --list-output-formats | grep -i asciidoc
asciidoc
asciidoc_legacy
asciidoctor
$ pandoc slide/slide.adoc -o /tmp/out.pdf -f asciidoc -t pdf --pdf-engine=weasyprint (6)
  1. pandoc debian amd64 package を入手

  2. hash 確認

  3. system に導入

  4. バージョン確認

  5. 入力フォーマットにasciidoc があるのを確認

  6. 適当なasciidoc をpdf に変換してみる

asciidoc からpdf への変換が出来ました.

pandoc 3.8.3 adoc2pdf

ちなみに現時点での対応フォーマットは入力51,出力75 のようです.この中にはhtml/html4/html5 のようなバージョン違いのようなものも含まれます.

$ pandoc --list-input-formats | wc -l
51
$ pandoc --list-output-formats | wc -l
75

ということでこれまでも便利だったPandoc ですがasciidoc 入力対応でまた一つ便利になりました.

環境
$ pandoc -v
pandoc 3.8.3
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/matoken/.local/share/pandoc
Copyright (C) 2006-2025 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
$ dpkg-query -W pandoc
pandoc  3.8.3-1
$ lsb_release -dr
Description:    Debian GNU/Linux forky/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2025/12/01/pandoc-3-8-3-now-supports-asciidoc-input/feed/ 0
tmux 3.6 リリース https://matoken.org/blog/2025/11/27/tmux-3-6-release/ https://matoken.org/blog/2025/11/27/tmux-3-6-release/#respond Thu, 27 Nov 2025 10:05:18 +0000 https://matoken.org/blog/?p=4741

ターミナルマルチプレクサのtmux 3.6 が出ていました.

早速ビルドしてみます.今回はgit リポジトリから導入します.
$ git pull
$ git checkout 3.6
$ ./autogen.sh
$ ./configure --enable-sixel --prefix=$HOME/usr/local (1)
$ make
$ ./tmux -V
tmux 3.6
  1. sixel を有効にし,$HOME/usr/local 以下に導入

tmux が起動しない?旧tmux が生きていたせいでした.
$ ./tmux
open terminal failed: not a terminal
$ pgrep tmux
14030
$ tmux kill-server
$ ./tmux
$ ./tmux kill-server
intall
$ make install
$ which tmux
/home/matoken/local/bin/tmux
$ tmux -V
tmux 3.6

tmux 3.6

環境
$ tmux -V
tmux 3.6
$ dpkg-query -W autoconf automake pkg-config libevent-dev ncurses-bin
autoconf        2.72-3.1
automake        1:1.18.1-3
libevent-dev    2.1.12-stable-10+b1
ncurses-bin     6.5+20251123-1
pkg-config:amd64        1.8.1-4
$ lsb_release -dr
Description:    Debian GNU/Linux forky/sid
Release:        n/a
$ arch
x86_64
追記

Debian sid にtmux 3.6 が降りてきました.sixel も有効になっています.パッケージ名にaがつくのはなんでだろう?tmux 3.5a が存在したようにtmux 3.6a がリリースされたら当たりそうだなとも.

$ /usr/bin/tmux -V
tmux 3.6
$ zgrep -B99 -m1 — – /usr/share/doc/tmux/NEWS.Debian.gz
tmux (3.6a-1) unstable; urgency=medium

Please restart tmux entirely after upgrading to 3.6: an old server and
a new client will not be fully compatible with each other and the new
client may hang.
Note: if necessary the old client can be used via /proc/pid/exe to
talk to the old server, e.g. `/proc/$(pgrep "tmux: server")/exe attach'.
 -- Sébastien Delafond <seb@debian.org>  Mon, 01 Dec 2025 16:44:38 +0100
$ rmadison tmux
tmux       | 3.1c-1+deb11u1 | oldoldstable              | source, amd64, arm64, armhf, i386
tmux       | 3.1c-1+deb11u1 | oldoldstable-debug        | source
tmux       | 3.3a-3         | oldstable                 | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
tmux       | 3.5a-2~bpo12+1 | oldstable-backports       | source, amd64, arm64, armel, armhf, i386, mips64el, mipsel, ppc64el, s390x
tmux       | 3.5a-2~bpo12+1 | oldstable-backports-debug | source
tmux       | 3.5a-3         | stable                    | source, amd64, arm64, armel, armhf, i386, ppc64el, riscv64, s390x
tmux       | 3.5a-3         | testing                   | source, amd64, arm64, armhf, i386, ppc64el, riscv64, s390x
tmux       | 3.6a-2         | unstable                  | source, amd64, arm64, armhf, i386, ppc64el, riscv64, s390x
tmux       | 3.6a-2         | unstable-debug            | source
]]>
https://matoken.org/blog/2025/11/27/tmux-3-6-release/feed/ 0
VSCode拡張機能の手動ダウンロード https://matoken.org/blog/2025/10/09/manual-download-of-vscode-extensions/ https://matoken.org/blog/2025/10/09/manual-download-of-vscode-extensions/#respond Thu, 09 Oct 2025 10:39:27 +0000 https://matoken.org/blog/?p=4721

Microsoftの開発しているVisual Studio Code というElectron製のマルチプラットホームで無料のコーディング向けテキストエディタがあります.
ソースコードはMITライセンスにて公開されていますが,Microsoftで公開しているバイナリはプロプライエタリ・ソフトウェアだったりテレメトリーが埋め込まれていたりします.
VSCodeは拡張機能により様々な機能が追加できるのですが,オフライン環境や,VSCodeからフォークされたVSCodiumではVSCodeの拡張機能が配布されているVSCode Marketplaceに規定値ではアクセスできません.
VSCodiumの場合,オープンプラットフォームなVSCode拡張機能配布サイトのOpen VSX Registryが有効になっているのでここから入手できる拡張機能も多いですが.VSCode Marketplaceで歯科公開されていない拡張機能もあります.
そういった場合,以前は拡張機能のファイルである .vsix ファイルをVS VSCode Marketplaceよりダウンロードして導入することができました.

最近同様にダウンロードしようとしたところダウンロードリンクが消えていました.

VSCode extention old
Figure 1. 2024-09-19時のスクリーンショット.バージョン毎にダウンロードリンクがあった.
VSCode extention now
Figure 2. 2025-10-08時のスクリーンショット.ダウンロードリンクがなくなっている.

これは困るなと少し調べるとRedditでやはり困っている方が.

いくつか回答がありますが,おてがるそうなのがこのUserScritpを利用する方法.

拡張機能ページに(最新の) .vsix ダウンロードリンクが作られます.このリンクからダウンロードして,VSCodeやVSCodiumに導入が可能です.

VSCode userscript download
Figure 3. UserScriptにてダウンロードリンクが作られた.
VSCode userscript downloading
Figure 4. ダウンロード中はプログレスが表示される.
VSCodium extention install
Figure 5. VSCodiumに .vsix から拡張機能を導入.

Redditの投稿は9ヶ月前.結構前に消えていたんですね.

環境
$ codium --version
1.104.36664
3af140d2498acc8743822d23d4171fe1eac449ec
x64
$ lsb_release -dr
Description:    Debian GNU/Linux 13 (trixie)
Release:        13
$ arch
]]>
https://matoken.org/blog/2025/10/09/manual-download-of-vscode-extensions/feed/ 0
asciinema 3.0とRaspberry Pi armhf環境でのビルド https://matoken.org/blog/2025/09/23/building-in-asciinema-3-0-and-raspberry-pi-armhf-environments/ https://matoken.org/blog/2025/09/23/building-in-asciinema-3-0-and-raspberry-pi-armhf-environments/#comments Mon, 22 Sep 2025 22:08:00 +0000 https://matoken.org/blog/?p=4703

asciinema logo red

ターミナルの録画再生共有などができるソフトウェアのasciinemaの3.0がリリースされました.
今回のリリースはrustで書き直され,ファイル形式も新しくなったようです.(asciicast v3 file format)また,ターミナルのウェブによるライブストリーミング機能も付きました.

自分のDebian環境ではパッケージ度導入しているのですが,出たばかりなのでunstableでも2.4.0です.

$ rmadison asciinema
asciinema  | 2.0.2-2       | oldoldstable | source, all
asciinema  | 2.2.0-1       | oldstable    | source, all
asciinema  | 2.4.0-1       | stable       | source, all
asciinema  | 2.4.0-1       | testing      | source, all
asciinema  | 2.4.0-1       | unstable     | source, all

LinuxではReleasesページにx86_64, aarch64のバイナリが用意されています.

armhfでのビルド

Raspberry Pi OS bookworm armhf環境でビルドを試してみました.

パッケージで導入したRustが古いようです,rust 1.66以降が必要そうです.

$ git clone https://github.com/asciinema/asciinema
$ cd asciinema
$ cargo build --release
  :
error: package `toml v0.8.23` cannot be built because it requires rustc 1.66 or newer, while the currently active rustc version is 1.63.0
Either upgrade to rustc 1.66 or newer, or use
cargo update -p toml@0.8.23 --precise ver
where `ver` is the latest version of `toml` supporting rustc 1.63.0

以下のManual installationからarmv7-unknown-linux-gnueabihf版のrustup-initを入手します.

$ wget https://static.rust-lang.org/rustup/dist/armv7-unknown-linux-gnueabihf/rustup-init
    https://static.rust-lang.org/rustup/dist/armv7-unknown-linux-gnueabihf/rustup-init.sha256
$ sha256sum --check rustup-init.sha256
./rustup-init: OK
$ chmod u+x ./rustup-init

rustup-initコマンドを実行して新しいrustを導入します.

$ ./rustup-init
  :
Continue? (y/N) y
1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>1
  :
info: installing component 'rustfmt'
info: default toolchain set to 'stable-armv7-unknown-linux-gnueabihf'

  stable-armv7-unknown-linux-gnueabihf installed - rustc 1.90.0 (1159e78c4 2025-09-14)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, you need to source
the corresponding env file under $HOME/.cargo.

This is usually done by running one of the following (note the leading DOT):
. "$HOME/.cargo/env"            # For sh/bash/zsh/ash/dash/pdksh
source "$HOME/.cargo/env.fish"  # For fish
source $"($nu.home-path)/.cargo/env.nu"  # For nushell

バージョンを確認します.最近リリースされた1.90.0が使えるようになりました.

$ which cargo
/usr/bin/cargo
$ /usr/bin/cargo -V
cargo 1.65.0
$ ~/.cargo/bin/cargo -V
warning: `/home/matoken/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
cargo 1.90.0 (840b83a10 2025-07-30)

rust 1.90.0を使って再度asciinemaをbuildします.今度は成功.

$ PATH=~/.cargo/bin:$PATH cargo build --release

    Finished `release` profile [optimized] target(s) in 39m 49s

asciinemaのusageとversionを確認.3.0.0になっています.

$ target/release/asciinema
Terminal session recorder, streamer, and player

Usage: asciinema [OPTIONS] <COMMAND>

Commands:
  record   Record a terminal session [aliases: rec]
  stream   Stream a terminal session
  session  Record and stream a terminal session
  play     Play back a terminal session
  upload   Upload a recording to an asciinema server
  auth     Authenticate this CLI with an asciinema server account
  cat      Concatenate multiple recordings
  convert  Convert a recording to another format
  help     Print this message or the help of the given subcommand(s)

Options:
  -q, --quiet    Quiet mode - suppress diagnostic messages
  -h, --help     Print help (see more with '--help')
  -V, --version  Print version

$ target/release/asciinema --version
asciinema 3.0.0

asciinema 3,0を試す

ライブストリーミング機能を試す

新機能のライブストリーミング機能を試します.
ローカルとリモートが選べます.

$ target/release/asciinema stream
error: the following required arguments were not provided:
  <--local [<IP:PORT>]|--remote [<STREAM-ID|WS-URL>]>

Usage: asciinema stream <--local [<IP:PORT>]|--remote [<STREAM-ID|WS-URL>]>

For more information, try '--help'.
$ target/release/asciinema stream -h
Stream a terminal session

Usage: asciinema stream [OPTIONS] <--local [<IP:PORT>]|--remote [<STREAM-ID|WS-URL>]>

Options:
  -l, --local [<IP:PORT>]            Stream via the local HTTP server
  -r, --remote [<STREAM-ID|WS-URL>]  Stream via remote asciinema server
  -c, --command <COMMAND>            Command to start in the session [default: $SHELL]
  -I, --capture-input                Enable input (keyboard) capture
      --capture-env <VARS>           Comma-separated list of environment variables to capture
                                     [default: SHELL]
  -t, --title <TITLE>                Title of the session
      --headless                     Headless mode - don't use the terminal for I/O
      --window-size <COLSxROWS>      Override session's terminal window size
      --return                       Return the session's exit status
      --log-file <PATH>              Log file path
      --server-url <URL>             asciinema server URL
  -q, --quiet                        Quiet mode - suppress diagnostic messages
  -h, --help                         Print help (see more with '--help')

Examples:

  asciinema stream --local
      Streams a shell session via the local HTTP server listening on an ephemeral port on 127.0.0.1

  asciinema stream --local 0.0.0.0:8080
      Streams via the local HTTP server listening on port 8080 on all network interfaces

  asciinema stream --remote
      Streams via an asciinema server for public viewing

  asciinema stream -l -r
      Streams both locally and remotely simultaneously

  asciinema stream -r --command "ping asciinema.org"
      Streams execution of the ping command

  asciinema stream -r <ID> -t "Live coding"
      Streams via a remote server, reusing the existing stream ID and setting the stream title

まずはローカルを試します.既定値ではlocalhostしか使えないようなのでlan内で使えるようにipアドレスと適当なportを指定して起動します.

$ target/release/asciinema stream --local 10.42.0.253:9999
::: asciinema session started
::: Live streaming at http://10.42.0.253:9999
::: Press <ctrl+d> or type 'exit' to end
$ ^d
exit
::: asciinema session ended

この状態でウェブブラウザで Live streaming at の後ろのアドレスにアクセスするとasciinema端末のストリーミングが表示されます.

asciinema stream local

次はリモート.
初回は認証が必要です.authサブコマンドを実行したときに表示されるurlにアクセスして認証します.

$ target/release/asciinema auth
Open the following URL in a web browser to authenticate this CLI with your asciinema.org user account:

https://asciinema.org/connect/abc123de-f345-7890-1234-abc123def456

This will associate all recordings uploaded from this machine with your account (including past uploads), and enable public live streaming via asciinema.org.

リモートサーバは未指定時の既定値ではasciinema.orgが利用されます.

$ target/release/asciinema stream --remote
::: asciinema session started
::: Live streaming at https://asciinema.org/s/aBcDeFgHiJkLmNoP
::: Press <ctrl+d> or type 'exit' to end

この状態でウェブブラウザで Live streaming at の後ろのアドレスにアクセスするとasciinema.orgで端末のストリーミングが表示されます.

閲覧のみですがデモにいい感じそうです.

録画と再生

以前は録画時にリモートにアップロードすると録画ファイルは消えていましたが,asciinema 3.0ではローカルにファイルが残るようになっています.
また,録画形式もasciicast v2, asciicast v3(default), raw, txtから選べるようになっています.基本的に規定値のasciicast v3形式でいいでしょうが,セルフホスト環境などでv3非対応の場合などはv2形式にする感じでしょうか.もしv3で録画したあとv2が必要だった(もしくはその逆)の場合でも後述の変換コマンドで相互変換が可能です.

$ target/release/asciinema rec -h                                                                                                                [4/1462]
Record a terminal session

Usage: asciinema record [OPTIONS] <FILE>

Arguments:
  <FILE>  Output file path

Options:
  -f, --output-format <FORMAT>   Output file format [default: asciicast-v3] [possible values:
                                 asciicast-v3, asciicast-v2, raw, txt]
  -c, --command <COMMAND>        Command to start in the session [default: $SHELL]
  -I, --capture-input            Enable input (keyboard) capture
      --capture-env <VARS>       Comma-separated list of environment variables to capture [default:
                                 SHELL]
  -a, --append                   Append to an existing recording file
      --overwrite                Overwrite the output file if it already exists
  -t, --title <TITLE>            Title of the recording
  -i, --idle-time-limit <SECS>   Limit idle time to a given number of seconds
      --headless                 Headless mode - don't use the terminal for I/O
      --window-size <COLSxROWS>  Override session's terminal window size
      --return                   Return the session's exit status
      --log-file <PATH>          Log file path
  -q, --quiet                    Quiet mode - suppress diagnostic messages
  -h, --help                     Print help (see more with '--help')

Examples:

  asciinema rec demo.cast
      Records a shell session to a file

  asciinema rec --command "python script.py" demo.cast
      Records execution of a Python script

  asciinema rec --idle-time-limit 2 demo.cast
      Records with idle time capped at 2 seconds

  asciinema rec --capture-input --title "API Demo" demo.cast
      Records with keyboard input and sets a title

  asciinema rec --append demo.cast
      Continues recording to an existing file

  asciinema rec demo.txt
      Records as a plain-text log - output format inferred from the .txt extension

録画してみる.

$ target/release/asciinema rec hello-asciinema3.0.cast
::: asciinema session started
::: Recording to hello-asciinema3.0.cast
::: Press <ctrl+d> or type 'exit' to end
$
$ ^d
exit
::: asciinema session ended
::: Recorded to hello-asciinema3.0.cast

録画ファイルから再生.

$ target/release/asciinema play hello-asciinema3.0.cast
::: Replaying session from hello-asciinema3.0.cast
$
exit
::: Playback ended

録画ファイルのasciinema.orgへのアップロード

asciicast v1, v2, v3形式のファイルをasciinemaサーバにアップロードします.今回は既定値のasciinema.orgへアップロードします.

$ target/release/asciinema upload -h
Upload a recording to an asciinema server

Usage: asciinema upload [OPTIONS] <FILE>

Arguments:
  <FILE>  The path to the asciicast recording file to upload, in a supported asciicast format (v1,
          v2, or v3)

Options:
      --server-url <URL>  asciinema server URL
  -q, --quiet             Quiet mode - suppress diagnostic messages
  -h, --help              Print help (see more with '--help')

録画ファイルを指定してアップロードします.成功したら共有urlが表示されます.

$ target/release/asciinema upload hello-asciinema3.0.cast
View the recording at:

    https://asciinema.org/a/OyMKojer2JRgnQbICxZ14mmKC
Tip

大きなファイルはアップロードに失敗します.asciinema serverをセルフホストしたり,asciinema playerをセルフホストすることで大きなファイルを共有することが可能です.

asciicast形式の変換

asciinema 3.0でファイル形式がasciicast v3になりました.
convertコマンドでasciicast v1, v2, v3を相互に変換可能になっています.また,rawからのasciicast形式への変換もできるようです.以前は別のサードパーティツールを使っていましたがasciinemaコマンドだけで完結できるようになったようです.

$ target/release/asciinema convert -h
Convert a recording to another format

Usage: asciinema convert [OPTIONS] <INPUT> <OUTPUT>

Arguments:
  <INPUT>   The source recording to convert. Can be a local file path, HTTP(S) URL for remote files,
            or '-' to read from standard input. Remote URLs allow converting recordings directly
            from the web without need for manual downloading. Supported input formats include
            asciicast v1, v2 and v3
  <OUTPUT>  The output path for the converted recording. Can be a file path or '-' to write to
            standard output

Options:
  -f, --output-format <FORMAT>  Output file format [default: asciicast-v3] [possible values:
                                asciicast-v3, asciicast-v2, raw, txt]
      --overwrite               Overwrite the output file if it already exists
  -q, --quiet                   Quiet mode - suppress diagnostic messages
  -h, --help                    Print help (see more with '--help')

Examples:

  asciinema convert old.cast new.cast
      Converts a recording to the latest asciicast format (v3)

  asciinema convert demo.cast demo.txt
      Exports a recording as a plain-text log - output format inferred from the .txt extension

  asciinema convert --output-format raw demo.cast demo.txt
      Exports as raw terminal output

  asciinema convert -f txt demo.cast -
      Exports as plain text to stdout

  asciinema convert https://asciinema.org/a/569727 starwars.cast
      Downloads a remote recording and converts it to the latest asciicast format (v3)

変換してみます.

asciicast v3からv2へ変換
$ target/release/asciinema convert --output-format asciicast-v2 hello-asciinema3.0.cast hello-asciinema3.0.v2.cast
asciicast v2からv3へ変換
$ target/release/asciinema convert --output-format asciicast-v3 hello-asciinema3.0.v2.cast hello-asciinema3.0.v3.cast

変換後のファイルをplayコマンドで再生してみると問題なく再生できました.

おわりに

asciinema 3.0がリリースされました.標準でローカルに録画ファイルが残るようになったり,ストリーミング機能,ファイル形式変換機能が便利そうです.
その他asciicast v3形式に対応したplayerも試してみたいところです.

]]>
https://matoken.org/blog/2025/09/23/building-in-asciinema-3-0-and-raspberry-pi-armhf-environments/feed/ 1
docker pullの最大同時ダウンロード数を変更する https://matoken.org/blog/2025/08/21/change-the-maximum-number-of-simultaneous-downloads-for-docker-pull/ https://matoken.org/blog/2025/08/21/change-the-maximum-number-of-simultaneous-downloads-for-docker-pull/#respond Wed, 20 Aug 2025 23:08:34 +0000 https://matoken.org/blog/?p=4695

最近は楽天モバイルを常用しているのですが,auローミングエリアかつ電波が弱いのもあってADSLの頃よりも遅く不安定な回線です,
更に土日休日,朝昼晩と速度が落ちます.
てことでdocker pullなどは深夜帯にやったりしているのですが最近はそれでも駄目な感じに.

pull時の色々なエラー

なんだかバリエーションに富んだエラーが出て楽しくなってきました.
これは昨日試した時の何度か分です.

error pulling image configuration: download failed after attempts=6: net/http: TLS handshake timeout
EOF
error pulling image configuration: download failed after attempts=6: dial tcp [2600:1f18:2148:bc02:9ace:ab18:c47e:e0a5]:443: i/o timeout
 ✘ sockpuppetbrowser Error Get "https://registry-1.docker.io/v2/": net/http: TLS handshake timeout                                                                                                                                       10.1s
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: TLS handshake timeout
 ✘ browser-chrome Error   Head "https://registry-1.docker.io/v2/selenium/standalone-chrome/manifests/4": Get "https://auth.docker.io/token?scope=repository%3Aselenium%2Fstandalone-chrome%3Apull&service=regist...                      23.5s
 ✔ changedetection Pulled
                                                                                                                                       21.3s
Error response from daemon: Head "https://registry-1.docker.io/v2/selenium/standalone-chrome/manifests/4": Get "https://auth.docker.io/token?scope=repository%3Aselenium%2Fstandalone-chrome%3Apull&service=registry.docker.io": net/http: requ
est canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
error pulling image configuration: download failed after attempts=6: net/http: TLS handshake timeout
Get "https://registry-1.docker.io/v2/selenium/standalone-chrome/manifests/sha256:553ff18c2055bc2134cd833211c352d601d91f43fd42a7559f94a28eba96a504": EOF
Get "https://registry-1.docker.io/v2/selenium/standalone-chrome/manifests/sha256:553ff18c2055bc2134cd833211c352d601d91f43fd42a7559f94a28eba96a504": EOF
dial tcp: lookup auth.docker.io: Temporary failure in name resolution
error pulling image configuration: download failed after attempts=6: dial tcp: lookup registry-1.docker.io: i/o timeout
error pulling image configuration: download failed after attempts=6: dial tcp: lookup registry-1.docker.io: i/o timeout
 ✘ sockpuppetbrowser Error Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)                                                              15.0s
 ! browser-chrome          Interrupted                                                                                                                                                                                                   15.0s
 ! changedetection         Interrupted                                                                                                                                                                                                   17.3s
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
Get "https://registry-1.docker.io/v2/selenium/standalone-chrome/blobs/sha256:e34a67f89d25bc77130abb059c42a2c47d18fd489056fa50da057d4b51507fac": dial tcp: lookup registry-1.docker.io: i/o timeout

ダウンロード並列数を変更する

ダウンロードは複数並列で動き,失敗したコンテナは再実行時始めら開始されます.
以下のように結構いいとこまで行っても失敗するとまたはじめからで悲しいです.

   ⠹ e34a67f89d25 Downloading [========================================>          ]  131.6MB/164.3MB                                                                                                                                    284.2s

ということでダウンロード並列数を減らしたり, wget -continue のようにダウンロード途中から再開する機能が欲しいところ.

検索して以下のページに --max-concurrent-downloads というオプションが紹介されていました.

設定ファイルに書くこともできるようです.

この設定でダウンロード並列数を既定値の3から1にしてみます.

/etc/docker/daemon.json を編集,存在しない場合は新規作成して同時ダウンロード数を1にしてデーモンを再起動しました.

$ ls -lA /etc/docker/ (1)
合計 8
-rw------- 1 root root 244  7月 19  2024 key.json
$ umask 0077 (2)
$ umask
0077
$ echo '{
    "max-concur-downloads": 1
}' | sudo tee /etc/docker/daemon.json (3)
{
    "max-concurrent-downloads": 1
}
$ ls -lA /etc/docker/
合計 8
-rw------- 1 root root  38  8月 21 07:01 daemon.json
-rw------- 1 root root 244  7月 19  2024 key.json
$ sudo systemctl restart docker (4)
  1. daemon.json は存在しない状態

  2. 他のファイルとパーミッションを合わせるためにumaskを設定

  3. ダウンロード並列数を1にする設定をdaemon.jsonに

  4. dockerデーモン再起動

デーモン再起動後再度pullを試みると最後まで動作しました.

$ docker compose --file ./docker-compose.yml pull
[+] Pulling 43/43
 ✔ sockpuppetbrowser Pulled                                                                                                                                                                                                               3.5s
 ✔ browser-chrome Pulled                                                                                                                                                                                                               1394.0s
   ✔ b71466b94f26 Already exists                                                                                                                                                                                                          0.0s
   ✔ e34a67f89d25 Already exists                                                                                                                                                                                                          0.0s
   ✔ 75d85e0261db Already exists                                                                                                                                                                                                          0.0s
   ✔ 939d8ca73113 Already exists                                                                                                                                                                                                          0.0s
   ✔ 6186010a47ee Already exists                                                                                                                                                                                                          0.0s
   ✔ 27714f768b43 Already exists                                                                                                                                                                                                          0.0s
   ✔ 916b96ca33ba Already exists                                                                                                                                                                                                          0.0s
   ✔ 04aa3410ccc8 Already exists                                                                                                                                                                                                          0.0s
   ✔ bdb59075b1d5 Already exists                                                                                                                                                                                                          0.0s
   ✔ 2df770ff8fc0 Already exists                                                                                                                                                                                                          0.0s
   ✔ 54ac28d956cc Already exists                                                                                                                                                                                                          0.0s
   ✔ c44f6dc55fed Already exists                                                                                                                                                                                                          0.0s
   ✔ 5aff9b4a47b1 Already exists                                                                                                                                                                                                          0.0s
   ✔ b1b7bf4d2165 Already exists                                                                                                                                                                                                          0.0s
   ✔ 24f77931a43f Already exists                                                                                                                                                                                                          0.0s
   ✔ 6c2a20e23e29 Already exists                                                                                                                                                                                                          0.0s
   ✔ 1876ab010adb Already exists                                                                                                                                                                                                          0.0s
   ✔ 3e2e63824644 Already exists                                                                                                                                                                                                          0.0s
   ✔ 422e43c124fc Already exists                                                                                                                                                                                                          0.0s
   ✔ 2f170438d2dd Already exists                                                                                                                                                                                                          0.0s
   ✔ b2b509664d5c Pull complete                                                                                                                                                                                                         649.2s
   ✔ d1699bb66466 Pull complete                                                                                                                                                                                                         815.8s
   ✔ 5c8f9ce7ebce Pull complete                                                                                                                                                                                                         821.8s
   ✔ 597064b9d874 Pull complete                                                                                                                                                                                                         826.8s
   ✔ 34893f441ecf Pull complete                                                                                                                                                                                                         828.3s
   ✔ 9e5143f86271 Pull complete                                                                                                                                                                                                         829.8s
   ✔ 84388cffd066 Pull complete                                                                                                                                                                                                         840.2s
   ✔ 9d6965976ee5 Pull complete                                                                                                                                                                                                        1322.8s
   ✔ 2046aa7c3ddc Pull complete                                                                                                                                                                                                        1322.8s
   ✔ c834abc7e6bf Pull complete                                                                                                                                                                                                        1323.3s
   ✔ 23f3e15ccb79 Pull complete                                                                                                                                                                                                        1324.8s
   ✔ 57a77ef3c897 Pull complete                                                                                                                                                                                                        1353.7s
   ✔ b38fd1040849 Pull complete                                                                                                                                                                                                        1368.1s
   ✔ 18fd3cb83a78 Pull complete                                                                                                                                                                                                        1380.9s
   ✔ ce86c34af927 Pull complete                                                                                                                                                                                                        1383.7s
   ✔ 6efed1a6a8f0 Pull complete                                                                                                                                                                                                        1385.1s
   ✔ 9fc8549fc5d4 Pull complete                                                                                                                                                                                                        1386.5s
   ✔ 1b3b81dbe4ce Pull complete                                                                                                                                                                                                        1388.0s
   ✔ acbe3debc1b0 Pull complete                                                                                                                                                                                                        1389.3s
   ✔ 2b0eb12e590f Pull complete                                                                                                                                                                                                        1390.6s
 ✔ changedetection Pulled
 ----

ということで2日くらい失敗を繰り返していたpullが1回で通りました.
しばらくはこの設定のままにしておこうと思います.


.環境

$ dpkg-query -W docker.io bash
bash 5.2.37-2+b5
docker.io 26.1.5+dfsg1-4+b1
$ lsb_release -dr
Description: Debian GNU/Linux forky/sid
Release: n/a
$ arch
x86_64


]]>
https://matoken.org/blog/2025/08/21/change-the-maximum-number-of-simultaneous-downloads-for-docker-pull/feed/ 0
Zellijのウェブ共有機能を少し試す https://matoken.org/blog/2025/08/12/try-zellijs-web-sharing-feature/ https://matoken.org/blog/2025/08/12/try-zellijs-web-sharing-feature/#respond Tue, 12 Aug 2025 11:26:22 +0000 https://matoken.org/blog/?p=4683

zellij logo small

ターミナルマルチプレクサ,ワークスペースのZellij 0.43.0が2025-08-05にリリースされていました.

気になる新機能としてウェブブラウザでZellijセッションを共有できるようになったようです.Tmateのような感じでしょうか?

Zellij 0.43.0のビルド

$ cargo install --locked zellij

でいいはずですが,sourceからも

$ git clone https://github.com/zellij-org/zellij (1)
$ cd zellij
$ git checkout v0.43.0 (2)
$ cargo xtask make -r (3)
  :
Could not find `protoc` installation and this build crate cannot proceed without (4)
Contthis knowledge. If `protoc` is installed and this crate had trouble finding
    it, you can set the `PROTOC` environment variable with the specific path to your11 [1,328 kB]
  :
$ sudo apt install protobuf-compiler (5)
$ cargo xtask make -r (6)
$ ./target/release/zellij --version (7)
zellij 0.43.0
  1. git でsourceをもらってくる

  2. v0.43.0 branchへ

  3. build

  4. protocが見つからないエラーで失敗

  5. protocはDebian sidではprotobuf-compilerなので導入

  6. 再度build

  7. バージョンの確認

Webサーバ機能を無効にするビルド例

ウェブサーバ機能が必要ない場合は –no-web を付けてビルドする
$ cargo xtask make -r --no-web
$ ./target/release/zellij web
This version of Zellij was compiled without web server support, cannot run web server!

CLIでWebサーバを起動

ウェブサーバ用トークンの作成
$ ./target/release/zellij web --create-token
Created token successfully

token_1: f964e7a4-0c8d-4652-b92f-23168161b3b4
トークンの一覧表示
$ ./target/release/zellij web --list-tokens
token_1: created at 2025-08-11 21:19:18
token_2: created at 2025-08-12 10:35:47
トークンの削除
$ ./target/release/zellij web --revoke-token token_1
Successfully revoked token.
Zellijウェブサーバ起動
$ ./target/release/zellij web
Web Server started on 127.0.0.1 port 8082

ウェブブラウザで http://127.0.0.1:8082/ に接続してトークンを入力してウェブブラウザでZellijが利用可能.

zellij web token
zellij web init
zellij web

結構普通に使えそうです.Zellijでは対応しているSixelはWeb版では未対応のようです.
ngrok経由でAndroidのFirefoxでも試してみるとモバイルブラウザでも動作するようです.でもキーボードとの相性がありそう.
sourceを見るとXterm.jsを利用しているようです.

Zellij上でウェブサーバを起動

Zellij起動中に Ctrl+o s で起動できます.
zellij share

設定でZellij起動時にいつもウェブサーバを起動するようにする

設定ファイルがない場合はディレクトリを作成して書き出し
$ mkdir ~/.config/zellij
$ zellij setup --dump-config > ~/.config/zellij/config.kdl
設定ファイルに web_server true を追記
5$ echo '// WebServer
> web_server true' | tee -a ~/.config/zellij/config.kdl

トンネリングサービスで外部から利用

トンネリングサービスのngrokでZellijのportを指定することで外部仮利用することもできました.

$ ngrok http 8082

好みの類似サービスでもきっと大丈夫です.

おわりに

TmuxフォークのTmateにも同じような機能がありますが,こちらはトンネリングサービスも含まれていたりhttpdだけでなくsshdも使えたり読み取り用セッション,読み書きセッションが選べたりと便利です.
でもUnux哲学的にはバラけていたほうがいいかなとか.それならZellij-nowebにWeb共有アプリ+トンネリングサービスのほうがいいのかなとか思ったりも.
何にせよ選択肢が増えたのは嬉しいですね.

環境
$ ./target/release/zellij --version
zellij 0.43.0
$ dpkg-query -W rustup
rustup  1.27.1-4
$ lsb_release -dr
Description:    Debian GNU/Linux forky/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2025/08/12/try-zellijs-web-sharing-feature/feed/ 0
X11環境でフルスクリーン状態でも時計を表示 https://matoken.org/blog/2025/07/28/display-clock-even-in-full-screen/ https://matoken.org/blog/2025/07/28/display-clock-even-in-full-screen/#respond Sun, 27 Jul 2025 22:46:14 +0000 https://matoken.org/blog/?p=4658

macOSでフルスクリーン状態でもその上に時計を表示するアプリを知りました.昔Linux X11環境でも同じようなことをしていたなと掘り出してみました.

No more hovering just for time checking.

X11ではdzen2という汎用メッセージング及び通知アプリです.

Debian環境ではパッケージがあるのでaptコマンドなどで簡単に導入できます,

$ sudo apt install dzen2

そして例えば以下のようにして右上の辺りに時計を表示できます.

dzen2_x=$((`xrandr | grep \* | cut -f1 -dx` - 100 ))
while :; do
    date +"%H:%M:%S"
    sleep 1
done | dzen2 -p 1 -x ${dzen2_x} -y 12 -fn '12' -bg '#000000' -fg '#FFFFFF'

この状態でFirefoxやmpvでフルスクリーン表示してもその上にdzen2が表示され時計が確認できます.

最近はWaylandが規定値の環境が多いですがその場合は使えないと思います.
デスクトップ環境は$XDG_SESSION_TYPEなどで確認できます.

X11の場合
$ echo $XDG_SESSION_TYPE
x11
Waylandの場合
$ echo $XDG_SESSION_TYPE
wayland
環境
$ dpkg-query -W dzen2 x11-xserver-utils
dzen2   0.9.5+git20130923.488ab66-1
x11-xserver-utils       7.7+11
$ lsb_release -dr
Description:    Debian GNU/Linux 13 (trixie)
Release:        13
$ arch
x86_64
]]>
https://matoken.org/blog/2025/07/28/display-clock-even-in-full-screen/feed/ 0