matoken's blog https://matoken.org/blog Is there no plan B? Fri, 05 Dec 2025 11:27:53 +0000 ja hourly 1 https://wordpress.org/?v=6.9 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg matoken's blog https://matoken.org/blog 32 32 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
Squawker 3.8.4 で再度認証可能に https://matoken.org/blog/2025/12/02/squawker-3-8-4-allows-authentication-again/ https://matoken.org/blog/2025/12/02/squawker-3-8-4-allows-authentication-again/#respond Tue, 02 Dec 2025 09:45:00 +0000 https://matoken.org/blog/?p=4761

squawker logo

非公式Twitter client の Squawker バージョン 3.8.4 がリリースされました.

今回のリリースで仕様変更による認証情報の取得 異失敗する問題が解決されています.

Implement a new way to log (via the X web page, inspired by QuaX).

QuaX を参考にして実装されたようです.
今回の問題でQuaX に乗り換えようかとも思ったのですが,Squawker からのデータ移行は出来ましたがたくさんのアカウントの読み込みがうまく行かなかったりと自分の使い方ではSquawker のほうが良さそうです.

ということで早速更新.
F-Froid から導入していたので,F-Droid アプリで更新を行いました.

起動するとセッションの切れた認証情報を消しておいたせいか Not logged in と言われます Login から認証を行おうとしましたが,

squawker login

回線がプアなせいで何度かタイムアウト

squawker timeout

とかやっていたら Not logged in 画面を消してしまいました.右上の歯車→account からアカウントを追加しました.

squawker addaccount

Web認証画面に遷移するので認証を行うとSquawker にアカウントが登録できます.

squawker xlogin

アカウントの登録ができると時系列でTweet を見たり出来ます.

squawker matoken1

Nitter と組み合わせて使っていこうかと思います.

環境
$ adb shell dumpsys package org.ca.squawker | grep versionName=
    versionName=3.8.4
$ adb shell dumpsys package org.fdroid.fdroid | grep versionName=
    versionName=1.23.1
$ adb shell getprop ro.build.version.release
14
$ adb shell getprop ro.build.version.sdk
34
$ adb shell getprop ro.build.id
UTAS34.82-113-2
$ adb shell getprop ro.product.model
moto g24
]]>
https://matoken.org/blog/2025/12/02/squawker-3-8-4-allows-authentication-again/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
]]>
https://matoken.org/blog/2025/11/27/tmux-3-6-release/feed/ 0
イタリアの X.org スポット https://matoken.org/blog/2025/10/11/x-org-spotted-in-italy/ https://matoken.org/blog/2025/10/11/x-org-spotted-in-italy/#respond Sat, 11 Oct 2025 11:13:08 +0000 https://matoken.org/blog/?p=4730

ActivityPubで見かけたネタです.

イタリアには X.org スポットがあるそうです.
X.org の logo が看板になっています!


x logo

スレッドには近所に住んでいる方のtootも.
イタリア最大の湖や川から数百mか慣れた場所にあるナイトクラブらしいです.

View on Mastodon

という情報が分かればGoogleストリートビューで見つけられそう.てことでありました.(Mapillary には写っていなそう)
Googleストリートビューで履歴を見ると 2016-05〜2017-09 の間にできたようです.そして最新の 2025-06 にはまだあります.

スレッドにはいくつかのOSS系マスコットの写っている写真が.

View on Mastodon

Post by @philip@mastodon.nu
View on Mastodon

ちょっと違いますが日本には unix.co.jp とか Ubuntu というヘアサロンがあったり.

UNIX といえばタッパーウェアとかも有名ですね.日本でもスーパーなどでよく見かけます.

(UNIXと名の付く色々なものをまとめた海外のサイトがあったと思うのですが見つかりません.わかる方教えてください.)

]]>
https://matoken.org/blog/2025/10/11/x-org-spotted-in-italy/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/#respond 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/ 0
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
XServer無料VPSを少し試す https://matoken.org/blog/2025/07/19/try-xserver-free-vps/ https://matoken.org/blog/2025/07/19/try-xserver-free-vps/#respond Fri, 18 Jul 2025 22:31:30 +0000 https://matoken.org/blog/?p=4635

結構老舗のXServerが無料VPSを始めたらしいということで少し試してみています.

登録とOS(or アプリケーション)の選択

無料VPSは2種類から選択できます.
> メモリ2GB/vCPU2コア/NVMe SSD 30GB/ネットワーク 30Mbps/契約更新 4日ごと
もしくは
> メモリ4GB/vCPU3コア/NVMe SSD 30GB/ネットワーク 30Mbps/契約更新 2日ごと
の2種類から選べます.

登録には住所,氏名,電話番号,クレジットカード情報が必要でした.登録中にメール認証,電話(音声)認証,クレジットカード3Dセキュア認証が必要でした.ちょっと面倒です.
パスワードには利用可能文字が制限されていてとても面倒でした.(サービスパスワードとrootパスワード両方とも)

OSイメージはLinuxのみで*BSDなどは見当たりません.更に既存イメージの選択のみで自分で指定したインストーラから新規インストールのようなメニューは無さそう.無理やり差し替えることは可能でしょうがちょっと面倒です.
archtectureの選択はなくx86_64のみのようです.
OS以外にアプリケーションの選択もあります.WordPressやMisskeyなど利用したいアプリケーションが決まっている場合は小地位のほうがおてがるそうですが未確認.

今回はそろそろoldstableになるDebian 12を選択しました.

OS選択後root passwordとssh鍵を登録できます.ssh鍵は手持ちのものを登録したりXServerに作ってもらうこともできるようです.今回は手持ちのed25519の公開鍵を登録しました.

ssh接続

早速ssh接続をしようとしましたが繋がりません.

$ ssh ${XSERVER_VPS_IP} -l root -i ~/.ssh/id_ed25519
ssh: connect to host ${XSERVER_VPS_IP} port 22: Connection refused

XServerのパケットフィルターがデフォルトで有効になっているせいのようです.
XServer VPSの管理パネルから,「VPS管理」→「サーバー選択」で無料VPSの右の「選択する」 → 「パケットフィルター設定」からSSHを追加したら繋がるようになりました.

繋ぐと警告が.

-bash: warning: setlocale: LC_ALL: cannot change locale (ja_JP.UTF-8)
_____________________________________________________________________
WARNING! Your environment specifies an invalid locale.
 The unknown environment variables are:
   LC_CTYPE=ja_JP.UTF-8 LC_MESSAGES=ja_JP.UTF-8 LC_ALL=ja_JP.UTF-8
 This can affect your user experience significantly, including the
 ability to manage packages. You may install the locales by running:

 sudo dpkg-reconfigure locales

 and select the missing language. Alternatively, you can install the
 locales-all package:

 sudo apt-get install locales-all

To disable this message for all users, run:
   sudo touch /var/lib/cloud/instance/locale-check.skip
_____________________________________________________________________

sudo dpkg-reconfigure locales でTUIで設定するか, /etc/locale.gen を編集して sudo /sbin/locale-gen で治ると思います.
こんな感じになりましたが好みで編集しましょう.

$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=ja_JP.UTF-8
$ env | grep LC
LC_TIME=en_US.UTf-8
LC_ALL=ja_JP.UTF-8
LC_NUMERIC=en_US.UTf-8

LC_NUMERICen_US.UTf-8 とちょっとおかしいです.これは元のXServerのDebianイメージがおかしいようです.環境にあったdot fileなどで好みの設定に上書きしたほうが良さそうです.

ユーザの整理

このイメージではパスワードありのrootと一般ユーザとしてdebianが用意されていました.
sudoが設定済なのでrootのパスワードを無くして,作業ユーザを別途追加,debianユーザは消してしまおうと思います.

$ whoami (1)
debian
$ sudo passwd root -d (2)
$ sudo grep ^root: /etc/shadow (3)
root::20285:0:99999:7:::
$ sudo adduser ${OPERATOR} (4)
$ sudo adduser ${OPERATOR} sudo (5)
$ grep ^sudo: /etc/group (6)
sudo:x:27:debian,${OPERATOR}
$ sudo cp -r ~/.ssh ~${OPERATOR}/ (7)
$ sudo chown -R ${OPERATOR}:${OPERATOR} ~${OPERATOR}/.ssh
  1. debianユーザで作業

  2. rootのパスワードを削除

  3. 確認

  4. 作業ユーザを作成

  5. sudoグループに追加

  6. 確認

  7. ssh鍵をコピー

