sayaka – matoken's blog https://matoken.org/blog Is there no plan B? Wed, 24 Dec 2025 21:45:48 +0000 ja hourly 1 https://wordpress.org/?v=6.9 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg sayaka – matoken's blog https://matoken.org/blog 32 32 ターミナル特化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
ttyd でSixel https://matoken.org/blog/2024/01/05/sixel-with-ttyd/ https://matoken.org/blog/2024/01/05/sixel-with-ttyd/#respond Thu, 04 Jan 2024 20:28:20 +0000 https://matoken.org/blog/?p=3954

以前試したターミナルをWebで共有できるttyd のSixel の対応状況を確認してみると1つ前のリリースの 1,7.3 で対応しているようなので少し試してみました.

Sixel support is off by default now, use -t enableSixel=true to enable it.

以前試した時の記事.
* 端末をWeb共有できるttyd – matoken’s meme

オンラインでttyd を使いプレゼンテーションを試みた時のスライド.
* Terminalとウェブブラウザでプレゼンテーションの試み – Speaker Deck

GitHub のRelease にbinary があるけどsource からBuild してみました.

build
$ sudo apt install build-essential cmake git libjson-c-dev libwebsockets-dev
$ git clone https://github.com/tsl0922/ttyd.git
$ cd ttyd && mkdir build && cd build
$ cmake ..
$ make && make install
$ ./ttyd --version
ttyd version 1.7.4-fd280fe
$ ./ttyd
ttyd is a tool for sharing terminal over the web

USAGE:
    ttyd [options] <command> [<arguments...>]

VERSION:
    1.7.4-fd280fe

OPTIONS:
    -p, --port              Port to listen (default: 7681, use `0` for random port)
    -i, --interface         Network interface to bind (eg: eth0), or UNIX domain socket path (eg: /var/run/ttyd.sock)
    -U, --socket-owner      User owner of the UNIX domain socket file, when enabled (eg: user:group)
    -c, --credential        Credential for basic authentication (format: username:password)
    -H, --auth-header       HTTP Header name for auth proxy, this will configure ttyd to let a HTTP reverse proxy handle authentication
    -u, --uid               User id to run with
    -g, --gid               Group id to run with
    -s, --signal            Signal to send to the command when exit it (default: 1, SIGHUP)
    -w, --cwd               Working directory to be set for the child program
    -a, --url-arg           Allow client to send command line arguments in URL (eg: http://localhost:7681?arg=foo&arg=bar)
    -W, --writable          Allow clients to write to the TTY (readonly by default)
    -t, --client-option     Send option to client (format: key=value), repeat to add more options
    -T, --terminal-type     Terminal type to report, default: xterm-256color
    -O, --check-origin      Do not allow websocket connection from different origin
    -m, --max-clients       Maximum clients to support (default: 0, no limit)
    -o, --once              Accept only one client and exit on disconnection
    -B, --browser           Open terminal with the default system browser
    -I, --index             Custom index.html path
    -b, --base-path         Expected base path for requests coming from a reverse proxy (eg: /mounted/here, max length: 128)
    -P, --ping-interval     Websocket ping interval(sec) (default: 5)
    -6, --ipv6              Enable IPv6 support
    -S, --ssl               Enable SSL
    -C, --ssl-cert          SSL certificate file path
    -K, --ssl-key           SSL key file path
    -A, --ssl-ca            SSL CA file path for client certificate verification
    -d, --debug             Set log level (default: 7)
    -v, --version           Print the version and exit
    -h, --help              Print this text and exit

Visit https://github.com/tsl0922/ttyd to get more information and report bugs.
ttyd でbash を起動
$ ttyd -p 8080 --writable -t enableSixel=true /bin/bash
Note
  • 1.7.4 から --readonly オプションが --writable に変更になっています.
  • -t enableSixel=true でSixel を有効に出来ます.
Sixel で画像表示

ttyd sixel

sayaka ちゃんを起動

ttyd sayaka

環境
$ ./ttyd -v
ttyd version 1.7.4-fd280fe
$ dpkg-query -W build-essential cmake git libjson-c-dev libwebsockets-dev
build-essential 12.10
cmake   3.28.1-1
git     1:2.43.0-1
libjson-c-dev:amd64     0.17-1
libwebsockets-dev:amd64 4.3.3-1
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
Codename:       trixie
$ arch
x86_64
]]>
https://matoken.org/blog/2024/01/05/sixel-with-ttyd/feed/ 0
misskey クライアント sayaka ちゃん https://matoken.org/blog/2023/10/31/sayaka-chang_which_supports_misskey/ https://matoken.org/blog/2023/10/31/sayaka-chang_which_supports_misskey/#comments Tue, 31 Oct 2023 10:28:22 +0000 https://matoken.org/blog/?p=3921

「twitter クライアント sayaka ちゃん」が,「misskey クライアント sayaka ちゃん」 になっていたので試してみました.

sayaka ちゃんはターミナルに特化したクライアントで,SIXEL にも対応しているのでアイコンや画像つきでタイムラインを流すことができて便利です.
以前はTwitter クライアントですが,3.7.0 (2023/10/09) からTwitter への接続機能を廃止してMisskey 対応開始したようです.(–record などで保存していたファイルを –play で再生することはできる.※要configure option )

メール購読していたISSUE でsite 見に行って気づきました.

早速build します.

$ git clone https://github.com/isaki68k/sayaka
$ cd sayaka
$ sudo apt install libbsd-dev libwebp-dev libgif-dev libwslay1 libwslay-dev libmbedtls-dev libssl-dev bmake build-essential
$ ./configure
$ bmake -DRELEASE sayaka
$ install src/sayaka ~/bin/
$ sayaka
sayaka: No command option specified.
usage: sayaka [<options>...]
   command option:
        --local <server> : show <server>'s local timeline.
        --play : read JSON from stdin.
   other options:
        --color <n> : color mode { 2 .. 256 or x68k }. default 256.
        --font <width>x<height> : font size. default 7x14
        --full-url : display full URL even if the URL is abbreviated. (twitter)
        --light / --dark : Use light/dark theme. (default: auto detect)
        --no-color : disable all text color sequences
        --no-image : force disable (SIXEL) images.
        --force-sixel : force enable SIXEL images.
        --jis / --eucjp : Set output encoding.
        --progress: show startup progress (for very slow machines).
        --protect : don't display protected user's tweet. (twitter)
        --record <file> : record JSON to file.
        --record-all <file> : record all received JSON to file.
        --timeout-image <msec>
        --version
        --x68k : preset options for x68k (with SIXEL kernel).

        -4 / -6                         --ciphers <ciphers>
        --debug       <0-2>             --debug-format
        --debug-http  <0-2>             --debug-image <0-1>
        --debug-sixel <0-2>             --debug-show  <0-2>
        --mathalpha                     --no-combine
        --max-cont <n>                  --max-image-cols <n>
        --ormode <on|off> (default off) --palette <on|off> (default on)
Note
Linux 環境だとmake(GNU Make)ではなくbmake(bsd make) を使います.

現在は指定したMisskey サーバのローカルタイムラインの表示ができます.認証などは必要ありません.Misskey サーバについては以下のページを参考にすると良さそうです.

$ sayaka --local <servername>

動作確認には流量の多い misskey.io が良さそう.

$ sayaka --local misskey.io
Tip
サーバに https:// を付けるとホスト名の解決に失敗します
$ sayaka --local https://misskey.yukineko.me/
Ready...mbedtls_net_connect_nonblock https:443 - NET - Failed to get an IP address for the given hostname
sayaka: WebSocket connection failed
Tip
ローカルタイムラインを無効にしているサーバだと何も流れてきません.
$ sayaka --local misskey.yukineko.me
Ready...Connected

大量に流れてきます :)

misskey.io htl

NSFW画像は既定値ではぼかされます.表示したい場合は --show-nsfw オプションを付けると表示されます.
CW 投稿は既定値では展開されません.表示したいときは --show-cw オプションを付けると表示されます.

$ sayaka --show-nsfw --show-cw --local misskey.io

画像が表示されない場合は端末がSIXEL に対応しているか確認しましょう.そういえば最近は Microsoft Visual Studio Code も対応しているようです.(要設定変更※未検証)

laptop なんかでサスペンドしたりネットワークが切れると終了するので無限ループの中に入れたり.

$ while true; do sayaka --show-cw --show-nsfw --local nijimiss.moe --local misskey.io ; sleep 30; done
環境
$ sayaka --version
sayaka version 3.7.2 (2023/10/19)
$ dpkg-query -W libbsd-dev libwebp-dev libgif-dev libwslay1 libwslay-dev libmbedtls-dev libssl-dev bmake build-essential
bmake   20200710-16
build-essential 12.10
libbsd-dev:amd64        0.11.7-4
libgif-dev:amd64        5.2.1-2.5
libmbedtls-dev:amd64    2.28.5-1
libssl-dev:amd64        3.0.12-1
libwebp-dev:amd64       1.3.2-0.3
libwslay-dev:amd64      1.1.1-4
libwslay1:amd64 1.1.1-4
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
Codename:       trixie
$ arch
x86_64
]]>
https://matoken.org/blog/2023/10/31/sayaka-chang_which_supports_misskey/feed/ 1
Twitterクライアントsayakaちゃんの最新版(3.5.0)をLinuxでビルドする https://matoken.org/blog/2021/03/06/build-the-latest-version-3-5-0-of-twitter-client-sayaka-on-linux/ https://matoken.org/blog/2021/03/06/build-the-latest-version-3-5-0-of-twitter-client-sayaka-on-linux/#respond Sat, 06 Mar 2021 13:32:34 +0000 http://matoken.org/blog/?p=3052