作業ユーザでssh loginしてsudoできるのを確認.`

$ ssh ${XSERVER_VPS_IP} -l ${OPERATOR} -i ~/.ssh/id_ed25519
$ sudo -v

ssh login制限

sshポートを変更,rootでのssh loginを無効にして作業ユーザのみログインできるようにします.

$ sudo diff -u /etc/ssh/sshd_config.ucf-dist /etc/ssh/sshd_config
--- /etc/ssh/sshd_config.ucf-dist       2025-07-16 15:28:39.245927761 +0900
+++ /etc/ssh/sshd_config        2025-07-16 18:33:10.502522166 +0900
@@ -11,7 +11,7 @@

 Include /etc/ssh/sshd_config.d/*.conf

-#Port 22
+Port ${SSH_PORT} (1)
 #AddressFamily any
 #ListenAddress 0.0.0.0
 #ListenAddress ::
@@ -30,12 +30,13 @@
 # Authentication:

 #LoginGraceTime 2m
-#PermitRootLogin prohibit-password
+PermitRootLogin no (2)
 #StrictModes yes
 #MaxAuthTries 6
 #MaxSessions 10

 #PubkeyAuthentication yes

 # Expect .ssh/authorized_keys2 to be disregarded by default in future.
 #AuthorizedKeysFile    .ssh/authorized_keys .ssh/authorized_keys2
@@ -115,8 +116,9 @@
 Subsystem      sftp    /usr/lib/openssh/sftp-server

 # Example of overriding settings on a per-user basis
-#Match User anoncvs
+Match User ${OPERATOR} (3)
 #      X11Forwarding no
 #      AllowTcpForwarding no
 #      PermitTTY no
 #      ForceCommand cvs server
$ sudo /sbin/sshd -t
  1. ポート番号は適当にランダムで決めました echo $RANDOM % 10000 + 49152

  2. rootのloginを無効に

  3. 作業ユーザのみログインできるように

パケットフィルターで設定したポートでログインできるよう設定しておきます.
PORT 22は閉じずにEndlesshで待ち受けることにします.

一時的にsshdを起動して

$ sudo /sbin/sshd -dD

作業ユーザ,指定ポートで接続できるのを確認.

$ ssh ${XSERVER_VPS_IP} -l ${OPERATOR} -i ~/.ssh/id_ed25519 -p ${SSH_PORT}

sshdを再起動.

$ sudo service ssh restart
Note
XServer VPSの機能でコンソール機能があるようなのでコンソールでssh設定してからポートを開けたほうが少し安心そうです.

パッケージ更新

Debianパッケージを更新します.結構たくさん更新ありました.kernelも更新来ていたので再起動.

$ sudo sh -c "apt update && apt upgrade"
$ sudo shutdown -r now

契約更新

無料VPSはそのままでは2日もしくは4日で消えてしまいます.手動で契約更新を行う必要があります.
メモリ4GBは2日ごと,メモリ2GBは4日ごとに契約更新が必要です.

手順はこんな感じでちょっと面倒.

  • XServer アカウントログイン

  • XServer VPS管理画面へ

  • 契約情報 → 利用期限 → 更新する

  • 引き続き無料VPSの利用を継続する

これを2日若しくは4日ごとに行う必要があります.
これを忘れるとこんな感じになります.

未契約のサービスです。エックスサーバーを利用するにはお申し込みが必要です。

特にメールなどの通知は無さそうです.

VPS利用期限になるとメールで通知が届くようになりました.
これまでに2通確認しましたが,更新期限日の11時すぎにメールが送信されていました.

Subject: 【XServer VPS】■重要■無料サーバーのご利用期限と更新に関するご案内 (${VPS名})

本文より

・サーバーが順次削除されます

ということでタイミングによっては復旧できるのかも?

— 追記

2025-07-30にはこのメールが届かなかったです(というのに31日に気づきVPSが消えてしまう).メールに頼り切るとダメそう.

— 追記2

そしてまた作り直そうとしたらこんなメッセージになり申し込めないことも.

現在、XServer VPS (無料VPS)は
予想を上回るお申し込みの増加に伴い、
新規お申し込みの受付を停止しております。

契約更新はぴったり2,4日ごとでなくとも1日前から更新可能なようです.

利用期限の1日前から更新手続きが可能です。
利用を継続される場合は、YYYY年YY月DD日以降にお試しください。

自分の場合単純の更新忘れや体調崩すなどすると消えてしまいそう.データはデイリーでバックアップするなどしたほうが良さそうです.

ベンチマーク

UnixBenchを走らせてみました.

$ sudo apt install make gcc
$ cd `mktemp -d`
$ wget https://github.com/kdlucas/byte-unixbench/archive/refs/tags/v6.0.0.tar.gz
$ tar xf v6.0.0.tar.gz
$ cd byte-unixbench-6.0.0/UnixBench
$ ./Run

resultsはこちら

用途

現在自分で契約しているVPSは複数ありますが,RAMの少なさで動かすのを諦めているアプリケーションがあるのでそういったものを動かしてみようと思います.
例えばchangedetection.ioをChrome込で動かすと結構RAMが必要なので現在は自宅PCで動かしています.これをこのサーバで動かすと良さそうです.
更新忘れでサーバが消えても問題ないようなものか,サーバ消えてもデータが残るよう同期やバックアップをちゃんとするようにしないと悲しいことになりそうですが.

その他の無料VPS

古くはhost1freeなども使っていましたが,現在はOracle Cloud Free TierのVPSがおすすめです.こちらは負荷が低いとサーバがシャットダウンされますが,ある程度の負荷掛けて動かし続けることが可能です.Archtectureもx86_64の他Ampereのaarch64も利用できます.200GBの無料ストレージも利用できるので自分のは主にこれで個人クラウドストレージに使っています.

おわり

XServerの無料VPSを少し試してみています.更新手順が少し煩雑ですがRAMも多くありがたいサービスです.
手動更新を忘れると数日で消えてしまうので消えてしまっても大丈夫なものを動かしたり,リモートへの自動バックアップや構築の自動化をしておいたほうがいいでしょう.
ちゃんと運用する場合は有料サーバを契約して使いましょう.

toot

View on Mastodon

View on Mastodon

View on Mastodon

View on Mastodon

View on Mastodon

View on Mastodon

View on Mastodon

View on Mastodon

View on Mastodon

]]>
https://matoken.org/blog/2025/07/19/try-xserver-free-vps/feed/ 0
ugrepでマッチ行以降全て表示 https://matoken.org/blog/2025/06/23/show-all-after-match-line-with-ugrep/ https://matoken.org/blog/2025/06/23/show-all-after-match-line-with-ugrep/#respond Sun, 22 Jun 2025 21:38:00 +0000 https://matoken.org/blog/?p=4629

grepコマンドにマッチした部分から指定行を表示する機能があります.
例えば以下の例ではマッチした部分から後ろ11行を表示.

$ man grep | grep 'Context Line Control' -A 11
   Context Line Control
       -A NUM, --after-context=NUM
              Print NUM lines of trailing context after matching lines.  Places a line containing a group separator (--) between contiguous groups of matches.  With the -o or --only-matching option, this has no effect  and  a  warning  is
              given.

       -B NUM, --before-context=NUM
              Print  NUM  lines  of  leading context before matching lines.  Places a line containing a group separator (--) between contiguous groups of matches.  With the -o or --only-matching option, this has no effect and a warning is
              given.

       -C NUM, -NUM, --context=NUM
              Print NUM lines of output context.  Places a line containing a group separator (--) between contiguous groups of matches.  With the -o or --only-matching option, this has no effect and a warning is given.

マッチした部分以降全てを表示したいことがあります.行数を確認するのが面倒だったりするので -A 999 とかやりがちです.

ugrep に最後まで表示できるオプションがあるのに気づいたのでメモしておきます.

DebianではGNU grepは grep パッケージで,ugrep は ugrep パッケージで提供されています.

導入
$ sudo apt install grep
$ sudo apt install ugrep

GNU grep を試す

適当なテキスト
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head
root
daemon
bin
sys
sync
games
man
lp
mail
news
GNU grepman の後2行を表示
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -A2 -- ^man$
man
lp
mail
GNU grepman の前2行を表示
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -B2 -- ^man$
sync
games
man
GNU grepman の前後それぞれ2行を表示
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -C2 -- ^man$
sync
games
man
lp
mail
GNU grepman の前1行後2行を表示
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -B1 -A2 -- ^man$
games
man
lp
mail
GNU grepman の後99行を表示(実際はそんなに行数がないので最後まで表示)
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | grep -A99 -- ^man$
man
lp
mail
news

ugrep を試す

ugrep もGNU grepと同じように -A/-B/-C が使えます.そして -A 利用時には行数に -1 が指定可能でこれでマッチ部分から最後まで表示できます.

grepman の後すべてを表示
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | ugrep -A-1 -- ^man$
man
lp
mail
news
-B には使えない
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | ugrep -B-1 -- ^man$
ugrep: warning: exception while searching (standard input): Inappropriate ioctl for device
tacで逆順にして -1 で切り取ったと再度tacで逆順に
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | tac | ugrep -A-1 -- ^man$ | tac
root
daemon
bin
sys
sync
games
man

ugrepは他にも対話型問い合わせの機能(-Q)やインデックスを作成して検索を高速化(-indexer)する機能など様々な機能が含まれています.
もっと使いこなしていきたいところです.

別解: sed, awk, perl

sed
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | sed -n '/^man$/,$p'
man
lp
mail
news
awk
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | awk '/^man$/',0
man
lp
mail
news
perl
$ awk -F: '{if ($3 < 1000) {print $1 }}' /etc/passwd | head | perl -ne "print if /^man$/ .. eof;"
man
lp
mail
news

環境

$ dpkg-query -W grep ugrep sed gawk perl
gawk    1:5.3.2-1
grep    3.11-4
perl    5.40.1-3
sed     4.9-2
ugrep   7.4.2+dfsg-1
$ lsb_release -dr
Description:    Debian GNU/Linux 13 (trixie)
Release:        13
$ arch
x86_64
]]>
https://matoken.org/blog/2025/06/23/show-all-after-match-line-with-ugrep/feed/ 0
画像,JavaScript/CSSなどに対応するターミナルウェブブラウザのChawanを試す https://matoken.org/blog/2025/06/20/try-chawan-a-terminal-web-browser-that-supports-images-javascript-css-etc/ https://matoken.org/blog/2025/06/20/try-chawan-a-terminal-web-browser-that-supports-images-javascript-css-etc/#respond Thu, 19 Jun 2025 20:52:39 +0000 https://matoken.org/blog/?p=4613

Chawanというターミナルウェブブラウザを知りました.
メモリセーフなNimで実装されていてライセンスはパブリックドメインです.

同じようにターミナル上で動作するw3mやLynx系との大きな違いはJavaScriptやCSSに対応している辺りでしょうか.SixelやKittyのターミナル画像形式にも対応しています.
少し試してみました.

Note

少し用途が違いますが,v8エンジンを使ったスクレイピング向けのヘッドレスブラウザのLightpandaなんてものもあります.

Chawanのインストール

現在のChawan: 0.2.0Linux amd64の静的バイナリtarballDebian amd64の.debがあります.
不安定のパッケージとしてAUR/NixOS/AppImageがあるようです.(こちらは今回未確認)

他の環境ではセルフビルドが必要そうです.

Debianパッケージ利用(amd64のみ)

Debian sid amd64環境に.debパッケージで導入してみました.

$ wget -c https://chawan.net/dl/chawan-0-2-0-amd64.deb (1)
$ sha256sum ./chawan-0-2-0-amd64.deb
ba3ff4e24a5bf09919caba1cdc4f50b0cbf862f8433f5ea43d5391c1e04eceda  ./chawan-0-2-0-amd64.deb
$ sha512sum ./chawan-0-2-0-amd64.deb
e941b880c179df8da7eb4cf7a8050c75ef8a1cdfe629aff8287893f4308071454bf7fb54b4054a5ab99330610b17eca12e7f23a71ffc956d613329365d3c7e17  ./chawan-0-2-0-amd64.deb
$ sudo apt install ./chawan-0-2-0-amd64.deb (2)
$ chawan (3)
bash: chawan: command not found
$ dpkg -L chawan | grep /bin/ (4)
/usr/bin/cha
/usr/bin/mancha
$ cha
Chawan browser v0.2.0 (release, sandboxed)
Usage: cha [options] [URL(s) or file(s)...]
Options:
    --                          Interpret all following arguments as URLs
    -c, --css <stylesheet>      Pass stylesheet (e.g. -c 'a{color: blue}')
    -d, --dump                  Print page to stdout
    -h, --help                  Print this usage message
    -o, --opt <config>          Pass config options (e.g. -o 'page.q="quit()"')
    -r, --run <script/file>     Run passed script or file
    -v, --version               Print version information
    -C, --config <file>         Override config path
    -I, --input-charset <enc>   Specify document charset
    -M, --monochrome            Set color-mode to 'monochrome'
    -O, --display-charset <enc> Specify display charset
    -T, --type <type>           Specify content mime type
    -V, --visual                Visual startup mode
$ cha --version
Chawan browser v0.2.0 (release, sandboxed by seccomp-bpf)
$ mancha
Usage:
mancha [-M path] [[-s] section] -k keyword
mancha [-M path] [[-s] section] name
mancha -l file
$ mancha cha
    :
  1. .debを入手

  2. インストール

  3. chwanコマンドはなかった

  4. バイナリを探すと chamancha が見つかった

Debian sid amd64でsourceからbuild

sourceからのbuildも試してみます.

パッケージで導入したNimはちょっと古そうです.

$ /usr/bin/nim -V
Nim Compiler Version 1.6.14 [Linux: amd64]
Compiled at 2024-04-25
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release

Nim 2.2.4を貰ってきてPATHを通しておきます.

$ wget -c https://nim-lang.org/download/nim-2.2.4-linux_x64.tar.xz https://nim-lang.org/download/nim-2.2.4-linux_x64.tar.xz.sha256
$ sha256sum -c nim-2.2.4-linux_x64.tar.xz.sha256
nim-2.2.4-linux_x64.tar.xz: OK
$ fuse-archive nim-2.2.4-linux_x64.tar.xz
fuse-archive: Created mount point 'nim-2.2.4-linux_x64'
$ export PATH=`pwd`/nim-2.2.4-linux_x64/nim-2.2.4/bin:$PATH
$ which nim
/home/matoken/Downloads/nim-2.2.4-linux_x64/nim-2.2.4/bin/nim
$ nim -V
Nim Compiler Version 2.2.4 [Linux: amd64]
Compiled at 2025-04-22
Copyright (c) 2006-2025 by Andreas Rumpf

git hash: f7145dd26efeeeb6eeae6fff649db244d81b212d
active boot switches: -d:release

適当なディレクトリに移動してChawanのsourceを貰ってきてbuildします.

$ cd ~/src
$ git clone https://git.sr.ht/~bptato/chawan && cd chawan
$ sudo apt install libssh2-1-dev libssl-dev libbrotli-dev pkg-config make
$ make
$ ./cha
Chawan browser v0.3 (release, sandboxed)
Usage: cha [options] [URL(s) or file(s)...]
Options:
    --                          Interpret all following arguments as URLs
    -c, --css <stylesheet>      Pass stylesheet (e.g. -c 'a{color: blue}')
    -d, --dump                  Print page to stdout
    -h, --help                  Print this usage message
    -o, --opt <config>          Pass config options (e.g. -o 'page.q="quit()"')
    -r, --run <script/file>     Run passed script or file
    -v, --version               Print version information
    -C, --config <file>         Override config path
    -I, --input-charset <enc>   Specify document charset
    -M, --monochrome            Set color-mode to 'monochrome'
    -O, --display-charset <enc> Specify display charset
    -T, --type <type>           Specify content mime type
    -V, --visual                Visual startup mode
$ ./cha -v
Chawan browser v0.3 (release, sandboxed by seccomp-bpf)

Raspberry Pi OS bookworm armhf

Single-Board ComputerのRaspberry Piでも試したいのでこちらでもbuildを試します.

Linux armhfのNimバイナリは公式に見当たらないのでこちらのNightlyのものを使いました.

$ wget -c https://github.com/nim-lang/nightlies/releases/download/2025-04-22-version-2-2-f7145dd26efeeeb6eeae6fff649db244d81b212d/nim-2.2.4-linux_armv7l.tar.xz
$ tar tvf nim-2.2.4-linux_armv7l.tar.xz
$ tar xvf nim-2.2.4-linux_armv7l.tar.xz
$ export PATH=$PATH:`pwd`/nim-2.2.4/bin
$ which nim
/home/matoken/Downloads/nim-2.2.4/bin/nim
$ cd ~/src
$ git clone https://git.sr.ht/~bptato/chawan && cd chawan
$ sudo apt install libssh2-1-dev libssl-dev libbrotli-dev pkg-config make
$ make
$ ./cha --version
Chawan browser v0.3 (release, sandboxed by seccomp-bpf)
Note

手元の環境ではパッケージ導入時に以下のような依存関係のエラーとなりました.

The following packages have unmet dependencies:
 zlib1g-dev : Depends: zlib1g (= 1:1.2.13.dfsg-1) but 1:1.2.13.dfsg-1+rpt1 is to be installed
E: Unable to correct problems, you have held broken packages.

とりあえずバージョンを指定して入れ直して回避できました.

$ sudo apt install zlib1g=1:1.2.13.dfsg-1

Chawanを試す

$ cha
Chawan browser v0.2.0 (release, sandboxed)
Usage: cha [options] [URL(s) or file(s)...]
Options:
    --                          Interpret all following arguments as URLs
    -c, --css <stylesheet>      Pass stylesheet (e.g. -c 'a{color: blue}')
    -d, --dump                  Print page to stdout
    -h, --help                  Print this usage message
    -o, --opt <config>          Pass config options (e.g. -o 'page.q="quit()"')
    -r, --run <script/file>     Run passed script or file
    -v, --version               Print version information
    -C, --config <file>         Override config path
    -I, --input-charset <enc>   Specify document charset
    -M, --monochrome            Set color-mode to 'monochrome'
    -O, --display-charset <enc> Specify display charset
    -T, --type <type>           Specify content mime type
    -V, --visual                Visual startup mode

とりあえず cha $URL という感じでurlを指定して起動するとウェブページが表示できます.
既定値ではCSSは認識しますが,JavaScriptや画像は使えません.

右クリックからのメーニューやショートカットで有効にすることも出来ますが面倒なので設定ファイルで設定します.

右クリックのメニュー
┌──────────────────────────────┐
│ Select text              (v) │
│ Copy selection           (y) │
│ Previous buffer          (,) │
│ Next buffer              (.) │
│ Discard buffer           (D) │
│ ──────────────────────────── │
│ View image               (I) │
│ Peek                     (u) │
│ Copy link               (yu) │
│ Copy image link         (yI) │
│ Paste link             (M-p) │
│ Reload                   (U) │
│ ──────────────────────────── │
│ Save link             (sC-m) │
│ View source              (\) │
│ Edit source             (sE) │
│ Save source             (sS) │
│ ──────────────────────────── │
│ Linkify URLs             (:) │
│ Toggle images          (M-i) │
│ Toggle JS & reload     (M-j) │
│ Toggle cookie & reload (M-k) │
│ ──────────────────────────── │
│ Bookmark page          (M-a) │
│ Open bookmarks         (M-b) │
│ Open history           (C-h) │
└──────────────────────────────┘

設定ファイルは
~/.chawan/config.toml 若しくは ~/.config/chawan/config.toml が使えるようです.
cha-config(5) を見ながら設定すると良さそうです.

とりあえず画像とJavaScriptを有効にする最低限の設定はこんな感じのようです.

[buffer]
images = true
scripting = true

ただ,JavaScriptの設定の scripting はここではなくsiteごとの設定の [siteconf] 内で有効にするのを強く勧めますとのことなのでちゃんと必要なsiteだけ有効にしたほうが良さそうです.

この状態でSixelやKittyに対応したXTermなどの端末でアクセスするとこんな感じで表示されます.

about:chawan キーバインドなども確認できます

chawan about

https://tenki.jp/forecast/9/49/8820/46490/10days.html JavaScriptをOnにした状態で2週間天気を見ようとするとコケます.JavaScript offだと表示できました.

chawan tenki ng

MastodonやMisskeyはJavaScriptを有効にしてもダメそうです.この辺りはサードパーティのアプリケーションを使ったほうが良さそうです.と思ったけど fedibird.com は大丈夫そう.インスタンスの設定が違うのでしょうか?

chawan mastodon ng
chawan fedibird

GithubのReleasesのAssetsも今はJavaScriptが必須になってしまっているのでこれはどうだろうと思いましたが駄目でした.

chawan github

という感じで少し試した感じではCSSを認識するので見た目がw3mなどと比べて大分いい感じです.カーソルが背景と同じになり場所がわからなくなってしまったりしますが,ポインティングデバイスが使える場合はクリックでカーソルがその場所に移動するのでアンカ部分をクリック&Enterでリンク先に移動できます.画像が一部しか表示されないとき key:[M-i] で画像をoff → 再度 key:[M-i] で画像を再度on とすると読み込まれることがあります.

回線が細い場合リモートのVPSでChawanを動かして結果だけをもらうようにするとダウンロード時間が短縮されていい感じです.ただし加増が多いサイトでスクロールを多用する場合はもたつきます.

Sixelで画像が利用できる時にSixel対応tmux経由でChawanを起動するとChawanのSixel画像が表示されないようです.同じ端末でimg2sixelなどは問題ないのでChawan側の問題でしょうか?

JavaScriptは思ったより動かないなという感じですがCSSが思ったより助かります.JavaScriptについてはQuickJS-NGを使っているのでこちらに期待です.ECMAScriptの機能準拠の進捗状況はこちら

ただ,現時点ではChawanはLinux amd64環境でJavaScript/画像有効でもメモリ利用量10MB前後.色々と動くようになるとこの辺も増えていってしまうでしょうね…….

という感じで軽量で見た目もいいのでこれからにも期待しつつw3mなどと併用していこうと思います.

]]>
https://matoken.org/blog/2025/06/20/try-chawan-a-terminal-web-browser-that-supports-images-javascript-css-etc/feed/ 0
terminal衛星追跡アプリのtrackerに衛星を追加 https://matoken.org/blog/2025/06/07/add-satellites-to-the-tracker/ https://matoken.org/blog/2025/06/07/add-satellites-to-the-tracker/#respond Fri, 06 Jun 2025 23:10:48 +0000 https://matoken.org/blog/?p=4594

ターミナル上で動作する衛星追跡,軌道予測ソフトウェアのtrackerが楽しくて色々な衛星の軌道を見たりして楽しんでいます.

しかし設定された衛星しか見ることができません.
任意の衛星を登録してみました.

sourceを眺めると衛星はsource内にハードコードされていて,それを元にCelesTrakから軌道データを取得しているようです.
衛星のタイプは2種類の方法で登録してあり,ISSなどは任意のYYYY-NNNAAA形式の(例えば1994-029AAB)国際識別子で個別の衛星を設定,若しくはCelesTrakでGROUPで検索できるgroup名でそのグループの衛星群(例えばWeatherで様々な気象衛星)が登録してあります.

個別の衛星を追加

時別の衛星を登録してみます.

まず対象の衛星の国際識別子を調べます.
先ずはCelesTrakの以下のページで衛星を検索します.

検索結果から「International Designator」をメモします.

例えば「あらせ」を登録したい場合,「ARASE」で検索,検索結果を見ると国際識別子は「2016-080A」なのでこれをメモしておきます.

次にtrackerのsourceを編集します.
衛星の情報は src/satellite_group.rs に書かれているのでこれを編集します.
pub enum SatelliteGroup { の適当な場所に衛星名を登録します.
fn cospar_id(&self) → Option<&str> { の中に国際識別子を登録します.

今回は以下のようにしました.

$ git diff
diff --git a/src/satellite_group.rs b/src/satellite_group.rs
index 88bbce8..b895b54 100644
--- a/src/satellite_group.rs
+++ b/src/satellite_group.rs
@@ -51,6 +51,7 @@ pub enum SatelliteGroup {
     #[strum(to_string = "Radar calibration")]
     RadarCalibration,
     CubeSats,
+    Arase,
 }

 impl SatelliteGroup {
@@ -124,6 +125,7 @@ impl SatelliteGroup {
             Self::Iss => Some("1998-067A"),
             Self::Css => Some("2021-035A"),
             Self::Dfh1 => Some("1970-034A"),
+            Self::Arase => Some("2016-080A"),
             _ => None,
         }
     }

buildして実行して動作確認をします.

$ cargo build
$ target/debug/tracker

あらせの楕円軌道が表示できるようになりました :)

tracker arase

衛星グループを登録

一つ一つ衛星を登録してくのは面倒です.CelesTrakの以下のページから好みのグループを探したり,

以下のページから該当の衛星のCatalog Numberから検索します.groupに存在する場合表示されます.

group名がわかったらsourceをいじります.
今回は最近第1弾の衛星群の打ち上げのあったAmazonの低軌道通信衛星サービスのProject Kuiperだと思われるkuiperで試してみます.

わかりやすいように一旦元に戻します.

$ git reset --hard

今夏も src/satellite_group.rs を編集します.

$ git diff src/satellite_group.rs
diff --git a/src/satellite_group.rs b/src/satellite_group.rs
index 88bbce8..33c5d0b 100644
--- a/src/satellite_group.rs
+++ b/src/satellite_group.rs
@@ -37,6 +37,9 @@ pub enum SatelliteGroup {
     Galileo,
     Beidou,

+    // Communications Satellites
+    Kuiper,
+
     // Scientific satellites
     #[strum(to_string = "Space & Earth Science")]
     SpaceEarthScience,
@@ -141,6 +144,7 @@ impl SatelliteGroup {
             Self::Glonass => Some("glo-ops"),
             Self::Galileo => Some("galileo"),
             Self::Beidou => Some("beidou"),
+            Self::Kuiper => Some("kuiper"),
             Self::SpaceEarthScience => Some("science"),
             Self::Geodetic => Some("geodetic"),
             Self::Engineering => Some("engineering"),

buildして実行して動作確認をします.

$ cargo build
$ target/debug/tracker

まだ1回の打ち上げしか無いので1つの軌道しかなさそうです.

tracker kuiper

Note

Project Kuiperの次の打ち上げ予定日は6/13.その後今年だけで48回予定がされていそうで追い上げがすごいですね.FCCとの兼ね合いなんでしょうが.
https://nextspaceflight.com/launches/?search=kuiper

Note

ちなみにStarlinkも試したところ7500機以上あるので極以外の地図が埋もれてしまいました…….

View on Mastodon

後はCelesTrakのgroupに無い自分で選んだ衛星群(みちびき群とか)も登録できるといいなと思うのですが少しロジックをいじらないといけなそうです.

]]>
https://matoken.org/blog/2025/06/07/add-satellites-to-the-tracker/feed/ 0
GaleneのテキストチャットをGo製ライブラリで保存 https://matoken.org/blog/2025/06/03/save-galene-text-chat-with-go-library/ https://matoken.org/blog/2025/06/03/save-galene-text-chat-with-go-library/#respond Mon, 02 Jun 2025 21:58:11 +0000 https://matoken.org/blog/?p=4583

Galeneというビデオカンファレンスサーバーがあります.WebRTCのSFUを利用し,低スペックなサーバーでも動作するのでセルフホストして利用しています.
Galeneのテキストチャットの保存をするのにチャット欄をコピー&ペーストしていますが面倒ですしコピーし忘れてしまうことも.

最近GaleneのGo製client libraryがリリースされたのでこれでチャットを保存できないか試してみました.

まずはsourceを貰ってきます.

$ git clone https://github.com/jech/gclient
$ cd gclient

example以下を見るとchat.goというものがあります.このまま使えそうです.

$ go build examples/chat/chat.go
$ ./chat
Usage: ./chat group
  -debug
        enable protocol logging
  -insecure
        don't check server certificates
  -password password
        password to use for login
  -username username
        username to use for login (default "chat-example")

Galeneのgroup urlを指定して実行することでテキストチャットの送受信ができました.このときのユーザ名は`chat-example`になります.

$ ./chat https://www.kagolug.org:8443/group/test/ (1)
user: hello world! (2)
user: 日本語
user: 絵文字&#x1f3a8;
hello (3)
chat-example: hello
^C
$ ./chat https://www.kagolug.org:8443/group/test/ (4)
user: hello world!
user: 日本語
user: 絵文字&#x1f3a8;
chat-example: hello
  1. Galeneのgroup urlを指定して実行.

  2. Galeneのテキストチャットがリアルタイムに表示される.

  3. terminalからchatを送信.

  4. 接続し直すと過去の(期限切れになっていない)chat logも取得できる.

いい感じそうです.でもタイムスタンプも欲しいです.
ということで少し書き換えます.

$ git diff examples/chat/chat.go
diff --git a/examples/chat/chat.go b/examples/chat/chat.go
index 8c9211b..d2a637e 100644
--- a/examples/chat/chat.go
+++ b/examples/chat/chat.go
@@ -107,11 +107,11 @@ outer:
                                        fmt.Printf("* %v %v\n",
                                                e.Username, e.Value,
                                        )
-                               } else if e.Username == "" {
-                                       fmt.Printf("%v\n", e.Value)
+//                             } else if e.Username == "" {
+//                                     fmt.Printf("%v\n", e.Value)
                                } else {
-                                       fmt.Printf("%v: %v\n",
-                                               e.Username, e.Value,
+                                       fmt.Printf("%v %v: %v\n",
+                                               e.Time, e.Username, e.Value,
                                        )
                                }
                        case error:
$ go run examples/chat/chat.go https://www.kagolug.org:8443/group/test/
2025-06-03T05:16:04+09:00 user: hello world!
2025-06-03T05:18:12+09:00 user: 日本語
2025-06-03T05:18:33+09:00 user: 絵文字&#x1f3a8;
2025-06-03T05:18:45+09:00 chat-example: hello

galene chat client

いい感じそうです.今度のミーティングに使ってみようと思います.

環境
$ git config remote.origin.url
https://github.com/jech/gclient
$ git log --pretty=oneline -1
e8edc33fd3d81701c5bad61e9bdb9399cd4e5dc4 (HEAD -> master, origin/master, origin/HEAD) Initial import.
$ dpkg-query -W golang
golang:amd64    2:1.24~2
$ go version
go version go1.24.2 linux/amd64
$ lsb_release -dr
Description:    Debian GNU/Linux 13 (trixie)
Release:        13
$ arch
x86_64
]]>
https://matoken.org/blog/2025/06/03/save-galene-text-chat-with-go-library/feed/ 0
terminal衛星追跡アプリのtracker https://matoken.org/blog/2025/05/31/terminal-based-real-time-satellite-tracking/ https://matoken.org/blog/2025/05/31/terminal-based-real-time-satellite-tracking/#comments Fri, 30 May 2025 22:11:21 +0000 https://matoken.org/blog/?p=4576

ターミナル上で動作する衛星追跡,軌道予測アプリケーションを見つけたので試してみました.

導入はcargoコマンドで行いました.

$ cargo install --git https://github.com/ShenMian/tracker
$ which tracker
/home/matoken/.cargo/bin/tracker
Note

Raspberry Pi OS bookworm armhfではcargoのバージョンの問題でうまく行きませんでした.

Caused by:
  failed to parse the `edition` key

Caused by:
  this version of Cargo is older than the `2024` edition, and only supports `2015`, `2018`, and `2021` editions.

若しくはいくつかの環境向けにはreleasesページにバイナリがおいてあるようです.(未確認)

tracker-linux-x86_64.tar.gz
tracker-macos-aarch64.tar.gz
tracker-macos-x86_64.tar.gz
tracker-windows-x86_64.zip

起動します.もしbuildは成功したのにコマンドが見当たらない場合はPATHが通っていないと思うのでPATHを通すか ~/.cargo/bin/tracker で起動するかもしれません.

$ tracker

操作はマウスのみのようです.
まず右下の「Satellite groups」から好みのグループをクリックで選びます.(複数選択可)
すると少し経ってからマップに衛星(群)がプロットされるので好みの衛星をクリックすると予測軌道が(おそらくこの後の地球1周分)マップ上に,それと右上の「Object information」が表示されます.
以下の画像ではISSの予想軌道が表示されています.

tracker

以下はWratherとEarth resourcesグループを表示して日本のALOS-2(だいち2号)の軌道を表示しています.

tracker alos2

静止衛星のひまわりなどを選ぶと予想軌道は見えません.

色々と衛星を眺めつつその衛星について調べたりすると楽しいです.
この衛星はもう運用終わって墓場軌道でこんな動きなのかとか.

若しくは少し実用的にだと上の画像だと右上のPeriodが90分ほどなのでしばらくするとISSが日本上空を通過するので晴れていれば見えそうとかがわかります.

リアルタイムで衛星は遷移していくので眺めているだけでも楽しいです.

ターミナルで動作する天文ソフトウェアだと星図のastrotermもおすすめです.

]]>
https://matoken.org/blog/2025/05/31/terminal-based-real-time-satellite-tracking/feed/ 3
Linux Namespaceを使ったTor分離ツールのoniux https://matoken.org/blog/2025/05/20/oniux-tor-separation-tool-using-linux-namespace/ https://matoken.org/blog/2025/05/20/oniux-tor-separation-tool-using-linux-namespace/#respond Tue, 20 May 2025 10:38:37 +0000 https://matoken.org/blog/?p=4568

TorプロジェクトからLinux Namespaceで任意のアプリケーションをTorネットワークに分離するoniuxというツールがリリースされました.
動作としては以前からあるtorsocksやtorifyのようなもののようです.
少し試してみました.

oniuxはRust製です.以下のようにしてリポジトリから導入できます.

$ cargo install --git https://gitlab.torproject.org/tpo/core/oniux oniux@0.4.0

optionはなさそうです.

$ oniux --help
Usage: oniux <CMD>...

Arguments:
  <CMD>...  The actual program to execute

Options:
  -h, --help  Print help

早速試してみます.Torネットワークを使っているかのチェックサイトにアクセスします.
テキストブラウザのw3mで直にアクセスすると Sorry. You are not using Tor.
oniux経由だと Congratulations. This browser is configured to use Tor. となります.良さそうです.

$ w3m -dump https://check.torproject.org/ | grep -e 'Sorry.' -e 'Congratulations.'
Sorry. You are not using Tor.
$ oniux w3m -dump https://check.torproject.org/ | grep -e 'Sorry.' -e 'Congratulations.'
Congratulations. This browser is configured to use Tor.

その他にもshellを起動してTorネットワーク用shellなんてことも.

$ oniux bash
$ w3m -dump https://check.torproject.org/ | grep -e 'Sorry.' -e 'Congratulations.'
Congratulations. This browser is configured to use Tor.

Firefoxでも試してみます.

$ oniux firefox -P temp --profile `mktemp -d`

Torネットワークを使えていそうです.

oniux fx torcheck

BBCなんかも利用できます.

oniux fx bbc

が,日本のNHKなんかは拒否されます.これはTorBrowserなどでも同じで日本のメディア系サイトは大抵拒否されちゃうんですよね…….

oniux fx nhk

対してBBCなどはonionアドレスでも提供されています.

でもoniux経由のFirefoxだと名前が引けないようでアクセスできません.他のonion siteもダメそうです.

oniux fx onion ng

$ oniux w3m https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/
w3m: Can't load https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/.
$ oniux w3m https://www.facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd.onion/
w3m: Can't load https://www.facebookwkhpilnemxj7asaniu7vnjjbiltxjqhye3mhbshg7kx5tfyd.onion/.
$ oniux curl -v https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/
* Not resolving .onion address (RFC 7686)
* Could not resolve host: www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion
* closing connection #0
curl: (6) Not resolving .onion address (RFC 7686)
$ oniux wget https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/
--2025-05-20 18:57:14--  https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/
Resolving www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion (www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion)... failed: Name or service not known.
wget: unable to resolve host address ‘www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion’
$ oniux ssh pi3bddj6lflqdtsfhdlja2zma3m7kqc4rhwpytoa37pbjc63suocj6qd.onion -F /dev/null
ssh: Could not resolve hostname pi3bddj6lflqdtsfhdlja2zma3m7kqc4rhwpytoa37pbjc63suocj6qd.onion: Name or service not known

今のところonion addressは使えなさそうな感じです.

oniuxはまだ実験的なツールなのでいつもは従来のtorsocksなどを利用しつつ見守っていこうと思います.

$ torsocks w3m -dump https://check.torproject.org/ | grep -e 'Sorry.' -e 'Congratulations.'
Congratulations. This browser is configured to use Tor.
$ torsocks w3m -dump https://www.bbcnewsd73hkzno2ini43t4gblxvycyac5aw4gnv7t2rccijh7745uqd.onion/ | head
BBC Homepage

  • Skip to content
  • Accessibility Help

  •
    Your account

  • Home
  • News
環境
$ grep ^version ~/.cargo/git/checkouts/oniux-a37b67fa6132af61/ff31287/Cargo.toml
version = "0.4.0"
$ dpkg-query -W cargo torsocks tor w3m firefox openssh-client
cargo
firefox 138.0.4-1
openssh-client  1:10.0p1-5
tor     0.4.8.16-1
torsocks        2.5.0-1
w3m     0.5.3+git20230121-2.1
$ lsb_release -dr
Description:    Debian GNU/Linux 13 (trixie)
Release:        13
$ arch
x86_64
]]>
https://matoken.org/blog/2025/05/20/oniux-tor-separation-tool-using-linux-namespace/feed/ 0
Mastodonで任意の言語のトレンドを取得したい https://matoken.org/blog/2025/05/15/i-want-to-get-trends-for-a-specific-language-with-mastodon/ https://matoken.org/blog/2025/05/15/i-want-to-get-trends-for-a-specific-language-with-mastodon/#respond Thu, 15 May 2025 11:47:06 +0000 https://matoken.org/blog/?p=4557

セルフホストダッシュボードアプリのGlanceが先日v0.8.0がリリース.大型アップデートされました.

新機能の一つにCommunity widgetsがあります.これにより各種のJSONで帰ってくるコンテンツをカスタムウィジットとして表示できそうです.v0.8.0リリース時点ですでに40以上公開されています.
設定はglanceのyamlに書くだけです.

この中のMastodonのトレンドを表示するものがありました.

手元のウェブブラウザだと日本語のコンテンツが表示されるのにこのウィジットだと英語のものになります.
次のAPIを利用しているようです.getなんかでlang=jaのように指定できると便利そうですが言語選択はなさそうです.

curlで叩くと英語に.

$ curl -s https://mastodon.social/api/v1/trends/links | jq . | head
[
  {
    "url": "https://arstechnica.com/tech-policy/2025/05/meta-is-making-users-who-opted-out-of-ai-training-opt-out-again-watchdog-says/",
    "title": "Meta is making users who opted out of AI training opt out again, watchdog says",
    "description": "EU users have less than two weeks to opt out of Meta’s AI training.",
    "language": "en",
    "type": "link",
    "author_name": "Ashley Belanger",
    "author_url": "https://arstechnica.com/author/ashleybelanger/",
    "provider_name": "Ars Technica",

Accept-Language で ja を指定すると日本語に

$ curl -s -H 'Accept-Language: ja' https://mastodon.social/api/v1/trends/links | jq . | head
[
  {
    "url": "https://www.cnn.co.jp/fringe/35232941.html",
    "title": "長時間勤務で脳の構造が変化、認知や感情制御に影響も 韓国調査",
    "description": "長時間勤務が続くと脳の構造が変化して、認知機能や感情制御に影響を及ぼす恐れがあるという研究結果が、13日の医学誌に発表された。働き過ぎると身体的、精神的な無理が重なり、休養不足も加わって脳に
  重大な変化」が起きると指摘している。",
    "language": "ja",
    "type": "link",
    "author_name": "翻訳:CNN.co.jp編集部",
    "author_url": "",
    "provider_name": "CNN.co.jp",

Accept-Language で fr を指定するとフランス語になりました.

$ curl -s -H 'Accept-Language: fr' https://mastodon.social/api/v1/trends/links | jq . | head
[
  {
    "url": "https://www.huffingtonpost.fr/justice/article/la-justice-prend-une-decision-inedite-pour-une-personne-trans-en-france_250035.html",
    "title": "La justice prend une décision « inédite » pour une personne trans en France",
    "description": "Un homme trans, qui contestait en justice le refus de CPAM du Bas-Rhin de prendre en charge sa mastectomie, a obtenu gain de cause au tribunal de Strasbourg.",
    "language": "fr",
    "type": "link",
    "author_name": "Éva Craine",
    "author_url": "https://www.huffingtonpost.fr/author/eva-craine",
    "provider_name": "Le HuffPost",

ということでこのあたりを見て判断していそうです.Glance側で日本語を表示するには本体のsourceを修正しないといけなさそうです.

]]>
https://matoken.org/blog/2025/05/15/i-want-to-get-trends-for-a-specific-language-with-mastodon/feed/ 0
Codebergのssh認証を公開鍵認証に変更する https://matoken.org/blog/2025/05/05/change-codebergs-ssh-authentication-to-ssh-public-key/ https://matoken.org/blog/2025/05/05/change-codebergs-ssh-authentication-to-ssh-public-key/#respond Sun, 04 May 2025 22:15:05 +0000 https://matoken.org/blog/?p=4540

Forgejo+αな感じのGitHub代替なCodebergにSSH公開鍵を登録してssh公開鍵認証でGitが使えるようにしてみました.

公式の手順はこちらにあります.少し気になったのが鍵生成のオプションでroundsが100もあること.手元のOpenSSH 10.0p2のssh-keygenのmanで確認すると既定値は16になっているので大分捻っています.

鍵ペアを生成したら*.pubの拡張子の付いた公開鍵*を以下のページから登録.

~/.ssh/configにCodebergの設定を書いておきます.Codebergはport 443でもssh接続okなのでここでは443を使うようにしています.
Userがみんなgitですが,鍵によりユーザを区別するようです.

$ grep -A 4 Host\ codeberg.org ~/.ssh/config
Host codeberg.org
  HostName codeberg.org
  User git
  IdentityFile ~/.ssh/id_ed25519
  Port 443

接続テストをします.

初回接続時にはホスト鍵の確認が必要です.Codebergのホスト鍵の鍵指紋は以下で確認できます.確認して入力しましょう.

$ ssh -T git@codeberg.org
The authenticity of host 'codeberg.org (2a0a:4580:103f:c0de::1)' can't be established.
ED25519 key fingerprint is SHA256:mIlxA9k46MmM6qdJOdMnAQpzGxF4WIVVL+fj+wZbw0g.
+--[ED25519 256]--+
| ++*+=.          |
|o +.+...         |
|oBo...+ o        |
|+o*o + OE        |
|o ... +.So       |
|. o .  .o.+      |
|.= o .  .+ .     |
|..+.o   ...      |
| oo     .o.      |
+----[SHA256]-----+
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? SHA256:mIlxA9k46MmM6qdJOdMnAQpzGxF4WIVVL+fj+wZbw0g
Warning: Permanently added 'codeberg.org' (ED25519) to the list of known hosts.
Connection closed by 2a0a:4580:103f:c0de::1 port 22

接続がうまく行けば自分のアカウント名や,鍵のコメントが表示されます.

$ ssh -T git@codeberg.org
Host key fingerprint is SHA256:mIlxA9k46MmM6qdJOdMnAQpzGxF4WIVVL+fj+wZbw0g
+--[ED25519 256]--+
| ++*+=.          |
|o +.+...         |
|oBo...+ o        |
|+o*o + OE        |
|o ... +.So       |
|. o .  .o.+      |
|.= o .  .+ .     |
|..+.o   ...      |
| oo     .o.      |
+----[SHA256]-----+
Enter passphrase for key '/home/matoken/.ssh/id_ed25519':
Authenticated to codeberg.org ([2a0a:4580:103f:c0de::1]:22) using "publickey".
Hi there, matoken! You've successfully authenticated with the key named matoken@l13, but Forgejo does not provide shell access.
If this is unexpected, please log in with password and setup Forgejo under another user.

ここではmatoken@l13という鍵を使い,matokenというアカウントでログインに成功しています.

Note
Codebergはport 443でもssh接続okなのですが,ここのテストは443を使うと失敗するようです.

この状態でパスワード認証を試みると失敗します.

$ ssh -T matoken@codeberg.org -o PasswordAuthentication=yes
Host key fingerprint is SHA256:mIlxA9k46MmM6qdJOdMnAQpzGxF4WIVVL+fj+wZbw0g
+--[ED25519 256]--+
| ++*+=.          |
|o +.+...         |
|oBo...+ o        |
|+o*o + OE        |
|o ... +.So       |
|. o .  .o.+      |
|.= o .  .+ .     |
|..+.o   ...      |
| oo     .o.      |
+----[SHA256]-----+
matoken@codeberg.org: Permission denied (publickey).

TOTPの設定を有効にしてこのSSH公開鍵認証を使うようにするとそこそこ安心な感じです.

]]>
https://matoken.org/blog/2025/05/05/change-codebergs-ssh-authentication-to-ssh-public-key/feed/ 0
TUIでBBCの天気情報が確認できるbbc_weather_scraper https://matoken.org/blog/2025/05/03/bbc_weather_scraper-allows-you-to-check-bbc-weather-information-on-tui/ https://matoken.org/blog/2025/05/03/bbc_weather_scraper-allows-you-to-check-bbc-weather-information-on-tui/#respond Fri, 02 May 2025 22:10:01 +0000 https://matoken.org/blog/?p=4527

BBCの天気情報を取得してTUIで表示するbbc_weather_scraperというツールを知ったので少し試してみました.
BBCの天気情報は細かな土地には対応していませんが全世界の天気が確認でき,onion siteもあって便利です.

導入
$ git clone https://github.com/leonmavr/bbc_weather_scraper
$ cd bbc_weather_scraper
$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
error1
$ ./scraper.py
Traceback (most recent call last):
  File "/home/matoken/src/bbc_weather_scraper/./scraper.py", line 3, in <module>
    from hourly import fmt_day_hourly
  File "/home/matoken/src/bbc_weather_scraper/hourly.py", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

requests が足りないようなので,requirements.txt に requests を追加して pip install -r requirements.txt を再実行.

error2
$ ./scraper.py
Traceback (most recent call last):
  File "/home/matoken/src/bbc_weather_scraper/./scraper.py", line 8, in <module>
    from pynput import keyboard
ModuleNotFoundError: No module named 'pynput'

今度は pynput が足りないようなので requirements.txt に追加して pip install -r requirements.txt を再実行.

これで動作するようになりました.

修正後の requirements.txt
$ git diff
diff --git a/requirements.txt b/requirements.txt
index b6942e8..9172c97 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,5 @@
 beautifulsoup4==4.12.3
 wcwidth==0.2.13
 geopy
+requests
+pynput

引数なしで実行すると city_ids.dat 内から近くであろう場所が選ばれます.
KagoshimaなどBBCにはあるけれどこのリストにない場所の場合以下のページから探してURLの最後のIDをメモします.Kagoshimaの場合, URLは https://www.bbc.com/weather/6300348 で,IDは 6300348 です.

city_ids.dat に名前とこのIDを追加します.

Kagoshima: 6300348

引数に名前を書くことで指定した場所が開けます.

$ ./scraper.py Kagoshima

更に緯度,経度を追加することもできます.

Kagoshima: 6300348: 31.801837, 130.719404

自分の環境では物理的にはKagoshimaが近いのですが,Tokyoになってしまいます.
これは回線によるのだと思います.

起動したらwasdで日にちを移動,fで詳細を開けます.xで戻り,qで終了です.

動作するようになったのですが,何もしなくても細かくフラッシュされて見づらいです.
demoではそんなことはなさそうなのでなにかの環境が悪いのかもしれません.

環境
$ git log --pretty=oneline -1
e648ad41b5d192ff2e21bebb18feece7981ef4de (HEAD -> master, origin/master, origin/HEAD) Add requirements
$ python --version
Python 3.13.3
$ dpkg-query -W python3 python3-venv python3-pip
python3 3.13.3-1
python3-pip     25.1+dfsg-1
python3-venv    3.13.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/2025/05/03/bbc_weather_scraper-allows-you-to-check-bbc-weather-information-on-tui/feed/ 0
楽天モバイル2度めの契約 https://matoken.org/blog/2025/04/18/rakuten-mobile-second-contract/ https://matoken.org/blog/2025/04/18/rakuten-mobile-second-contract/#respond Thu, 17 Apr 2025 21:51:35 +0000 https://matoken.org/blog/?p=4513

日本で4番目のMNOの楽天モバイルを契約しました.
基本料無料で利用できていたとき以来2度めの契約です.

楽天モバイルの電波は圏外で西に数キロのあたりと東に数キロのあたりにはアンテナがあるようですが自宅は圏外,auのローミングはマップ上では圏内ですが実際のところ自宅では通話中にすぐ切れてしまう電波の弱さ(-120dBm程).でも裏山でpovo 2.0で試すとdown 20Mbps,up 10Mbpsほど出る場所があったのでこのあたりまでケーブルを引いて使えないかなと久しぶりに契約しました.

これがうまく行けば使い放題かつ現在のSoftBank(7Mbpsくらいしか出ない)より高速になるはずです.

契約時のトラブル

以前契約したこともあるしオンラインで楽天アカウントでログインしてでサクサクと申し込み.身分証明書は自動車運転免許証の写真を送りました.
しかしここでちゃんと確認しなかったのが悪いのですが,氏名のふりがながなぜか「フリガナ」になっており申し込みに失敗しました.

編集しようにもグレーアウトして編集できません.

rakuten name pretend

どうも楽天アカウントの方も確認するとふりがな部分が「フリガナ」になっています.おそらく以前は項目がなかった若しくは必須項目ではなかったのが必須になり「フリガナ」が代入されたのかなとか思っていますが実際のところはよくわかりません.この楽天アカウントの方は編集できて正しいものにできましたが楽天モバイルの方には反映されませんでした.

仕方がないのでサポートに問い合わせ.chatは24hではなく09:00〜でした.夕方に問い合わせ,修正をお願いして次の日くらいに反映されました.その後再度申し込みでokに.

今回は物理SIMを申し込み,数日後にクロネコヤマトから届けてもらえました.

端末

今回はとりあえず手持ちの富士ソフト +F FS030Wを利用.
以下の設定で使っています.

  • ユーザ名: なし

  • パスワード: なし

  • APN: rakuten.jp

  • 認証方式: なし

  • 接続方式: IPV6

Tip
「接続方式」を「IPv4/v6」にするとv4のみが割り当てられ通信できないことがあるのでIPv6にしています.

この端末ファームウェアが古いので最新にしたいのですが,バッテリーがないのでファームウェアアップデートができません.
バッテリーがない状態でファームウェアアップデートをしようとすると「電池残量が40%未満の場合は、アップデートはできません」と言われてアップデートができません.
最新にすると楽天モバイルとローミング回線があるとき楽天モバイル回線を優先して利用するような修正が入っているようです.

現バージョンは「V3.1.0」最新バージョンは「V7.0.1」のようです.

自宅での利用

自宅では-120dBmくらいで電波がとても弱いです.カーテンレールのあたりに吊り下げると少しマシに.その状態でspeedtest.netのCLI版を叩くとこんな感じ.Downは思ったより出ますが,Upはあんまりですね.パケットロスが20%を超えることも…….

$ speedtest

   Speedtest by Ookla

[error] Error: [101] Network unreachable
[error] Error: [0] Cannot read from socket:
      Server: Rakuten Mobile, Inc - Tokyo (id: 24333)
         ISP: Rakuten Mobile Network
Idle Latency:   282.83 ms   (jitter: 285.83ms, low: 89.02ms, high: 682.02ms)
     Latency: FAILED
[error] Cannot read from socket:
$ speedtest

   Speedtest by Ookla

[error] Error: [101] Network unreachable
      Server: サーバーならDDPS.jp - Tokyo (id: 60324)
         ISP: Rakuten Mobile Network
Idle Latency:    77.39 ms   (jitter: 9.61ms, low: 74.14ms, high: 88.87ms)
    Download:     2.20 Mbps (data used: 3.1 MB)
               1247.89 ms   (jitter: 91.15ms, low: 344.84ms, high: 3091.08ms)
      Upload: FAILED                                            cy: 3021.95 ms
[error] Cannot write:
$ speedtest

   Speedtest by Ookla

[error] Error: [0] Timeout occurred in connect.
      Server: IPA CyberLab - Bunkyo (id: 14623)
         ISP: Rakuten Mobile Network
Idle Latency:    75.91 ms   (jitter: 19.29ms, low: 57.58ms, high: 85.05ms)
    Download:     4.48 Mbps (data used: 8.1 MB)
                767.78 ms   (jitter: 90.57ms, low: 190.29ms, high: 1477.12ms)
      Upload:     0.27 Mbps (data used: 388.3 kB)
 Packet Loss:     0.0%
  Result URL: https://www.speedtest.net/result/c/40433a4f-d346-4e5c-b01e-a69d3a1efc63
ping
$ ping -c 10 www.google.com
PING www.google.com (2404:6800:4004:81e::2004) 56 data bytes
64 bytes from nrt20s20-in-x04.1e100.net (2404:6800:4004:81e::2004): icmp_seq=1 ttl=56 time=68.7 ms
64 bytes from nrt20s20-in-x04.1e100.net (2404:6800:4004:81e::2004): icmp_seq=2 ttl=56 time=92.5 ms
64 bytes from nrt20s20-in-x04.1e100.net (2404:6800:4004:81e::2004): icmp_seq=3 ttl=56 time=88.3 ms
64 bytes from nrt20s20-in-x04.1e100.net (2404:6800:4004:81e::2004): icmp_seq=4 ttl=56 time=84.0 ms
64 bytes from nrt20s20-in-x04.1e100.net (2404:6800:4004:81e::2004): icmp_seq=5 ttl=56 time=96.3 ms
64 bytes from nrt20s20-in-x04.1e100.net (2404:6800:4004:81e::2004): icmp_seq=6 ttl=56 time=65.6 ms
64 bytes from nrt20s20-in-x04.1e100.net (2404:6800:4004:81e::2004): icmp_seq=7 ttl=56 time=91.3 ms
64 bytes from nrt20s20-in-x04.1e100.net (2404:6800:4004:81e::2004): icmp_seq=8 ttl=56 time=79.9 ms
64 bytes from nrt20s20-in-x04.1e100.net (2404:6800:4004:81e::2004): icmp_seq=9 ttl=56 time=125 ms
64 bytes from nrt20s20-in-x04.1e100.net (2404:6800:4004:81e::2004): icmp_seq=10 ttl=56 time=89.9 ms

--- www.google.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9015ms
rtt min/avg/max/mdev = 65.621/88.162/125.154/15.622 ms
httping
$ httping -c 10 www.google.com
PING www.google.com:80 (/):
could not connect (Network is unreachable)
connect time out
connect time out
could not connect (Network is unreachable)
could not connect (Network is unreachable)
connect time out
connect time out
connect time out
connect time out
could not connect (Network is unreachable)
--- http://www.google.com/ ping statistics ---
10 connects, 0 ok, 100.00% failed, time 222099ms
ssh
$ ssh matoken.org
ssh: connect to host 153.121.44.87 port 2222: Connection timed out
$ ssh matoken.org
ssh: connect to host 153.121.44.87 port 2222: Network is unreachable
$ ssh matoken.org
ssh: connect to host 153.121.44.87 port 2222: Network is unreachable

ルーターを電波のいい場所に設置(予定)

これからですが,UTP cableを引っ張ってモバイルルーターを防水のボックスに入れてPoE経由で給電することで電波強度がましな場所から通信ができないかと思っています.
まずは防水ボックスが実際防水かということを確認しようと思っています.今日から雨がふるようなので箱の中に紙を入れてケーブルを挟んで庭に置いてみました.
これが問題なかったら実際に設置してみようと思います.

]]>
https://matoken.org/blog/2025/04/18/rakuten-mobile-second-contract/feed/ 0
GnumericでCSVファイルエクスポート https://matoken.org/blog/2025/04/15/export-csv-files-with-gnumeric/ https://matoken.org/blog/2025/04/15/export-csv-files-with-gnumeric/#respond Mon, 14 Apr 2025 20:41:11 +0000 https://matoken.org/blog/?p=4506
gnumeric52

Gnumericという比較的軽量なスプレッドシートアプリケーションがあります.LibreOffice Calcを使うほどでもないようなときなどに利用しています.
今回CSVファイルへの書き出し方法が分かりづらかったのでメモしておきます.

GnumericでCtrl+Sで保存しようとすると以下のファイルタイプしかなくCSV保存ができません.

gnumeric save file type

ファイルメニューの中には「Save」「Save As」くらいしかそれらしい項目がありません.
メニューを探すと「データ」→「Export Data」→「Export as CSV File」がありここからCSVファイル書き出しができました.

gnumeric csv export

今回はまっさらな状態からでしたが,.gnumericなどのファイルがある場合はGnumeric同梱の ssconvert コマンドでも変換できそうです.

$ ssconvert --list-exporters
ID                                | 説明
Gnumeric_Excel:excel_biff7        | MS Excel™ 5.0/95
Gnumeric_Excel:excel_biff8        | MS Excel™ 97/2000/XP
Gnumeric_Excel:excel_dsf          | MS Excel™ 97/2000/XP & 5.0/95
Gnumeric_Excel:xlsx               | ECMA 376 1st edition (2006); [MS Excel™ 2007]
Gnumeric_Excel:xlsx2              | ISO/IEC 29500:2008 & ECMA 376 2nd edition (2008); [MS Excel™ 2010]
Gnumeric_GnomeGlossary:po         | GNOME 用語 PO ファイル形式
Gnumeric_OpenCalc:odf             | ODF 1.2 extended conformance (*.ods)
Gnumeric_OpenCalc:openoffice      | ODF 1.2 strict conformance (*.ods)
Gnumeric_XmlIO:sax                | Gnumeric XML (*.gnumeric)
Gnumeric_XmlIO:sax:0              | Gnumeric XML uncompressed (*.xml)
Gnumeric_dif:dif                  | Data Interchange 形式 (*.dif)
Gnumeric_glpk:glpk                | GLPK Linear Program Solver
Gnumeric_html:html32              | HTML 3.2 (*.html)
Gnumeric_html:html40              | HTML 4.0 (*.html)
Gnumeric_html:html40frag          | HTML (*.html) fragment
Gnumeric_html:latex               | LaTeX 2e (*.tex)
Gnumeric_html:latex_table         | LaTeX 2e (*.tex) table fragment
Gnumeric_html:latex_table_visible | LaTeX 2e (*.tex) table fragment of visible rows
Gnumeric_html:roff                | TROFF (*.me)
Gnumeric_html:xhtml               | XHTML (*.html)
Gnumeric_html:xhtml_range         | XHTML range - for export to clipboard
Gnumeric_lpsolve:lpsolve          | LPSolve Linear Program Solver
Gnumeric_paradox:paradox          | Paradox database (*.db)
Gnumeric_pdf:pdf_assistant        | PDF export
Gnumeric_stf:stf_assistant        | Text (configurable)
Gnumeric_stf:stf_csv              | カンマ区切り(CSV)
Gnumeric_sylk:sylk                | MultiPlan (SYLK)
環境
$ dpkg-query -W gnumeric
gnumeric        1.12.57-1.1+b1
$ lsb_release -dr
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2025/04/15/export-csv-files-with-gnumeric/feed/ 0
Countryfetchで国の情報を表示 https://matoken.org/blog/2025/04/10/view-country-information-with-countryfetch/ https://matoken.org/blog/2025/04/10/view-country-information-with-countryfetch/#respond Thu, 10 Apr 2025 11:13:25 +0000 https://matoken.org/blog/?p=4487

countrtfetch jp

Countryfetchという色々な国に情報をscreenfetchのような形式で表示してくれるcliアプリケーションを知ったので試してみました.

とりあえずreleasesからbinaryをもらってきて試します.

$ wget2 -cv https://github.com/nik-rev/countryfetch/releases/download/v0.1.9/countryfetch-x86_64-unknown-linux-gnu.tar.xz \
            https://github.com/nik-rev/countryfetch/releases/download/v0.1.9/countryfetch-x86_64-unknown-linux-gnu.tar.xz.sha256
$ sha256sum -c countryfetch-x86_64-unknown-linux-gnu.tar.xz.sha256
countryfetch-x86_64-unknown-linux-gnu.tar.xz: OK
$ countryfetch-x86_64-unknown-linux-gnu/countryfetch-x86_64-unknown-linux-gnu/countryfetch --help
A Command-line tool similar to Neofetch for obtaining information about your country

Usage: countryfetch [OPTIONS] [COUNTRY]...

Arguments:
  [COUNTRY]...

Options:
      --all-countries   Print information about all countries
      --list-countries  Print a list of all countries that can be passed
  -h, --help            Print help
  -V, --version         Print version

Config:
      --no-area              Exclude information about area of country
      --no-flag              Exclude ASCII flag art
      --no-emoji             Exclude country emoji
      --no-continent         Exclude continent
      --no-population        Exclude population
      --no-tld               Exclude top-level domain
      --no-languages         Exclude languages
      --no-currency          Exclude currency
      --no-neighbours        Exclude neighbours
      --no-established-date  Exclude established date
      --no-iso-codes         Exclude iso codes
      --no-driving-side      Exclude driving side
      --no-capital           Exclude capital
      --no-dialing-code      Exclude dialing code
      --no-palette           Exclude the country flag's palette
      --no-color             No colored output
$ countryfetch-x86_64-unknown-linux-gnu/countryfetch-x86_64-unknown-linux-gnu/countryfetch --version
countryfetch 0.1.9

そのまま実行するとgeoipから実行した場所の国の情報を表示しようとします.


  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  Japan 
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  -------
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  Area: 377,930 km² (145,900 miles²)
  @@@@@@@@@@@@@@@@#OznnzO#@@@@@@@@@@@@@@@@  Continent: Asia
  @@@@@@@@@@@@@@k/++++++++/k@@@@@@@@@@@@@@  Population: 125,836,021 People
  @@@@@@@@@@@@@U++++++++++++U@@@@@@@@@@@@@  Neighbours: No neighbours
  @@@@@@@@@@@@Z++++++++++++++Z@@@@@@@@@@@@  Capital: Tokyo
  @@@@@@@@@@@@1++++++++++++++)@@@@@@@@@@@@  ISO Codes: JP / JPN
  @@@@@@@@@@@@_++++++++++++++_@@@@@@@@@@@@  Driving side: left
  @@@@@@@@@@@@(++++++++++++++(@@@@@@@@@@@@  Dialing code: +81
  @@@@@@@@@@@@q++++++++++++++q@@@@@@@@@@@@  Language: Japanese
  @@@@@@@@@@@@@Q_++++++++++_Q@@@@@@@@@@@@@  Established: February 11, 660 BC
  @@@@@@@@@@@@@@oj_++++++_jo@@@@@@@@@@@@@@  Currency: ¥ JPY (Japanese yen)
  @@@@@@@@@@@@@@@@&qJXXJq&@@@@@@@@@@@@@@@@  Top Level Domains: .jp, .みんな
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  ███████████████████████████
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

geoipは ip-api.com を利用しているようです.

$ grep http ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/countryfetch-0.1.9/src/location.rs
                "http://ip-api.com/json/{ip}?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query"
$ curl -s http://ip-api.com/json/`curl -s ifconfig.me/ip`?fields=status,country | jq .                                                                                      │
│{                                                                                                                                                                                           │
│  "status": "success",                                                                                                                                                                      │
│  "country": "Japan"                                                                                                                                                                        │
│}
$ curl -s http://ip-api.com/json/`torify curl -s ifconfig.me/ip`?fields=status,country | jq .                                                                               │
│{                                                                                                                                                                                           │
│  "status": "success",                                                                                                                                                                      │
│  "country": "Ukraine"                                                                                                                                                                      │
│}

特定の国を表示したい場合は後ろに国名を付けます.

$ countryfetch-x86_64-unknown-linux-gnu/countryfetch-x86_64-unknown-linux-gnu/countryfetch UnitedKingdom

  /Z%@8C];;;;;;;;;\@]]]]@\;;;;;;;;;]YQt}zo  United Kingdom 
  Q(}YM@@d\I;;;;;;\@]]]]@\;;;;;;I\ZU}(0%@$  -------
  ~c0x[xd$@#c<;;;;\@]]]]@\;;;;~c0x[xd$@Mc~  Area: 242,900 km² (93,800 miles²)
  ;;I\ZY}(0%@BO[;;\@]]]]@\;;[QQ(}YM@@b\I;;  Continent: Europe
  ;;;;;]UQ/}zo@@kjf@]]]]@fj0z}/Z%@8C];;;;;  Population: 67,215,293 People
  rrrrrrrv*aYXwB@@$@]]]]@BwXYa@@@*vrrrrrrr  Neighbour: Ireland
  aaaaaaaaaaaaaaaaaa]]]]aaaaaaaaaaaaaaaaaa  Capital: London
  ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]  ISO Codes: GB / GBR
  ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]  Driving side: left
  ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]  Dialing code: +44
  WWWWWWWWWWWWWWWWWW]]]]WWWWWWWWWWWWWWWWWW  Language: English
  |||||||x*@@$qunw8@]]]]@%@@Bwnuqox|||||||  Established: January 1, 1801
  ;;;;I(m$@WC))JC(/@]]]]@/(m$@WC))JL(I;;;;  Currency: £ GBP (British pound)
  ;;!n#@@au]fZX~;;\@]]]]@\;;+U8@$qt]umn!;;  Top Level Domain: .uk
  ]C8@%Z/}zQj!;;;;\@]]]]@\;;;;!jk@@oz}/QU]
  @@MY}(QL[;;;;;;;\@]]]]@\;;;;;;;[O$@%0(}Y  ███████████████████████████
  au]fZX~;;;;;;;;;\@]]]]@\;;;;;;;;;~Y8@$qt

国コードでも良さそう.

$ countryfetch-x86_64-unknown-linux-gnu/countryfetch-x86_64-unknown-linux-gnu/countryfetch de

                                            Germany 
                                            -------
                                            Area: 357,114 km² (137,900 miles²)
                                            Continent: Europe
                                            Population: 83,240,525 People
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Neighbours: Austria, Belgium,
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{  Czechia, Denmark, France, Luxembourg,
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{  Netherlands, Poland, Switzerland
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{  Capital: Berlin
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{  ISO Codes: DE / DEU
  {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{  Driving side: right
  kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk  Dialing code: +49
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  Language: German
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  Established: October 3, 1990
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  Currency: EUR € (Euro)
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  Top Level Domain: .de
  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

国は250登録されているようです.

$ countryfetch-x86_64-unknown-linux-gnu/countryfetch-x86_64-unknown-linux-gnu/countryfetch --list-countries | grep "[^${control_characters} -~]" | wc -l
250

すべての国を表示してみたり.

250も旗を用意するの大変そうもしかして絵文字から変換したりしてる?とか思いましたが gen_country/src/lib.rs にAAの旗を含めハードコードされているようです.
https://github.com/nik-rev/countryfetch/blob/main/gen_country/src/lib.rs

]]>
https://matoken.org/blog/2025/04/10/view-country-information-with-countryfetch/feed/ 0