追記2021-03-09)
Raspberry Pi OS buster armhf 及び Ubuntu 21.04 (development branch) amd64でも同様にビルドできました :)

ターミナルで動作するTwitterクライアントとしてsayakaちゃんというものがあります.NetBSDの入ったSHARP X68030でも動作するという軽量なクライアントで,SIXELで画像が表示できたりストリームモードがあってハッシュタグなどを垂れ流すのに便利に使っています.

今日オープンソースカンファレンス2021 Online/Spring 2日目があって @ebijunさんの「NetBSDのご紹介」 を視聴していたのですが,新しいバージョンの 3.5.0 がリリースされたとのことで試してみました.

twitter クライアント sayaka ちゃん version 3.5.0 (2021/03/03)
ターミナルに特化した twitter クライアントです。

フィルタストリームの垂れ流しが出来ます。
フィルタストリームによる疑似ホームタイムラインが表示できます。
mlterm などの SIXEL 対応ターミナル用です。
X68030/25MHz、メモリ12MB でも快適(?)動作。
更新履歴
3.5.0 (2021/03/03) … C++ に移行し vala 版廃止。 画像は現在のところ JPEG, PNG のみ対応。 ターミナル背景色の自動取得を実装。 --protect、--support-evs オプション廃止。 --noimg オプションを廃止 (--no-image に変更)。 userstream 時代の録画データの再生機能廃止。

watchしてたけどメール届いていないようです?

sayaka watch

現在のバーションを確認してみます.1つ前のバージョンぽいですね.

$ sayaka --version
sayaka.vala 3.4.6 (2020/11/10)

ビルドを試みます.

$ git clone https://github.com/isaki68k/sayaka/ (1)
$ cd sayaka
$ git checkout 3.5.0
HEAD is now at 958f630 ver 3.5.0 (2021/03/03)
$ ./configure (2)
  1. sayakaのsourceをclone
  2. configure

足りないものがパッケージ名で表示されて助かります :)

configure: error: *** mbedtls not found.
        On Ubuntu, sudo apt install libmbedtls-dev
configure: error: *** mbedtls not found.
        On Ubuntu, sudo apt install libmbedtls-dev

./configure が通ったらmake……失敗です.

$ make
(cd src; make all)
make[1]: Entering directory '/home/matoken/src/sayaka/src'
Makefile:3: *** missing separator.  Stop.
make[1]: Leaving directory '/home/matoken/src/sayaka/src'
make: *** [Makefile:2: all] Error 2

必要なものをよく見ると,GNU makeではなく BSD make が必要となっていました.(3.4.6を確認するとこのときはGNU makeなので今回変わったようです)

必要なもの
C++17 compiler
jpeg (libjpeg)
libpng
mbedtls (2.9.0 or later?)
BSD make (not GNU make)

BSD makeを導入してGNU makeではなくBSD makeを使います.

$ sudo apt install bmake (1)
$ bmake sayaka (2)
$ src/sayaka --version (3)
sayaka version 3.5.0 (2021/03/03)
$ install src/sayaka ~/bin/ (4)
  1. BSD makeを導入
  2. BSD makeでsayakaをmake
  3. 出来上がったsayakaを叩いてみる
  4. sayakaを適当な場所( ~/bin )にコピーにinstall

ということでsayaka 3.5.0 にできました :)

私はmlterm等のSIXEL対応端末で検索したいキーワードを繋げていってデスクトップの横においておくといった感じで使っています.

環境
$ sayaka --version
sayaka version 3.5.0 (2021/03/03)
$ ldd src/sayaka | cut -f1 -d"(" | cut -f3 -d" " | xargs -n1 apt-file search | cut -f1 -d: | uniq | xargs dpkg-query -W | grep amd64
libbsd0:amd64   0.11.3-1
libc6:amd64     2.31-9
libgcc-s1:amd64 10.2.1-6
libjpeg62-turbo:amd64   1:2.0.6-2
libmbedcrypto3:amd64    2.16.9-0.1
libmbedtls12:amd64      2.16.9-0.1
libmbedx509-0:amd64     2.16.9-0.1
libmd0:amd64    1.0.3-3
libpng16-16:amd64       1.6.37-3
libstdc++6:amd64        10.2.1-6
zlib1g:amd64    1:1.2.11.dfsg-2
$ dpkg-query -W bmake build-essential
bmake   20200710-7
build-essential 12.9
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64
]]>
https://matoken.org/blog/2021/03/06/build-the-latest-version-3-5-0-of-twitter-client-sayaka-on-linux/feed/ 0