testing – matoken's blog https://matoken.org/blog Is there no plan B? Tue, 30 May 2023 11:08:37 +0000 ja hourly 1 https://wordpress.org/?v=6.9 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg testing – matoken's blog https://matoken.org/blog 32 32 i3statusのフォントサイズを変更 https://matoken.org/blog/2023/05/30/change-i3status-font-size/ https://matoken.org/blog/2023/05/30/change-i3status-font-size/#respond Tue, 30 May 2023 11:08:37 +0000 https://matoken.org/blog/?p=3907

最近ウィンドウマネージャにi3 wmを使っています.以前使っていた環境は14インチで解像度は1600×900,現在は12インチで1920×1200で画面サイズは小さくなったけどドット数は増えています.
この状態だとi3のステータスを表示しているi3statusの文字がぱっと見読めません.目を凝らせば読めるけど大変.
ということで文字を大きくする方法を調べました.

公式ドキュメントのFontの項目のExampleにそのものがありました.

5.10. Font
Specifies the font to be used in the bar. See [fonts].

Syntax:

font <font>

Example:

bar {
    font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
    font pango:DejaVu Sans Mono 10
}

DejaVu font は好きではないので規定値のmonospaceでサイズだけ大きくしてみます.

~/.config/i3/config
 # finds out, if available)
 bar {
         status_command i3status
+        font pango:monospace 16
 }

既定値は上の方にあった font pango:monospace 8 だと思います.
この状態で Mod+Shift+r で再読込して反映されました.

環境
$ dpkg-query -W i3 i3status
i3      4.22-2
i3status        2.14-2
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/05/30/change-i3status-font-size/feed/ 0
GitWebでリポジトリが404になってしまう https://matoken.org/blog/2023/05/29/gitweb%e3%81%a7%e3%83%aa%e3%83%9d%e3%82%b8%e3%83%88%e3%83%aa%e3%81%8c404%e3%81%ab%e3%81%aa%e3%81%a3%e3%81%a6%e3%81%97%e3%81%be%e3%81%86/ https://matoken.org/blog/2023/05/29/gitweb%e3%81%a7%e3%83%aa%e3%83%9d%e3%82%b8%e3%83%88%e3%83%aa%e3%81%8c404%e3%81%ab%e3%81%aa%e3%81%a3%e3%81%a6%e3%81%97%e3%81%be%e3%81%86/#respond Mon, 29 May 2023 13:19:39 +0000 https://matoken.org/blog/?p=3905

ふとGitWebを起動したら404になって困りました.

$ git instaweb --httpd webrick

gitweb404

$ w3m -dump http://127.0.0.1:1234/
]>
gitprojects /


404 - No projects found
OPML TXT

いくつかのリポジトリで試すと,駄目なのは自分のものだけのようでcloneした他の人の作ったものは動いていそうです.自分おリポジトリに何かが足りない?

と思ったのですが,ddgで検索すると以下のページを見つけました.

Found a likely cause while writing the question: Cloning the repository to a directory without the @ character in the name fixed it.

ディレクトリに@が含まれていると駄目のようです.リポジトリを@の含まれていないところにコピーするとうまく動きました.

$ pwd | grep -o '@'
@
$ git instaweb --httpd webrick --stop
$ cp -a ../05 `mktemp -d`
$ cd /tmp/tmp.LjVifz85dp/05
$ git instaweb --httpd webrick

自分のリポジトリは@の含まれるパスの下にあって,他のcloneしたリポジトリは@の含まれないパスの下にあったので動いていたということのようでした.

環境
$ dpkg-query -W git ruby-webrick
git     1:2.39.2-1.1
ruby-webrick    1.8.1-1
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/05/29/gitweb%e3%81%a7%e3%83%aa%e3%83%9d%e3%82%b8%e3%83%88%e3%83%aa%e3%81%8c404%e3%81%ab%e3%81%aa%e3%81%a3%e3%81%a6%e3%81%97%e3%81%be%e3%81%86/feed/ 0
OpenSSH ED25519 の Vanity Adress を探してみる https://matoken.org/blog/2023/04/18/openssh-ed25519-vanity-adress/ https://matoken.org/blog/2023/04/18/openssh-ed25519-vanity-adress/#respond Mon, 17 Apr 2023 21:33:00 +0000 https://matoken.org/blog/?p=3891

以前何種類かのVanity Adress を掘ってみました.

ふとSSH鍵のVanity Adress はどうだろうと試してみました.

鍵はEd25519 .鍵ペアの公開鍵がいい感じだと良さそうな気がします.

OpenSSH ssh-keygen

まずはOpenSSH の ssh-keysign で作ってみます.大文字小文字いずれかの mat0 が見つかるまで作成しています.

$ umask 277; no=0; tmp=`mktemp -d -p ~/tmp/`; chmod 700 ${tmp}; while true;do no=$(($no + 1)); ssh-keygen -t ed25519 -f ${tmp}/${no} -N '' -C '' > /dev/null; grep -i -E m[a@]t[o0] ${tmp}/${no}.pub && echo ${tmp}/${no} && break; done
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOt6L8+9eF3T8o/M4BnDVZ5F7SVdPmat0hlM8s/8zV/r
/home/matoken/tmp/tmp.rGb5eSpEaJ/26016

26016鍵ペアを生成したところで186秒ほど,大体140.6keys/sec くらい.遅い感じ?vmstat やtop を見てもcpu はあまり使えていない感じです.
-a 1 (default:16) にすると160.8/keys/sec と少し早くなりましたが鍵を盗まれた場合の強度が下がると思うのでやめたほうが良さそうです.

ssh-keygen-ed25519-vanity

tool を探してみます.

clone&build
$ git clone https://github.com/ionathanch/ssh-keygen-ed25519-vanity
$ cd ssh-keygen-ed25519-vanity
$ make
run
$ ./vanity mato
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEHmibZNyKuT/GO9rloS8qmatoFOZ4N7fJcRSOPCwsky
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZWQyNTUxOQAAACBB5om2Tcirk/xjva5aEvKpmraBTmeDe3yXEUjjwsLJMgAAAIjwyswa8MrMGgAAAAtzc2gtZWQyNTUxOQAAACBB5om2Tcirk/xjva5aEvKpmraBTmeDe3yXEUjjwsLJMgA
AAEBro42f/ycDTNvMw3JHIGD5dzg+VVgshQw+RWIhN/I2WEHmibZNyKuT/GO9rloS8qmatoFOZ4N7fJcRSOPCwskyAAAAAAECAwQF
-----END OPENSSH PRIVATE KEY-----

shell でssh-keygen を回すより速そうです.更にREADME にはmoreutils のparallel を使って並列実行する方法も書かれていました.

$ time parallel -n 0 ./vanity vanity -- 1 2 3 4

以下はREADME にあった文字数によりどのくらい時間がかかるかの目安です.

Rough performance stats
Obviously since it’s brute force the times are probabilistic, but this gives you an idea of how feasible it would be to find your desired number of characters.

Substring Time (s)

a

0.002

ar

0.015

ars

0.501

arso

3.753

arson

abandon all hope ye who seek five sequential characters

大分速いような気がしますがアドレスの指定が固定なようで大文字小文字どっちでもとか代替記号でもいいなどといったことが出来なそうです.

vanity-keygen

また別のものも試してみます.

clone&build
$ go install github.com/pcarrier/vanity-keygen@latest
$ vanity-keygen -h
Usage of vanity-keygen:
  -cpuprofile string
        write cpu profile to file
  -threads int
        number of threads to run (default 4)
run
$ time vanity-keygen -threads `nproc` [mM][aA@][tT][oO0]
2023/04/05 08:30:06 Looking for a public key matching [mM][aA@][tT][oO0]
2023/04/05 08:30:06 Public key:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA2rzJZSoqwrVF/Pf2FzKgfL/eMATOI/V7bjdmqkGV5B
2023/04/05 08:30:06 Private key:
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtz
c2gtZWQyNTUxOQAAACANq8yWUqKsK1Rfz39hcyoHy/3jAEziP1e243ZqpBleQQAA
AIiaywRCmssEQgAAAAtzc2gtZWQyNTUxOQAAACANq8yWUqKsK1Rfz39hcyoHy/3j
AEziP1e243ZqpBleQQAAAEDBsKpzquKe0/QTheaoVSChK8gF6d38u5mwrtqihfMY
6A2rzJZSoqwrVF/Pf2FzKgfL/eMATOI/V7bjdmqkGV5BAAAAAAECAwQF
-----END OPENSSH PRIVATE KEY-----

real    0m0.331s
user    0m0.652s
sys     0m0.048s

このツールはスレッド数も指定できるし,アドレスの指定も柔軟なので良さそうです.

$ vanity-keygen aaaaa
2023/04/05 08:30:12 Looking for a public key matching aaaaa
2023/04/05 08:30:13 Generated 71,000 keypairs (69,788 Hz)
2023/04/05 08:30:14 Generated 141,000 keypairs (70,310 Hz)
2023/04/05 08:30:15 Generated 212,000 keypairs (70,454 Hz)
2023/04/05 08:30:16 Generated 284,000 keypairs (70,792 Hz)
2023/04/05 08:30:17 Generated 356,000 keypairs (71,040 Hz)

探索中にどのくらいの鍵を生成したかも表示されます.

良さそうなのでTor のときのように少電力なSBCのRaspberry Pi 3 modelB でも試してみました.

Raspberry Pi OS armhf 向けにamd64 環境でクロスビルド
$ GOARCH=arm GOARM=7 go build .
$ file ./vanity-keygen
./vanity-keygen: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, Go BuildID=Z_Cr4XM48GAIHSA-MQng/2wFeSpgr5k0WPASNS4ho/3FEwAtva33LS2ByXLcjP/0WSk_fEc6xXCDZEo89yH, with debug_info, not stripped
Pi3Bで実行
$ ./vanity-keygen -threads 4 aaaa
2023/04/05 08:22:58 Looking for a public key matching aaaa
2023/04/05 08:22:59 Generated 0 keypairs (0 Hz)
2023/04/05 08:23:00 Generated 4,000 keypairs (1,991 Hz)
2023/04/05 08:23:01 Generated 4,000 keypairs (1,332 Hz)
2023/04/05 08:23:02 Generated 8,000 keypairs (1,990 Hz)
2023/04/05 08:23:03 Generated 8,000 keypairs (1,598 Hz)
^C
$ cat /proc/device-tree/model && echo
Raspberry Pi 3 Model B Rev 1.2

……大分遅くなりました.PCで実行したほうが良さそうです.

まとめ

気に入った鍵が出来たらパスフレーズを設定したり,

$ ssh-keygen -p -f ./key
Key has comment ''
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.

コメントを書き換えたりしましょう.

$ ssh-keygen -c -f ./key
Enter passphrase:
Old comment:
New comment: vanity
Comment 'vanity' applied

Tor のVanity adoress なんかに比べるとあまり目立たないですが,hostkey やGitHub/Lab などで一般公開している鍵に使うのはありではと思います.

環境

$ cpu-info
Packages:
        0: Intel Core i5-7300U
Microarchitectures:
        2x Sky Lake
Cores:
        0: 2 processors (0-1), Intel Sky Lake
        1: 2 processors (2-3), Intel Sky Lake
Logical processors (System ID):
        0 (0): APIC ID 0x00000000
        1 (2): APIC ID 0x00000001
        2 (1): APIC ID 0x00000002
        3 (3): APIC ID 0x00000003
$ lsb_release -dr
No LSB modules are available.
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
$ arch
x86_64
]]>
https://matoken.org/blog/2023/04/18/openssh-ed25519-vanity-adress/feed/ 0
Logitech Webcam C310n を購入とC270との比較 https://matoken.org/blog/2023/03/14/logitech-webcam-c310n/ https://matoken.org/blog/2023/03/14/logitech-webcam-c310n/#respond Tue, 14 Mar 2023 10:28:49 +0000 https://matoken.org/blog/?p=3888

昔ハードオフでLogicool C270 を500円ほどで購入して使っていました.ビデオミーティングを良くするようになってC270はマイクもついているので便利に使っていました.でもマイクにノイズが乗るようになりNotePC内蔵ウェブカムやスマートフォンをWebcamとして利用していましたが使いにくいしマイクがついていないので少し不便.今回ひとつ上の機種のC310n を購入しました.

購入したのはAmazon で,-19% off 2400円となっていたのでそれで購入しようと思っていたところAmazon のUSED で2040円送料無料があったのでそちらを購入.

こんな感じのパッケージで届きました.内容物は本体と小さな保証書と取説が1枚づつ.付属物一覧がないので新品もこれと同じかは不明.

c310n package03
c310n package01

このテープの切り方はちょっとアウト感.

c310n package02

外観はこんな感じ.C270とほぼ同じだけどC270より気持ち大きくなって,ケーブル止めのベルクロがありません.

c310n 01
c310n c270 01

カタログスペックはC270 とほぼ同じで,画角と画素数が少し違うよう.

C270n C310n

画素数

0.9MP

1.2MP

対角視野

55°

60°

Linux端末に繋いでみるとC270と同じくUVC/UAC で認識して特に問題なく利用できていそうです.

$ sudo dmesg --human --color --follow-new
[  +4.580070] usb 1-3: new high-speed USB device number 59 using xhci_hcd
[  +0.369127] usb 1-3: New USB device found, idVendor=046d, idProduct=081b, bcdDevice= 0.12
[  +0.000026] usb 1-3: New USB device strings: Mfr=0, Product=0, SerialNumber=2
[  +0.000011] usb 1-3: SerialNumber: 159F4170
[  +0.002035] usb 1-3: Found UVC 1.00 device <unnamed> (046d:081b)
[  +0.115112] input: UVC Camera (046d:081b) as /devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.0/input/input192
[  +0.071778] usb 1-3: set resolution quirk: cval->res = 384
$ lsusb -d 046d:081b
Bus 001 Device 059: ID 046d:081b Logitech, Inc. Webcam C310
$ v4l-info /dev/video2

### v4l2 device info [/dev/video2] ###
general info
    VIDIOC_QUERYCAP
	driver                  : "uvcvideo"
	card                    : "UVC Camera (046d:081b)"
	bus_info                : "usb-0000:00:14.0-3"
	version                 : 6.1.12
	capabilities            : 0x84a00001 [VIDEO_CAPTURE,?,?,STREAMING,(null)]

standards

inputs
    VIDIOC_ENUMINPUT(0)
	index                   : 0
	name                    : "Camera 1"
	type                    : CAMERA
	audioset                : 0
	tuner                   : 0
	std                     : 0x0 []
	status                  : 0x0 []

video capture
    VIDIOC_ENUM_FMT(0,VIDEO_CAPTURE)
	index                   : 0
	type                    : VIDEO_CAPTURE
	flags                   : 0
	description             : "YUYV 4:2:2"
	pixelformat             : 0x56595559 [YUYV]
    VIDIOC_ENUM_FMT(1,VIDEO_CAPTURE)
	index                   : 1
	type                    : VIDEO_CAPTURE
	flags                   : 1
	description             : "Motion-JPEG"
	pixelformat             : 0x47504a4d [MJPG]
    VIDIOC_G_FMT(VIDEO_CAPTURE)
	type                    : VIDEO_CAPTURE
	fmt.pix.width           : 640
	fmt.pix.height          : 480
	fmt.pix.pixelformat     : 0x56595559 [YUYV]
	fmt.pix.field           : NONE
	fmt.pix.bytesperline    : 1280
	fmt.pix.sizeimage       : 614400
	fmt.pix.colorspace      : SRGB
	fmt.pix.priv            : 4276996862

controls
    VIDIOC_QUERYCTRL(BASE+0)
	id                      : 9963776
	type                    : INTEGER
	name                    : "Brightness"
	minimum                 : 0
	maximum                 : 255
	step                    : 1
	default_value           : 128
	flags                   : unknown
    VIDIOC_QUERYCTRL(BASE+1)
	id                      : 9963777
	type                    : INTEGER
	name                    : "Contrast"
	minimum                 : 0
	maximum                 : 255
	step                    : 1
	default_value           : 32
	flags                   : unknown
    VIDIOC_QUERYCTRL(BASE+2)
	id                      : 9963778
	type                    : INTEGER
	name                    : "Saturation"
	minimum                 : 0
	maximum                 : 255
	step                    : 1
	default_value           : 32
	flags                   : unknown
    VIDIOC_QUERYCTRL(BASE+12)
	id                      : 9963788
	type                    : BOOLEAN
	name                    : "White Balance, Automatic"
	minimum                 : 0
	maximum                 : 1
	step                    : 1
	default_value           : 1
	flags                   : unknown
    VIDIOC_QUERYCTRL(BASE+19)
	id                      : 9963795
	type                    : INTEGER
	name                    : "Gain"
	minimum                 : 0
	maximum                 : 255
	step                    : 1
	default_value           : 64
	flags                   : unknown
    VIDIOC_QUERYCTRL(BASE+24)
	id                      : 9963800
	type                    : MENU
	name                    : "Power Line Frequency"
	minimum                 : 0
	maximum                 : 2
	step                    : 1
	default_value           : 2
	flags                   : unknown
    VIDIOC_QUERYCTRL(BASE+26)
	id                      : 9963802
	type                    : INTEGER
	name                    : "White Balance Temperature"
	minimum                 : 0
	maximum                 : 10000
	step                    : 10
	default_value           : 4000
	flags                   : INACTIVE
    VIDIOC_QUERYCTRL(BASE+27)
	id                      : 9963803
	type                    : INTEGER
	name                    : "Sharpness"
	minimum                 : 0
	maximum                 : 255
	step                    : 1
	default_value           : 24
	flags                   : unknown
    VIDIOC_QUERYCTRL(BASE+28)
	id                      : 9963804
	type                    : INTEGER
	name                    : "Backlight Compensation"
	minimum                 : 0
	maximum                 : 1
	step                    : 1
	default_value           : 0
	flags                   : unknown
$ pactl list sources | grep 'escription: Webcam C310' -B 3 -A999
Source #1114
	State: RUNNING
	Name: alsa_input.usb-046d_081b_159F4170-02.mono-fallback
	Description: Webcam C310 モノ
	Driver: PipeWire
	Sample Specification: s16le 1ch 48000Hz
	Channel Map: mono
	Owner Module: 4294967295
	Mute: no
	Volume: mono: 65536 / 100% / 0.00 dB
	        balance 0.00
	Base Volume: 20724 /  32% / -30.00 dB
	Monitor of Sink: n/a
	Latency: 0 usec, configured 0 usec
	Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
	Properties:
		alsa.card = "2"
		alsa.card_name = "USB Device 0x46d:0x81b"
		alsa.class = "generic"
		alsa.device = "0"
		alsa.driver_name = "snd_usb_audio"
		alsa.id = "USB Audio"
		alsa.long_card_name = "USB Device 0x46d:0x81b at usb-0000:00:14.0-3, high speed"
		alsa.name = "USB Audio"
		alsa.resolution_bits = "16"
		alsa.subclass = "generic-mix"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		api.alsa.card.longname = "USB Device 0x46d:0x81b at usb-0000:00:14.0-3, high speed"
		api.alsa.card.name = "USB Device 0x46d:0x81b"
		api.alsa.path = "hw:2"
		api.alsa.pcm.card = "2"
		api.alsa.pcm.stream = "capture"
		audio.channels = "1"
		audio.position = "MONO"
		card.profile.device = "1"
		device.api = "alsa"
		device.class = "sound"
		device.id = "112"
		device.profile.description = "モノ"
		device.profile.name = "mono-fallback"
		device.routes = "1"
		factory.name = "api.alsa.pcm.source"
		media.class = "Audio/Source"
		device.description = "Webcam C310"
		node.name = "alsa_input.usb-046d_081b_159F4170-02.mono-fallback"
		node.nick = "USB Device 0x46d 0x81b"
		node.pause-on-idle = "false"
		object.path = "alsa:pcm:2:hw:2:capture"
		priority.driver = "2000"
		priority.session = "2000"
		factory.id = "18"
		clock.quantum-limit = "8192"
		client.id = "33"
		node.driver = "true"
		factory.mode = "split"
		audio.adapt.follower = ""
		library.name = "audioconvert/libspa-audioconvert"
		object.id = "92"
		object.serial = "1114"
		node.max-latency = "16384/48000"
		api.alsa.period-size = "512"
		api.alsa.period-num = "64"
		api.alsa.headroom = "512"
		api.acp.auto-port = "false"
		api.acp.auto-profile = "false"
		api.alsa.card = "2"
		api.alsa.use-acp = "true"
		api.dbus.ReserveDevice1 = "Audio2"
		device.bus = "usb"
		device.bus-id = "usb-046d_081b_159F4170-02"
		device.bus_path = "pci-0000:00:14.0-usb-0:3:1.2"
		device.enum.api = "udev"
		device.form_factor = "webcam"
		device.icon_name = "camera-web-analog-usb"
		device.name = "alsa_card.usb-046d_081b_159F4170-02"
		device.nick = "USB Device 0x46d:0x81b"
		device.plugged.usec = "152884093590"
		device.product.id = "0x081b"
		device.product.name = "Webcam C310"
		device.serial = "046d_081b_159F4170"
		device.subsystem = "sound"
		sysfs.path = "/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/sound/card2"
		device.vendor.id = "0x046d"
		device.vendor.name = "Logitech, Inc."
		device.string = "2"
	Ports:
		analog-input-mic: マイクロフォン (type: Mic, priority: 8700, availability unknown)
	Active Port: analog-input-mic
	Formats:
		pcm

現在はAmazonでC270n 2,200円,C310n 2,400円と値段差があまりないのでC310の方が良さそうです.

]]>
https://matoken.org/blog/2023/03/14/logitech-webcam-c310n/feed/ 0
Andorid の画面をPC に転送して操作も出来るScrcpy 2.0 でオーディオ転送にも対応 https://matoken.org/blog/2023/03/13/scrcpy-2-0-audio/ https://matoken.org/blog/2023/03/13/scrcpy-2-0-audio/#respond Sun, 12 Mar 2023 21:45:00 +0000 https://matoken.org/blog/?p=3881

Andorid の画面をPC に転送して操作も出来るScrcpy というソフトウェアがあります.最新版の2.0でオーディオ転送にも正式対応したので試してみました.

Scrcpy はここでも何度か記事にしています.

このScrcpy はオーディオに対応しておらず,sndcpy という別のソフトウェアを使ったり,Scrcpy/sndcpyを同梱してQtでGUIを実装したQtScrcpy を使ったり,Bluetooth a2d-source を使って音を転送していました.

Scrcpy 2.0 がリリースされ,標準でオーディオに対応したとのことで試してみました.

Linux 環境への導入は以下のページに纏まっています.ただ,現バージョンで2.0に対応しているのはHomebrewとScoopだけのようです.

snap も未だ 1.25 です.

ということでsourceからbuildしました.

$ sudo apt install ffmpeg libsdl2-2.0-0 adb wget \
                 gcc git pkg-config meson ninja-build libsdl2-dev \
                 libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev \
                 libswresample-dev libusb-1.0-0 libusb-1.0-0-dev (1)
$ git clone https://github.com/Genymobile/scrcpy (2)
$ cd scrcpy
$ ./install_release.sh (3)
$ which scrcpy (4)
/usr/local/bin/scrcpy
$ scrcpy --version (5)
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>

Dependencies (compiled / linked):
 - SDL: 2.26.3 / 2.26.3
 - libavcodec: 59.37.100 / 59.37.100
 - libavformat: 59.27.100 / 59.27.100
 - libavutil: 57.28.100 / 57.28.100
 - libavdevice: 59.7.100 / 59.7.100
 - libusb: - / 1.0.26
  1. 関連パッケージの導入
  2. scrcpy のclone
  3. build&install script の実行
  4. インストールパスの確認
  5. バージョンの確認
Note

uninstall

$ sudo ninja -Cbuild-auto uninstall

Android 端末のudev への登録をしていない場合登録します.Android端末側ではUSBデバッグを有効にしておいて,フィンガープリントの確認が表示されたら許可します.

$ lsusb | grep -i moto (1)
Bus 001 Device 011: ID 22b8:2e82 Motorola PCS XT1541 [Moto G 3rd Gen]
$ echo '# moto g31
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8" ATTR{idProduct}=="2e82", MODE="0660", GROUP="plugdev", SYMLINK+="android%n"' | sudo tee -a /etc/udev/rules.d/51-android.rules (2)
$ sudo udevadm control --reload (3)
$ adb devices (4)
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
ZY22DZ5M6C      device (5)
  1. AndroidデバイスのVID/PIDを確認
  2. udevへ登録
  3. udevをリロードして反映
  4. adbコマンドでデバイスが認識されるか確認

この状態でScrcpyを実行します.オーディオについては既定値で有効になっています.

$ scrcpy
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 5.2 MB/s (52867 bytes in 0.010s)
[server] INFO: Device: motorola moto g31(w) (Android 12)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 22.3.3
INFO: Trilinear filtering enabled
INFO: Initial texture: 1080x2400

この状態でAndroid側で音の出るアプリケーションを試すとPCから音が出てAndroid側からは音が出ずいい感じです.Bluetooth 接続と違い遅延も感じません.

scrcpy2.0 duolingo

Pavucontrol を確認しても scrcpy が居ます.

scrcpy2.0 pulseaudio

Scrcpy オーディオ非対応のAndroid 9(10 以前)端末でも試してみたところ以下のような警告が表示され,音は転送されませんでした.

[server] INFO: Device: TINNO C330 (Android 9)
[server] WARN: Audio disabled: it is not supported before Android 11

オーディオ転送を行いたくない場合は --no-audio オプションが利用できます.
以下オーディオ関連のオプションです.音がきれいに聞こえない場合は --audio-buffer=ms を設定する(既定値50から増やす)と良さそうです

 scrcpy --help | grep -- -audio
    --audio-bit-rate=value
    --audio-buffer=ms
    --audio-codec=name
    --audio-codec-options=key[:type]=value[,...]
    --audio-encoder=name
        by --audio-codec).
    --no-audio
    --require-audio
環境
$ scrcpy --version
scrcpy 2.0 <https://github.com/Genymobile/scrcpy>

Dependencies (compiled / linked):
 - SDL: 2.26.3 / 2.26.3
 - libavcodec: 59.37.100 / 59.37.100
 - libavformat: 59.27.100 / 59.27.100
 - libavutil: 57.28.100 / 57.28.100
 - libavdevice: 59.7.100 / 59.7.100
 - libusb: - / 1.0.26
 $ dpkg-query -W ffmpeg libsdl2-2.0-0 adb wget gcc git pkg-config meson ninja-build libsdl2-dev libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev libswresample-dev libusb-1.0-0 libusb-1.0-0-dev adb
adb     1:29.0.6-26
ffmpeg  7:5.1.2-3
gcc     4:12.2.0-3
git     1:2.39.2-1.1
libavcodec-dev:amd64    7:5.1.2-3
libavdevice-dev:amd64   7:5.1.2-3
libavformat-dev:amd64   7:5.1.2-3
libavutil-dev:amd64     7:5.1.2-3
libsdl2-2.0-0:amd64     2.26.3+dfsg-1
libsdl2-2.0-0:i386      2.26.3+dfsg-1
libsdl2-dev:amd64       2.26.3+dfsg-1
libswresample-dev:amd64 7:5.1.2-3
libusb-1.0-0:amd64      2:1.0.26-1
libusb-1.0-0:i386       2:1.0.26-1
libusb-1.0-0-dev:amd64  2:1.0.26-1
meson   1.0.0-1.1
ninja-build     1.11.1-1
pkg-config:amd64        1.8.1-1
wget    1.21.3-1+b2
$ lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux bookworm/sid
Release:        n/a
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/03/13/scrcpy-2-0-audio/feed/ 0
Nostr の Vanity address を掘る https://matoken.org/blog/2023/03/01/nostr-vanity-adress/ https://matoken.org/blog/2023/03/01/nostr-vanity-adress/#comments Wed, 01 Mar 2023 13:42:34 +0000 https://matoken.org/blog/?p=3864

Nostr という分散型SNSのプロトコルがあって最近良く見かけます.

このSNSの個人認識に秘密鍵と公開鍵のペアを作成してそれを利用します.鍵ペアは初回に自動生成されるのですが,公開鍵の文字列をたくさん計算して好みのアドレスが含まれたアドレスを掘るプログラムがあったので試してみました.

このプログラムはbech32で表現される公開鍵の npub1 の後ろの文字列を任意の文字列から始まるものにしたいというvanity アドレスを彫りたい人向けのものです.

導入

cargo insrtall で導入できるはずですが,手元のDebian bookworm testing amd64 環境ではrustc が 1.63 に対してrana は 1.64.0 以上が必要だということで古くて失敗しました.

$ cargo install rana
    Updating crates.io index
  Installing rana v0.5.1
  Downloaded is-terminal v0.4.4
  Downloaded clap_lex v0.3.2
  Downloaded syn v1.0.109
  Downloaded bip39 v1.2.0
  Downloaded 4 crates (346.5 KB) in 2.86s
error: failed to compile `rana v0.5.1`, intermediate artifacts can be found at `/tmp/cargo-installvCF9z2`

Caused by:
  package `clap_derive v4.1.0` cannot be built because it requires rustc 1.64.0 or newer, while the currently active rustc version is 1.63.0
  Try re-running cargo install with `--locked`
$ dpkg-query -W rustc
rustc   1.63.0+dfsg1-2

Rust Forge で新しいStable(1.67.1)を貰ってきて使おうかとも思いましたが,インストーラーを叩く形で環境が汚れそうで少し面倒そう.

Docker を使うことにします.

公式イメージだけあって最新の 1.67.1 です.rana もさくっと動きました.

$ script ./nostr_vanity.log
$ docker run --rm -it rust
# rustc --version
rustc 1.67.1 (d5a82bbd2 2023-02-07)
# adduser matoken
# su - matoken
$ export PATH=/usr/local/cargo/bin:$PATH
$ rustup default stable
$ cargo install rana
$ rana --help
Rana 🐸

      o  o
     ( -- )
  /\( ,   ,)/\
^^   ^^  ^^   ^^

A simple CLI to generate nostr vanity addresses

Francisco Calderón <negrunch@grunch.dev>

Usage: rana [OPTIONS]

Options:
  -d, --difficulty <DIFFICULTY>
          Enter the number of starting bits that should be 0. [default: 0]
  -v, --vanity <VANITY_PREFIX>
          Enter the prefix your public key should have when expressed
          as hexadecimal. [default: ]
  -n, --vanity-n-prefix <VANITY_NPUB_PREFIXES_RAW_INPUT>
          Enter the prefix your public key should have when expressed
          in npub format (Bech32 encoding). Specify multiple vanity
          targets as a comma-separated list. [default: ]
  -s, --vanity-n-suffix <VANITY_NPUB_SUFFIXES_RAW_INPUT>
          Enter the suffix your public key should have when expressed
          in npub format (Bech32 encoding). Specify multiple vanity
          targets as a comma-separated list. [default: ]
  -c, --cores <NUM_CORES>
          Number of processor cores to use [default: 4]
  -r, --restore <MNEMONIC>
          Restore from mnemonic to public private key [default: ]
  -g, --generate <WORD_COUNT>
          Generate mnemonic using wordcount. Should be 12,18 or 24 [default: 0]
  -p, --passphrase <MNEMONIC_PASSPHRASE>
          Passphrase used for restoring mnemonic to keypair [default: ]
  -q, --qr
          Print QR code of the private key
  -h, --help
          Print help
  -V, --version
          Print version

why can’t we use characters b, i, o, or 1?
the characters have to be in the bech32 character set.

— nostrogen
https://github.com/tonyinit/nostrogen#why-cant-we-use-characters-b-i-o-or-1

公開鍵は Bech32 形式で 023456789acdefghjklmnpqrstuvwxyz が利用できます.以下は Bech32 で使えない o を使って怒られた例です.

$ rana --vanity-n-prefix matok
thread 'main' panicked at 'The vanity npub prefix can only contain characters supported by Bech32: 023456789acdefghjklmnpqrstuvwxyz', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rana-0.5.1/src/cli.rs:146:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

oを0に置き換えて動かしてみます.

$ rana --vanity-n-prefix mat0k | tee rana.log
Started mining process for vanity bech32 prefix[es]: 'npub1["mat0k"]' (estimated pow: 20)
Benchmarking of cores disabled for vanity npub key upon proper calculation.
Mining using 4 cores...

さて,これで待っていれば鍵が掘れるのですが,以下のように新しいラップトップで以下のような速度で掘れるとのことです.あまり長くするとなかなか掘れないので気をつけましょう.

how fast will nostrogen find my addresses?
this depends entirely upon how fast your machine is, but here are some rough estimates for a modern laptop or mobile phone:

1 character = usually less than a 0.1 seconds
2 characters = usually less than a 1 second
3 characters = usually less than a 30 seconds
4 characters = usually less than a 10 minutes
5 characters = usually less than a 1 hour
6+ characters = keep fire extinguisher handy

— nostrogen
https://github.com/tonyinit/nostrogen#how-fast-will-nostrogen-find-my-addresses

以下のような感じで結果が表示されます.Npub public key の npub1の後ろが指定したmat0kから始まっています.

$ rana --vanity-n-prefix mat0k | tee rana.log
Started mining process for vanity bech32 prefix[es]: 'npub1["mat0k"]' (estimated pow: 20)
Benchmarking of cores disabled for vanity npub key upon proper calculation.
Mining using 4 cores...
<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
Vanity npub found:         mat0k
Found matching Nostr public key:
Hex public key:   df56fb6cce5a60eac0a55b09ff6d5fbb565b07da6f64a2578ae827d70a21873b
Hex private key:  7a1a088022c3110fabc445af28681c0d2c349a2123f38fe83fbc809d7c8ed6bb
Npub public key:  npub1mat0kmxwtfsw4s99tvyl7m2lhdt9kp76daj2y4u2aqnawz3psuass9qwnz
Nsec private key: nsec10gdq3qpzcvgsl27ygkhjs6qup5krfx3py0ecl6plhjqf6lyw66as4gyfat
26169409 iterations (about 2x10^7 hashes) in 3199 seconds. Avg rate 8180 hashes/second
Warning
公開されているこの鍵は利用しないでください

手元の,NotePCの Intel® Core™ i5-7300U CPU @ 2.60GHz と Oeracle Free Tier VPS Arm Ampere A1 共に8000〜8200 hashes/secod という感じでした.

3日ほど走らせて mak0 から始まるものたくさん,mat0ke から始まるものが2つ出てきました. cpu fan うるさいしmat0ken は諦めてこの辺にしとこうかな?

Npub public key: npub1mat0kejpylctwszs3h0jcaw24vsmzvx0h44hl2qf3ghuz2ggekjqkwyeq5

そういえば以前はTor の Vanity address も掘っていました…….

]]>
https://matoken.org/blog/2023/03/01/nostr-vanity-adress/feed/ 1
Windows/Linux環境で動作する視差壁紙エンジンのlwp https://matoken.org/blog/2023/02/27/parallax-wallpaper-engine/ https://matoken.org/blog/2023/02/27/parallax-wallpaper-engine/#respond Sun, 26 Feb 2023 22:25:00 +0000 https://matoken.org/blog/?p=3856

視差壁紙エンジンのlwp というものを試してみました.

動作環境はLinux, Windows です.Linux amd64 環境で試してみました.
lwp のREADME では / に展開するようにとなっていましたがあまりやりたくないのでとりあえずアドホックに動かしました.

$ wget https://github.com/jszczerbinsky/lwp/releases/download/1.5/lwp-linux-x86_64.zip (1)
$ unzip -l ./lwp-linux-x86_64.zip
Archive:  ./lwp-linux-x86_64.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2023-02-19 07:42   etc/
      661  2023-02-19 07:32   etc/default.cfg
     1047  2023-02-22 23:42   etc/lwp.cfg
        0  2023-02-11 05:41   usr/
        0  2023-02-22 23:42   usr/bin/
    30800  2023-02-22 23:42   usr/bin/lwp
        0  2022-09-30 05:27   usr/share/
        0  2022-09-30 05:27   usr/share/lwp/
     1076  2023-02-22 23:42   usr/share/lwp/LICENSE
        0  2022-09-30 05:27   usr/share/lwp/wallpapers/
        0  2023-02-21 07:58   usr/share/lwp/wallpapers/test/
  8294538  2023-02-22 23:42   usr/share/lwp/wallpapers/test/1.bmp
      102  2023-02-22 04:16   usr/share/lwp/wallpapers/test/source
  8294538  2023-02-22 23:42   usr/share/lwp/wallpapers/test/3.bmp
  8294538  2023-02-22 23:42   usr/share/lwp/wallpapers/test/2.bmp
      461  2023-02-22 23:42   usr/share/lwp/wallpapers/test/wallpaper.cfg
        0  2023-02-11 05:41   usr/etc/
      558  2023-02-11 05:41   usr/etc/default.cfg
---------                     -------
 24918319                     18 files
$ mkdir lwp
$ cd lwp
$ unzip ../lwp-linux-x86_64.zip
$ usr/bin/lwp (2)
INFO: User config file not found, opening default config
ERROR: Default config file not found!
Segmentation fault
$ mkdir ~/.config/lwp (3)
$ install ./etc/lwp.cfg ~/.config/lwp/lwp.cfg (4)
$ xrandr | grep \* (5)
   1920x1200     59.96*+
$ vi ~/.config/lwp/lwp.cfg (6)
$ diff -u etc/lwp.cfg ~/.config/lwp/lwp.cfg
--- etc/lwp.cfg 2023-02-22 23:42:43.000000000 +0900
+++ /home/matoken/.config/lwp/lwp.cfg   2023-02-27 03:31:49.160716609 +0900
@@ -25,11 +25,11 @@
 monitor1_h=1080

 # Absolute path to the wallpaper directory
-monitor1_wallpaper=/usr/share/lwp/wallpapers/test
+monitor1_wallpaper=./usr/share/lwp/wallpapers/test (7)

 # Wallpaper size and position relative to Your monitor
 # Wallpaper resolution ratio should be the same as in original image
 monitor1_wallpaper_x=0
 monitor1_wallpaper_y=0
 monitor1_wallpaper_w=1920
-monitor1_wallpaper_h=1080
+monitor1_wallpaper_h=1200 (8)
$ usr/bin/lwp (9)
  1. release からバイナリアーカイブを取得
  2. 展開して実行してみると設定ファイルが見当たらないらしい
  3. 設定ファイルディレクトリを作成
  4. 規定値の設定ファイルをコピー
  5. 解像度を確認,ここでは 1920×1200
  6. 設定ファイルを編集
  7. 壁紙のパスを修正
  8. 解像度を修正
  9. 実行すると壁紙が設定された

Android の壁紙のようで面白いです.ただ,手元の環境では縦サイズが足りません.壁紙の元サイズが 1920×1080 に対してPCの解像度が 1920×1200 なのでそのせいだと思います.

$ file usr/share/lwp/wallpapers/test/*.bmp
usr/share/lwp/wallpapers/test/1.bmp: PC bitmap, Windows 98/2000 and newer format, 1920 x 1080 x 32, cbSize 8294538, bits offset 138
usr/share/lwp/wallpapers/test/2.bmp: PC bitmap, Windows 98/2000 and newer format, 1920 x 1080 x 32, cbSize 8294538, bits offset 138
usr/share/lwp/wallpapers/test/3.bmp: PC bitmap, Windows 98/2000 and newer format, 1920 x 1080 x 32, cbSize 8294538, bits offset 138
環境
$ dpkg-query -W libwayland-server0 gnome-shell
gnome-shell     43.2-2
libwayland-server0:amd64        1.21.0-1
libwayland-server0:i386 1.21.0-1
$ lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux bookworm/sid
Release:        n/a
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/02/27/parallax-wallpaper-engine/feed/ 0
Wayland 環境で任意のウィンドウを最前面に維持する https://matoken.org/blog/2023/02/26/keep-any-window-on-top-in-wayland-environment/ https://matoken.org/blog/2023/02/26/keep-any-window-on-top-in-wayland-environment/#respond Sun, 26 Feb 2023 13:35:26 +0000 https://matoken.org/blog/?p=3853

メディアプレイヤーのmpv で動画を最前面に表示しながら別のアプリケーションを利用したいので T を押して最前面にせってしようとしますがうまく行きません.

mpv(1)だとこんな感じで合っていそう.

Keyboard Control
       T      Toggle stay-on-top (see also --ontop).

引数の --ontop や,Linux ではおそらく関係のない --ontop-level も試してみましたが駄目です.

OPTIONS
       --ontop
              Makes the player window stay on top of other windows.

              On Windows, if combined with fullscreen mode, this causes mpv to be treated as exclusive fullscreen window that bypasses the Desktop Window Manager.

       --ontop-level=<window|system|desktop|level>
              (macOS only) Sets the level of an ontop window (default: window).

              window On top of all other windows.

              system On top of system elements like Taskbar, Menubar and Dock.

              desktop
                     On top of the Dekstop behind windows and Desktop icons.

              level  A level as integer.

Wayland のせいだろうか?と検索すると当たりのようです.

ワークアラウンドとして Alt+space で出てきたメニューから 「最前面に維持する」を選ぶことで実現できました.

wayland window stay ontop

環境
$ dpkg-query -W libwayland-server0 gnome-shell mpv
gnome-shell     43.2-2
libwayland-server0:amd64        1.21.0-1
libwayland-server0:i386 1.21.0-1
mpv     0.35.1-1
$ lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux bookworm/sid
Release:        n/a
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/02/26/keep-any-window-on-top-in-wayland-environment/feed/ 0
標準入力にタイムスタンプを付けてくれるmoreutils の ts コマンドが便利 https://matoken.org/blog/2023/02/05/moreutils-ts/ https://matoken.org/blog/2023/02/05/moreutils-ts/#respond Sun, 05 Feb 2023 13:38:16 +0000 https://matoken.org/blog/?p=3838

moreutils の ts コマンドが便利だったので紹介.

通常のpingはこんな感じ

$ ping ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.052 ms
64 bytes from ::1: icmp_seq=2 ttl=64 time=0.051 ms
64 bytes from ::1: icmp_seq=3 ttl=64 time=0.040 ms
64 bytes from ::1: icmp_seq=4 ttl=64 time=0.049 ms
^C
--- ::1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3067ms
rtt min/avg/max/mdev = 0.040/0.048/0.052/0.004 ms

http(s) の疎通確認の出来る httping には --timestamp/--ts オプションがありタイムスタンプが付けられて便利です.

--timestamp or --ts
       Put a timestamp before the result-lines. Use -v to also show a date.
$ httping 192.168.1.1
PING 192.168.1.1:80 (/):
connected to 192.168.1.1:80 (234 bytes), seq=0 time= 12.53 ms
connected to 192.168.1.1:80 (234 bytes), seq=1 time= 13.34 ms
connected to 192.168.1.1:80 (234 bytes), seq=2 time= 13.16 ms
^CGot signal 2
--- http://192.168.1.1/ ping statistics ---
3 connects, 3 ok, 0.00% failed, time 2578ms
round-trip min/avg/max = 12.5/13.0/13.3 ms
$ httping --timestamp 192.168.1.1
PING 192.168.1.1:80 (/):
22:05:30.798 connected to 192.168.1.1:80 (172 bytes), seq=0 time= 14.99 ms
22:05:31.813 connected to 192.168.1.1:80 (172 bytes), seq=1 time= 14.45 ms
22:05:32.827 connected to 192.168.1.1:80 (172 bytes), seq=2 time= 13.28 ms
^CGot signal 2
--- http://192.168.1.1/ ping statistics ---
3 connects, 3 ok, 0.00% failed, time 2658ms
round-trip min/avg/max = 13.3/14.2/15.0 ms

ping コマンドのman にはそれらしいものは見当たらなかったので,こんな感じで date コマンドの結果を繋いだりしていました.

$ ping ::1 | sed -s "s/^/`date +%F\ %T`\t/"
2023-02-05 21:58:50     PING ::1(::1) 56 data bytes
2023-02-05 21:58:50     64 bytes from ::1: icmp_seq=1 ttl=64 time=0.068 ms
2023-02-05 21:58:50     64 bytes from ::1: icmp_seq=2 ttl=64 time=0.066 ms
2023-02-05 21:58:50     64 bytes from ::1: icmp_seq=3 ttl=64 time=0.042 ms
^C

同じようなことをしてくれる moreutils 内の ts コマンドがありました.

ts: timestamp standard input

$ ping ::1 | ts
Feb 05 22:01:20 PING ::1(::1) 56 data bytes
Feb 05 22:01:20 64 bytes from ::1: icmp_seq=1 ttl=64 time=0.121 ms
Feb 05 22:01:21 64 bytes from ::1: icmp_seq=2 ttl=64 time=0.118 ms
Feb 05 22:01:22 64 bytes from ::1: icmp_seq=3 ttl=64 time=0.115 ms
^C

フォーマット( strftime(3) )を指定して自分好みにも.

$ ping ::1 | ts -m "%F %T"
2023-02-05 22:02:16 PING ::1(::1) 56 data bytes
2023-02-05 22:02:16 64 bytes from ::1: icmp_seq=1 ttl=64 time=0.038 ms
2023-02-05 22:02:17 64 bytes from ::1: icmp_seq=2 ttl=64 time=0.044 ms
2023-02-05 22:02:18 64 bytes from ::1: icmp_seq=3 ttl=64 time=0.066 ms
^C

sed などで書くより良さそうです.(moreutilsの導入が必要だけど)

環境
$ dpkg-query -W iputils-ping moreutils httping
httping 2.5-5.2+b1
iputils-ping    3:20221126-1
moreutils       0.67-1
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux bookworm/sid
Release:        n/a
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/02/05/moreutils-ts/feed/ 0
Debian testing の source.list に non-free-firmware を登録 https://matoken.org/blog/2023/02/02/debian-testing-source-list-non-free-firmware/ https://matoken.org/blog/2023/02/02/debian-testing-source-list-non-free-firmware/#respond Thu, 02 Feb 2023 11:14:59 +0000 https://matoken.org/blog/?p=3835

Debian で non-free-firmware というコンポーネントが増えることになり,実際に移動し始めたとのことで利用できるように設定しました.

/etc/apt/sources.list を編集します.直に編集することも出来ますが, apt edit-sources を使うと保存時に文法チェックをしてくれるのでおすすめです.

$ sudo apt edit-source
編集例
$ sudo git -C /etc diff /etc/apt/sources.list
diff --git a/apt/sources.list b/apt/sources.list
index d9af843..11f6837 100644
--- a/apt/sources.list
+++ b/apt/sources.list
@@ -2,8 +2,8 @@

 #deb cdrom:[Debian GNU/Linux testing _Bookworm_ - Official Snapshot amd64 DVD Binary-1 20220919-00:24]/ bookworm contrib main

-deb http://deb.debian.org/debian/ bookworm main contrib non-free
-deb-src http://deb.debian.org/debian/ bookworm main contrib non-free
+deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
+deb-src http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
 #deb http://security.debian.org/debian-security bookworm-security main contrib
 #deb-src http://security.debian.org/debian-security bookworm-security main contrib

@@ -13,13 +13,13 @@ deb-src http://deb.debian.org/debian/ bookworm main contrib non-free
 # are provided as examples, but you should amend them as appropriate
 # for your mirror of choice.
 #
-deb http://deb.debian.org/debian/ bookworm-updates main contrib non-free
-deb-src http://deb.debian.org/debian/ bookworm-updates main contrib non-free
+deb http://deb.debian.org/debian/ bookworm-updates main contrib non-free non-free-firmware
+deb-src http://deb.debian.org/debian/ bookworm-updates main contrib non-free non-free-firmware

 # bookworm-backports, previously on backports.debian.org
 # A network mirror was not selected during install.  The following entries
 # are provided as examples, but you should amend them as appropriate
 # for your mirror of choice.
 #
-deb http://deb.debian.org/debian/ bookworm-backports main contrib non-free
-deb-src http://deb.debian.org/debian/ bookworm-backports main contrib non-free
+deb http://deb.debian.org/debian/ bookworm-backports main contrib non-free non-free-firmware
+deb-src http://deb.debian.org/debian/ bookworm-backports main contrib non-free non-free-firmware

apt update コマンドでパッケージリストを更新, apt upgrade コマンドでパッケージを最新にします.

$ sudo apt update
$ sudo apt upgrade

早速 non-free-firmware から firmware-iwlwifi が降ってきました.

取得:1 http://deb.debian.org/debian bookworm/non-free-firmware amd64 firmware-iwlwifi all 20221214-5 [20.5 MB]

今回 bookworm(testing) で設定しましたが,sid(unstable) の場合も同様だと思います.

環境
$ lsb_release -a
Distributor ID:	Debian
Description:	Debian GNU/Linux bookworm/sid
Release:	n/a
Codename:	bookworm
$ dpkg-query -W apt dpkg
apt	2.5.5
dpkg	1.21.19
$ arch
x86_64

追記) Bookworm 新規インストールの場合

non-free-firmware が有効になった Debian-Installer Bookworm Alpha 2 が出たので少し試してみました.
パッケージマネージャの設定で,「non-free のファームウェアを使用しますか?」「はい」を選択することで, source.listnon-free-firmware が設定されるのを確認しました.

d i bookworm a2 non free firmware gui
d i bookworm a2 non free firmware cui

]]>
https://matoken.org/blog/2023/02/02/debian-testing-source-list-non-free-firmware/feed/ 0
Wayland 環境の Google Chrome / chromium でタブ以外の画面共有が出来ない https://matoken.org/blog/2023/01/25/wayland-google-chrome-chromium-screenshareing/ https://matoken.org/blog/2023/01/25/wayland-google-chrome-chromium-screenshareing/#respond Wed, 25 Jan 2023 12:32:13 +0000 https://matoken.org/blog/?p=3831

先日の鹿児島Linux勉強会 2023.01 で発表時にGoogle Chrome を利用して画面共有時にChrome のタブしか選択できませんでした.スライドは.html だった(Asciidoctor Reveal.js)ので大丈夫だったのですが,別アプリケーションのデモを共有することが出来ませんでした.
先月は出来ていたのになぜだろうと調べてみました.

wayland chrome screenshareing NG
図 1. Chromeのタブしか共有できない

結果から言うとWayland環境でのGoogle Chrome のバグのようです.ワークアラウンドとして chrome://flags で 「WebRTC PipeWire support」という項目( chrome://flags/#enable-webrtc-pipewire-capturer )を「Enabled」に設定変更してウェブブラウザを再起動することで画面共有できるようになりました.この項目はバグが直ったら既定値になるようです.

wayland chrome screenshareing flags
例 1. chrome://flags/#enable-webrtc-pipewire-capturer

WebRTC PipeWire support
When enabled the WebRTC will use the PipeWire multimedia server for capturing the desktop content on the Wayland display server.

wayland chrome screenshareing OK
図 2. ウィンドウ共有や,デスクトップ共有も出来るようになった.

なお,Chromium, Brave も同様でした.Firefox については規定値のままで「単一のウインドウ」「画面全体」の共有が可能でした.
ということでWayland環境のウェブブラウザで画面共有をしたい場合はFirefoxを使うのが楽そうです.

Wayland困ることが少なくなったと思っていたのですが,まだぽつぽつこれ出来ないのかということに引っかかりますね><

環境
$ dpkg-query -W google-chrome-stable chromium brave-browser firefox-esr
brave-browser   1.47.171
chromium        109.0.5414.74-2
firefox-esr     102.6.0esr-1
google-chrome-stable    109.0.5414.74-1
$ lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux bookworm/sid
Release:        n/a
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/01/25/wayland-google-chrome-chromium-screenshareing/feed/ 0
日本語環境のPlayOnLinuxでリスト読み込みが出来ない https://matoken.org/blog/2023/01/24/cant-read-list-in-playonlinux-in-japanese-environment/ https://matoken.org/blog/2023/01/24/cant-read-list-in-playonlinux-in-japanese-environment/#respond Tue, 24 Jan 2023 13:05:59 +0000 https://matoken.org/blog/?p=3828

PlayOnLinuxというWineのラッパーが有ります.これを起動するとリストをリモートから読み込むはずなのですが,読み込み中のまま進まないという話を鹿児島Linux勉強会 2023.01 で聞きました.手元で試してみました.

Debian bookworm testing amd64 環境で apt install playonlinux として導入して起動すると確かに読み込み中から先に進みません.

playonlinux loop

以下の記事によると日本語の翻訳ミスが原因のようです.(以前の環境では en_US.UTF-8 環境だったりもしたので動いていたのかな?)

このページを真似して以下のように修正してPlayOnLinux を起動し直すと読み込みがされるようになりました.

$ msgunfmt /usr/share/locale/ja/LC_MESSAGES/pol.mo -o /tmp/pol.po (1)
$ vi /tmp/pol.po (2)
$ diff -u /tmp/pol.po.org /tmp/pol.po (3)
--- /tmp/pol.po.org     2023-01-24 04:45:59.897079913 +0900
+++ /tmp/pol.po 2023-01-24 06:46:07.853063925 +0900
@@ -494,7 +494,7 @@
 msgstr "更新"

 msgid "Refreshing {0}"
-msgstr "{0 }をリフレッシュ中"
+msgstr "{0}をリフレッシュ中"

 msgid "Registry Editor"
 msgstr "レジストリエディタ"
$ msgfmt /tmp/pol.po -o /tmp/pol.mo (4)
$ sudo mv /tmp/pol.mo /usr/share/locale/ja/LC_MESSAGES/pol.mo (5)
  1. 翻訳バイナリファイルを人間の読める.po形式に変換
  2. .po を編集
  3. 編集内容({}内のスペースを消した)
  4. 編集した .po から .mo を作成
  5. ディストリビューションの .mo を上書き

しかしPlayOnLinuxのアップデートで上書きされてしまいますね…….ということで大本がどうなっているか確認してみます.

PlayOnLinuxの翻訳を確認するとlaunchpadで翻訳しているようで,該当部分を確認するとCurrent Japaneseは間違ったまま.Suggestionsに修正が来ていた(2017年!)のでReviewしておきました.

playonlinux trans01
playonlinux trans02

これでそのうち取り込まれるかな?

とりあえず以下から直った .mo をダウンロードできるはずなので,それを /usr/share/locale/ja/LC_MESSAGES/pol.mo に上書きでも直ると思います.

環境
$ dpkg-query -W playonlinux gettext
gettext 0.21-10
playonlinux     4.3.4-3
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux bookworm/sid
Release:        n/a
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/01/24/cant-read-list-in-playonlinux-in-japanese-environment/feed/ 0
自動ログイン状態の Gnome 43 のリモートデスクトップでパスワードが勝手に変わってしまい困る https://matoken.org/blog/2023/01/24/gnome-43-remote-desktop/ https://matoken.org/blog/2023/01/24/gnome-43-remote-desktop/#respond Mon, 23 Jan 2023 21:31:00 +0000 https://matoken.org/blog/?p=3825

日曜日の鹿児島Linux勉強会 2023.01 でGnome 42の自動ログイン環境でリモートデスクトップ機能を有効にすると毎回パスワードが変わってしまいヘッドレスで使いたいのにリモートログインのためには画面を確認しないといけなくて不便という話を聞いたので少し調べてみました.
ただし環境は少し違ってGnome 43です.

リモートデスクトップを有効にする

「設定」→「共有」→ 「リモートデスクトップ」で「リモートデスクトップ」と「リモートコントロール」を有効にして認証の「パスワード」を変更するか記録しておきます.

gnome remote desktop
Tip
「リモートデスクトップ」の項目がない場合,Debian では gnome-remote-desktop パッケージを導入すれば出てくると思います.

通常のログイン

ディスプレイマネージャーで手動でパスワードを入力するログインを行い,設定を確認するとパスワードは変わらずログインも出来ます.

自動ログイン

「設定」→「ユーザー」で「ロック解除」を行い,「自動ログイン」を有効にして再起動してみます.

gnome autologin

自動ログイン後設定を確認すると新しいランダムなパスワードが設定されています.
現象が確認できました.

パスワードマネージャのマスターパスワードをNULLに変更

以下のページを見るとGnomeのキーリングは既定値ではログインパスワードと同一でログイン時のパスワード入力で一緒に解除され,リモートデスクトップがアクセスできるようになる.自動ログインを有効にするとこのマスターパスワードの解除が自動で行われず,リモートデスクトップがパスワードがわからずランダムなパスワードを設定するという感じのようです.

ということでワークアラウンドとして,「パスワードと鍵」(Seahorse)でマスターパスワードを「」(NULL) にすることで自動ログインでもリモートデスクトップのパスワードが勝手に変わらなくなりました.

seahorse

しかしセキュリティ的にイマイチなのでGnomeのリモートデスクトップは使わずx11vnc(Waylandだと利用不可)やxrdpで利用するようにしたほうがいい気がします.

環境

$ dpkg-query -W gnome-shell gnome-remote-desktop seahorse remmina
gnome-remote-desktop    43.3-1
gnome-shell     43.2-1
remmina 1.4.27+dfsg-2+b1
seahorse        43.0-1
$ lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux bookworm/sid
Release:        n/a
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/01/24/gnome-43-remote-desktop/feed/ 0
Pandoc 3.0 で pandoc-server を少し試す https://matoken.org/blog/2023/01/21/try-pandoc-server/ https://matoken.org/blog/2023/01/21/try-pandoc-server/#respond Fri, 20 Jan 2023 20:51:26 +0000 https://matoken.org/blog/?p=3822

各種ファイル変換をしてくれるPandoc が久々にメジャーバージョンアップして 3.0 になりました.

手元の端末に入れて少し触ってみました.

ディストリビューションパッケージのPandoc をアンインストール
$ sudo apt remove pandoc pandoc-data
GitHub のRelease からPandoc 3.0の amd64 の.deb を入手してインストール
$ wget https://github.com/jgm/pandoc/releases/download/3.0/pandoc-3.0-1-amd64.deb
$ sudo apt install ./pandoc-3.0-1-amd64.deb
$ $ apt show pandoc -a
Package: pandoc
Version: 3.0-1
Status: install ok installed
Priority: optional
Section: text
Maintainer: John MacFarlane <jgm@berkeley.edu>
Installed-Size: 129 MB
Depends: libc6 (>= 2.13), libgmp10, zlib1g (>= 1:1.1.4)
Suggests: texlive-latex-recommended, texlive-xetex, texlive-fonts-recommended
Replaces: pandoc-data
Download-Size: 不明
APT-Manual-Installed: yes
APT-Sources: /var/lib/dpkg/status
Description: general markup converter
  Pandoc is a Haskell library for converting from one markup format
  to another, and a command-line tool that uses this library. The
  formats it can handle include light markup formats (many variants
  of Markdown, reStructuredText, AsciiDoc, Org-mode, Muse, Textile,
  txt2tags), HTML formats (HTML 4 and 5), ebook formats (EPUB v2
  and v3, FB2), Documentation formats (GNU TexInfo, Haddock),
  Roff formats (man, ms), TeX formats (LaTeX, ConTeXt), XML
  formats (DocBook 4 and 5, JATS, TEI Simple, OpenDocument),
  outline formats (OPML), bibliography formats (BibTeX, BibLaTeX,
  CSL JSON, CSL YAML, RIS), word processor formats (Docx, RTF,
  ODT), interactive notebook formats (Jupyter notebook
  ipynb), page layout formats (InDesign ICML), wiki markup
  formats (MediaWiki, DokuWiki, TikiWiki, TWiki, Vimwiki,
  XWiki, ZimWiki, Jira wiki, Creole), slide show formats
  (LaTeX Beamer, PowerPoint, Slidy, reveal.js, Slideous, S5,
  DZSlides), data formats (CSV and TSV tables), and PDF (via
  external programs such as pdflatex or wkhtmltopdf).

Package: pandoc
Version: 2.17.1.1-1.1
Priority: optional
Section: text
Maintainer: Debian Haskell Group <debian-haskell@lists.debian.org>
Installed-Size: 172 MB
Provides: pandoc-abi (= 1.22.2.1-1)
Depends: libc6 (>= 2.34), libffi8 (>= 3.4), libgmp10 (>= 2:6.2.1+dfsg1), liblua5.3-0, libyaml-0-2, zlib1g (>= 1:1.1.4), pandoc-data (>= 2.17.1.1-1.1), pandoc-data (<< 2.17.1.1-1.1.~)
Suggests: texlive-latex-recommended, texlive-xetex, texlive-luatex, pandoc-citeproc, texlive-latex-extra, context, wkhtmltopdf, librsvg2-bin, groff, ghc, nodejs, php, perl, python, ruby, r-base-core, libjs-mathjax, libjs-katex, citation-style-language-styles
Homepage: https://pandoc.org/
Tag: devel::doc, implemented-in::haskell, interface::commandline,
 role::documentation, role::program, use::converting,
 works-with-format::bib, works-with-format::docbook,
 works-with-format::html, works-with-format::json,
 works-with-format::man, works-with-format::odf,
 works-with-format::plaintext, works-with-format::tex,
 works-with-format::xml, works-with::text
Download-Size: 21.3 MB
APT-Sources: http://deb.debian.org/debian bookworm/main amd64 Packages
Description: general markup converter
 Pandoc is a Haskell library for converting
 from one markup format to another,
 and a command-line tool that uses this library.
 The formats it can handle include
  * light markup formats
    (many variants of Markdown, reStructuredText, AsciiDoc,
     Org-mode, Muse, Textile, txt2tags)
  * HTML formats (HTML 4 and 5)
  * Ebook formats (EPUB v2 and v3, FB2)
  * Documentation formats (GNU TexInfo, Haddock)
  * Roff formats (man, ms)
  * TeX formats (LaTeX, ConTeXt)
  * XML formats
    (DocBook 4 and 5, JATS, TEI Simple, OpenDocument)
  * Outline formats (OPML)
  * Bibliography formats (BibTeX, BibLaTeX, CSL JSON, CSL YAML)
  * Word processor formats (Docx, RTF, ODT)
  * Interactive notebook formats (Jupyter notebook ipynb)
  * Page layout formats (InDesign ICML)
  * Wiki markup formats
    (MediaWiki, DokuWiki, TikiWiki, TWiki,
     Vimwiki, XWiki, ZimWiki, Jira wiki, Creole)
  * Slide show formats
    (LaTeX Beamer, PowerPoint, Slidy,
     reveal.js, Slideous, S5, DZSlides)
  * Data formats (CSV tables)
  * PDF (via external programs such as pdflatex or wkhtmltopdf)
 .
 Pandoc can convert mathematical content in documents
 between TeX, MathML, Word equations, roff eqn, and plain text.
 It includes a powerful system
 for automatic citations and bibliographies,
 and it can be customized extensively using templates, filters,
 and custom readers and writers written in Lua.
 .
 This package contains the pandoc tool.
 .
 Some uses of Pandoc require additional packages:
  * SVG content in PDF output requires librsvg2-bin.
  * YAML metadata in TeX-related output requires texlive-latex-extra.
  * *.hs filters not set executable requires ghc.
  * *.js filters not set executable requires nodejs.
  * *.php filters not set executable requires php.
  * *.pl filters not set executable requires perl.
  * *.py filters not set executable requires python.
  * *.rb filters not set executable requires ruby.
  * *.r filters not set executable requires r-base-core.
  * LaTeX output, and PDF output via PDFLaTeX,
    require texlive-latex-recommended.
  * XeLaTeX output, and PDF output via XeLaTeX, require texlive-xetex.
  * LuaTeX output, and PDF output via LuaTeX, require texlive-luatex.
  * ConTeXt output, and PDF output via ConTeXt, require context.
  * PDF output via wkhtmltopdf requires wkhtmltopdf.
  * Roff man and roff ms output, and PDF output via roff ms,
    require groff.
  * MathJax-rendered equations require libjs-mathjax.
  * KaTeX-rendered equations require node-katex.
  * option --csl may use styles in citation-style-language-styles.
$ dpkg -L pandoc
/.
/usr
/usr/bin
/usr/bin/pandoc
/usr/share
/usr/share/doc
/usr/share/doc/pandoc
/usr/share/doc/pandoc/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/pandoc-lua.1.gz
/usr/share/man/man1/pandoc-server.1.gz
/usr/share/man/man1/pandoc.1.gz
/usr/bin/pandoc-lua
/usr/bin/pandoc-server
$ pandoc-server -v
pandoc-server 3.0
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.
$ ls -l /bin/pandoc*
-rwxr-xr-x 1 root root 128885952  1月 19 06:00 /bin/pandoc
lrwxrwxrwx 1 root root         6  1月 19 06:00 /bin/pandoc-lua -> pandoc
lrwxrwxrwx 1 root root         6  1月 19 06:00 /bin/pandoc-server -> pandoc
対応フォーマットの数
$ pandoc --list-input-formats | wc -l
42
$ pandoc --list-output-formats | wc -l
63

Pandoc Server を少し試す

Pandocサーバ起動
$ pandoc-server
Starting server on port 3030...
Pandocサーババージョン確認
$ http http://localhost:3030/version
HTTP/1.1 200 OK
Content-Type: text/plain;charset=utf-8
Date: Fri, 20 Jan 2023 13:24:51 GMT
Server: Warp/3.3.23
Transfer-Encoding: chunked

3.0
絵文字をPandocサーバでhtmlに変換
$ http POST http://localhost:3030/ text=:+1: from=markdown+emoji to=html4 Accept:text/plain
HTTP/1.1 200 OK
Content-Type: text/plain;charset=utf-8
Date: Fri, 20 Jan 2023 20:40:17 GMT
Server: Warp/3.3.23
Transfer-Encoding: chunked

<p><span class="emoji" data-emoji="+1">👍</span></p>
MarkdownファイルをPandocサーバでhtmlに変換
$ head ~/src/tilck/README.md (1)
<p align="center">
   <img src="http://vvaltchev.github.io/tilck_imgs/v2/tilck-logo-v5.png" alt="Tilck - A Tiny Linux-Compatible Kernel">
</p>

[![Build Status](https://vkvaltchev.visualstudio.com/Tilck/_apis/build/status/Tilck?branchName=master)](https://vkvaltchev.visualstudio.com/Tilck/_build/latest?definitionId=1&branchName=master)
[![codecov](https://codecov.io/gh/vvaltchev/tilck/branch/master/graph/badge.svg)](https://codecov.io/gh/vvaltchev/tilck)
[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause)

<a href="https://youtu.be/Ce1pMlZO_mI">
   <img
$ http POST http://localhost:3030/ text=@~/src/tilck/README.md from=markdown+emoji to=html4 Accept:text/plain | head (2)
<p align="center">
<img src="http://vvaltchev.github.io/tilck_imgs/v2/tilck-logo-v5.png" alt="Tilck - A Tiny Linux-Compatible Kernel">
</p>
<p><a
href="https://vkvaltchev.visualstudio.com/Tilck/_build/latest?definitionId=1&amp;branchName=master"><img
src="https://vkvaltchev.visualstudio.com/Tilck/_apis/build/status/Tilck?branchName=master"
alt="Build Status" /></a> <a
href="https://codecov.io/gh/vvaltchev/tilck"><img
src="https://codecov.io/gh/vvaltchev/tilck/branch/master/graph/badge.svg"
alt="codecov" /></a> <a
$ http POST http://localhost:3030/ text=@~/src/tilck/README.md from=markdown+emoji to=html4 Accept:text/plain | w3m -T text/html -dump | head (3)
                    Tilck - A Tiny Linux-Compatible Kernel

Build Status codecov License

Tilck

Contents

  • Overview
      □ What is Tilck?
  1. Markdownファイル確認
  2. htmlに変換
  3. Markdownをhtmlに変換してw3mでレンダリング
環境
$ dpkg-query -W pandoc httpie w3m
httpie  3.2.1-1
pandoc  3.0-1
w3m     0.5.3+git20220429-1+b1
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux bookworm/sid
Release:        n/a
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2023/01/21/try-pandoc-server/feed/ 0
FUJISOFT F030W 設定メモ https://matoken.org/blog/2023/01/19/fujisoft-f030w-setting/ https://matoken.org/blog/2023/01/19/fujisoft-f030w-setting/#respond Thu, 19 Jan 2023 12:03:15 +0000 https://matoken.org/blog/?p=3814

中古でモバイルルータのFUJISOFT F030W とクレードル(RJ45)付きを3.5kで入手しました.設定メモです.(何気に初めてのモバイルルータです)

初期設定

  • 背面の蓋を外してバッテリーを外すことでmicroSIMスロットx1にアクセスできる.スライドロック式なのでアダプタ経由でも詰まったりしにくい.
  • microUSBケーブルで充電(5V 1.5A)
  • 電源の入った状態で背面の蓋を外し,RESETボタンを長押しして工場出荷時状態に
  • 起動したら液晶面のボタンを一回押して表示される接続情報のAPに接続
  • http://192.168.100.1/ へアクセス
Note
初期パスワードは admin
  • ソフトウェアアップデート
    • オンラインアップデート
Note
バッテリー40%以上無いと処理が始まらない.FS030W_V4.0.0 99.7MB になった
Note
オフラインアップデートは現在siteからFWが入手できない?
Note
クレードルで自宅ネットワークなどに繋いでAPモードにするとパケットを消費せずにファームウェアダウンロードができそう(未確認)
  • モバイルネットワーク設定
    • プロファイル設定 でAPN設定.
  • LAN設定
    • プライマリ無線LAN設定
      • SSID/セキュリティキー → 変更
      • 周波数 → 5GHz W56 に変更(2.4GHzに戻ってしまう?DFS?)
  • WPS → 無効
  • Bluetoothテザリング → 有効
    • システム設定
  • ログインパスワード → 変更
  • スリープ設定 → 有効
Note
スリープ解除は本体ボタン
  • 充電設定 → ロングライフモード有効(60%〜70%を維持しようとする)
Note
電源off時に給電すると100%まで充電される

Linuxでの動き

USB接続時のdmesg
[68082.524110] usb 1-6: reset high-speed USB device number 3 using xhci_hcd
[72490.758736] usb 1-1: new high-speed USB device number 12 using xhci_hcd
[72490.927081] usb 1-1: New USB device found, idVendor=1c9e, idProduct=f133, bcdDevice= 2.32
[72490.927103] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[72490.927112] usb 1-1: Product: USB Modem
[72490.927119] usb 1-1: Manufacturer: USB Modem
[72490.982273] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-0000:00:14.0-1, RNDIS device, 86:ca:ce:1e:2d:37
[72491.697333] rndis_host 1-1:1.0 enx86cace1e2d37: renamed from usb0
Note

Linux 2.6.27 – 6.1 drivers/net/usb/rndis_host.c

lsusb
$ lsusb -d 1c9e:f133
Bus 001 Device 012: ID 1c9e:f133 OMEGA TECHNOLOGY USB Modem
Tip
クレードル経由のUSB接続だとおそらく給電のみ
Note
同じVID/PIDで別の製品もあるよう
ip
$ ip addr show dev enx86cace1e2d37
11: enx86cace1e2d37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
    link/ether 86:ca:ce:1e:2d:37 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.24/24 brd 192.168.100.255 scope global dynamic noprefixroute enx86cace1e2d37
       valid_lft 86123sec preferred_lft 86123sec
    inet6 2400:2200:3f5:3810:2962:d045:ab7b:b1a2/64 scope global temporary dynamic
       valid_lft 86358sec preferred_lft 14358sec
    inet6 2400:2200:3f5:3810:84ca:ceff:fe1e:2d37/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 86358sec preferred_lft 14358sec
    inet6 fe80::84ca:ceff:fe1e:2d37/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
Linuxぽい?
$ sudo nmap -AO 192.168.100.1
Starting Nmap 7.92 ( https://nmap.org ) at 2023-01-14 04:41 JST
Nmap scan report for FS030W.lan (192.168.100.1)
Host is up (0.0020s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
53/tcp open  domain  dnsmasq 2.68
| dns-nsid:
|_  bind.version: dnsmasq-2.68
80/tcp open  http?
|_http-title: Site doesn't have a title (text/html).
MAC Address: 00:23:B1:94:98:53 (Longcheer Technology (Singapore) Pte)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.10 - 4.11
Network Distance: 1 hop

TRACEROUTE
HOP RTT     ADDRESS
1   1.97 ms FS030W.lan (192.168.100.1)

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 97.71 seconds
Tip

Linux 3.19 を使っているよう
* OSS list

Androidアプリ

設定自体はWebに飛ばされる.
Androidアプリでしか使えない機能はない?

メッセージが中国語になったりもした.

FUJISOFT F030W

アプリの更新も長らく無いようだし(最終更新日 2020/07/06)入れないほうがいいかもしれない.

Note
iOSアプリもあるようだが未確認

バッテリーレス運用

バッテリーを外した状態で給電することで普通に使えそう.
NotePC(Panasonic CF-SZ6)やモバイルバッテリーで動作するのを確認.

Tip
ファームウェアアップデートはバッテリー40%以上が必要なので不可だった.

その他

  • スリープから復帰時にアンテナマークが点滅し続けてmobile回線につながらない状態になった → 再起動で復帰

URL

富士ソフトということで国内開発かと思っていたのですが,OEM(OMEGA TECHNOLOGY)のようで少し残念.
同じくらいの値段の NEC Aterm MR04LN の方が良かったかもしれません.(デュアルSIMだし)

]]>
https://matoken.org/blog/2023/01/19/fujisoft-f030w-setting/feed/ 0
Chromiumのheadless環境でPDFがうまく出力されなくなって困った https://matoken.org/blog/2022/11/29/pdf-is-no-longer-output-well-in-chromiums-headless-environment/ https://matoken.org/blog/2022/11/29/pdf-is-no-longer-output-well-in-chromiums-headless-environment/#respond Mon, 28 Nov 2022 23:18:14 +0000 http://matoken.org/blog/?p=3782

最近のスライドは Asciidoc で書いて,Reveal.js のhtml に変換して発表,そのhtml をChrome のheadless モードでPDF に変換していました.
こけれを行っていた端末を変更したせいかこれがうまくいかなくなりました.

引数はこんな感じで

               chromium --user-data-dir=$TMPDIR --headless --disable-gpu --print-to-pdf="${PDF}" "$URL?print-pdf"; \

出力されるPDFはCSSが足りないようなものや,真っ白なものになります.

revealjs2pdf01
revealjs2pdf02

make から呼んでいるので手動でコマンドラインから実行しても同じ, --headless オプションを削って手動で Ctrl + p でPDF 出力すれば問題なく出力されます.

Firefox にはPDF 出力オプションはないのですが画像出力ができるので画像書き出しをしてみると求める結果になりました.

$ firefox --screenshot /tmp/page.png --window-size=1280 "file:///`pwd`/slide.html#print-pdf"

各ページをこれで画像に出力して結合してPDFにすることも可能ですが,文字情報が消えてしまいます…….

wkhtmltopdf も試すと以下のようなコマンドで近いものが出来ますがサイズや余白,フォントが違います.もう少し頑張れば良く出来そう?

$ wkhtmltopdf --enable-local-file-access --orientation Landscape --page-size B5 --margin-top 0 --margin-bottom 0 --margin-right 0 --margin-left 0 "file://`pwd`/slide/slide.html?print-pdf" /tmp/slide.pdf

検索して以下のページを見つけました.

こちらを参考にChromium に --run-all-compositor-stages-before-draw--virtual-time-budget を指定するようにして書き出せるようになりました. --virtual-time-budget の値については環境により変える必要があるかもしれません.

$ chromium --headless --run-all-compositor-stages-before-draw --virtual-time-budget=9999999 --print-to-pdf=/tmp/slide.pdf file://`pwd`/slide/slide.html?print-pdf

Makefile は以下のように変更.

-               chromium --user-data-dir=$TMPDIR --headless --disable-gpu --print-to-pdf="${PDF}" "$URL?print-pdf"; \
+               chromium --user-data-dir=$TMPDIR --headless --run-all-compositor-stages-before-draw --virtual-time-budget=999999 --print-to-pdf="${PDF}" "$URL?print-pdf"; \

書き出せるようになりました :)

環境
$ dpkg-query -W chromium firefox-esr wkhtmltopdf
chromium        107.0.5304.110-2
firefox-esr     102.5.0esr-1
wkhtmltopdf     0.12.6-2+b1
$ lsb_release -dc
No LSB modules are available.
Description:    Debian GNU/Linux bookworm/sid
Codename:       bookworm
$ arch
x86_64
]]>
https://matoken.org/blog/2022/11/29/pdf-is-no-longer-output-well-in-chromiums-headless-environment/feed/ 0
LinuxのRAMを制限するメモ https://matoken.org/blog/2021/07/17/linux-ram-limit/ https://matoken.org/blog/2021/07/17/linux-ram-limit/#respond Fri, 16 Jul 2021 21:25:29 +0000 http://matoken.org/blog/?p=3310

LinuxでRAMの少ない状態のテストをしたいなと思ってコマンドラインオプションにメモリ制限のオプションをつけて試してみました.

物理RAMモジュールが制限したい容量に刺し直すことができればいいのですが,都合の良いサイズのRAMモジュールがあるとは限りません.Linuxの起動オプションで制限できそうだったので試してみました.

Linuxマシンを起動して,GRUBのメニューで編集したいエントリを矢印上下キーで選択して, e ボタンを押して編集メニューに入ります.
linux /vmlinuz〜 といった行に移動して末尾に追加の起動オプションを追記します.今回はメモリを2GBに制限したいので, mem=2048m を指定します.(実メモリ以上にも設定できるようですがそこを使おうとしたときにクラッシュしそうですね)

linux /vmlinuz-5.13.2-mptcp+le9 root=/dev/mapper/yoga—​260—​vg-root ro
linux /vmlinuz-5.13.2-mptcp+le9 root=/dev/mapper/yoga—​260—​vg-root ro mem=2048m

Ctrl + x を押してこのオプションで起動します.

起動したら確認してみます.

$ cat /proc/cmdline (1)
BOOT_IMAGE=/vmlinuz-5.13.2-mptcp+le9 root=/dev/mapper/yoga--260--vg-root ro mem=2048m
$ head -1 /proc/meminfo (2)
MemTotal:        2032968 kB
$ free (3)
               total        used        free      shared  buff/cache   available
Mem:         2032968     1575032       70032      161360      387904      139588
Swap:              0           0           0
  1. コマンドラインオプションの確認
  2. メモリの確認
  3. メモリの確認

2GBに制限できたようです :)

詳細はKernelドキュメントを

linux-5.13/Documentation/admin-guide/kernel-parameters.txt
        mem=nn[KMG]     [KNL,BOOT] Force usage of a specific amount of memory
                        Amount of memory to be used in cases as follows:

                        1 for test;
                        2 when the kernel is not able to see the whole system memory;
                        3 memory that lies after 'mem=' boundary is excluded from
                         the hypervisor, then assigned to KVM guests.

                        [X86] Work as limiting max address. Use together
                        with memmap= to avoid physical address space collisions.
                        Without memmap= PCI devices could be placed at addresses
                        belonging to unused RAM.

                        Note that this only takes effects during boot time since
                        in above case 3, memory may need be hot added after boot
                        if system memory of hypervisor is not sufficient.

今回の手順はアドホックな手順で再起動すれば元に戻ってしまいます.もし永続化したいのであれば, grub.cfg を書き換えればOKなはずです.今回のDebian Bullseye の場合は, /etc/grub.d/10_linux を編集して sudo update-grub2 の実行で /boot/grub/grub.cfg が更新されます.

環境
$ dpkg-query -W grub2* linux-image-`uname -r` procps
grub2
grub2-common    2.04-19
linux-image-5.13.2-mptcp+le9    5.13.2-mptcp+le9-3
procps  2:3.3.17-5
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ arch
x86_64
]]>
https://matoken.org/blog/2021/07/17/linux-ram-limit/feed/ 0
Debian環境でacpidのログをsyslogに出力する2(acpi event & action) https://matoken.org/blog/2021/07/12/output-acpid-log-to-syslog-part-2-acpi-event-action/ https://matoken.org/blog/2021/07/12/output-acpid-log-to-syslog-part-2-acpi-event-action/#respond Sun, 11 Jul 2021 15:07:13 +0000 http://matoken.org/blog/?p=3301

acpidのイベントをすべてログに出力できるよう設定しました.

しかしちょっと冗長です.ACアダプタの状況だけをロギングするよう設定してみました.

まずACアダプタの抜き差し時のログを確認します.

ACアダプタ切断時
Jul 11 23:05:51 yoga-260 acpid: completed netlink event "ac_adapter ACPI0003:00 00000080 00000000"
ACアダプタ接続時
Jul 11 23:05:55 yoga-260 acpid: received netlink event "ac_adapter ACPI0003:00 00000080 00000001"

manのEXAMPLE を確認します.

man acpidより

EXAMPLE
This example will shut down your system if you press the power button.

Create a file named /etc/acpi/events/power that contains the following:
event=button/power
action=/etc/acpi/power.sh "%e"
Then create a file named /etc/acpi/power.sh that contains the following:
/sbin/shutdown -h now "Power button pressed"
Now,  when  acpid  is  running,  a  press  of  the power button will cause the rule in /etc/acpi/events/power to trigger the script in
/etc/acpi/power.sh.  The script will then shut down the system.

このEXAMPLEを真似してこんなファイルを作成しました.acpidから ac_adapter のイベント実行時にaction に指定されたscript を実行するようにしています.

/etc/acpi/events/ac_event_logging
event=ac_adapter
action=/etc/acpi/ac_event_logging.sh %e

そして呼び出されるscript として以下のファイルを用意.

/etc/acpi/ac_event_logging.sh
#!/bin/sh
case "$4" in
        00000000)
                echo 'AC offline'
                logger -t acpid AC offline
                ;;
        00000001)
                echo 'AC online'
                logger -t acpid AC online
                ;;
esac

このscriptには実行権も付与します.

$ sudo chmod +x /etc/acpi/ac_event_logging.sh

動作を確認するために acpid を再起動します.

$ sudo service acpid restart

この状態でACアダプタを抜き差しするとこんな感じのログが出力されます.

$ sudo tail -f /var/log/syslog | grep acpid:
Jul 11 23:51:10 yoga-260 acpid: received netlink event "battery PNP0C0A:00 00000080 00000001"
Jul 11 23:51:10 yoga-260 acpid: 0 total rules matched
Jul 11 23:51:10 yoga-260 acpid: completed netlink event "battery PNP0C0A:00 00000080 00000001"
Jul 11 23:51:10 yoga-260 acpid: received netlink event "ac_adapter ACPI0003:00 00000080 00000000" (1)
Jul 11 23:51:10 yoga-260 acpid: rule from /etc/acpi/events/ac_event_logging matched (2)
Jul 11 23:51:10 yoga-260 acpid: executing action "/etc/acpi/ac_event_logging.sh ac_adapter ACPI0003:00 00000080 00000000" (3)
Jul 11 23:51:10 yoga-260 acpid: AC offline (4)
Jul 11 23:51:10 yoga-260 acpid: action exited with status 0 (5)
Jul 11 23:51:10 yoga-260 acpid: 1 total rule matched
Jul 11 23:51:10 yoga-260 acpid: completed netlink event "ac_adapter ACPI0003:00 00000080 00000000"
Jul 11 23:51:11 yoga-260 acpid: received netlink event "ibm/hotkey LEN0068:00 00000080 00006030"
Jul 11 23:51:11 yoga-260 acpid: 0 total rules matched
Jul 11 23:51:11 yoga-260 acpid: completed netlink event "ibm/hotkey LEN0068:00 00000080 00006030"
Jul 11 23:51:11 yoga-260 acpid: received netlink event "thermal_zone LNXTHERM:00 00000081 00000000"
Jul 11 23:51:11 yoga-260 acpid: 0 total rules matched
Jul 11 23:51:11 yoga-260 acpid: completed netlink event "thermal_zone LNXTHERM:00 00000081 00000000"
Jul 11 23:51:12 yoga-260 acpid: received netlink event "battery PNP0C0A:00 00000080 00000001"
Jul 11 23:51:12 yoga-260 acpid: 0 total rules matched
Jul 11 23:51:12 yoga-260 acpid: completed netlink event "battery PNP0C0A:00 00000080 00000001"
Jul 11 23:51:13 yoga-260 acpid: received netlink event "ac_adapter ACPI0003:00 00000080 00000001"
Jul 11 23:51:13 yoga-260 acpid: rule from /etc/acpi/events/ac_event_logging matched
Jul 11 23:51:13 yoga-260 acpid: executing action "/etc/acpi/ac_event_logging.sh ac_adapter ACPI0003:00 00000080 00000001"
Jul 11 23:51:13 yoga-260 acpid: AC online
Jul 11 23:51:13 yoga-260 acpid: action exited with status 0
Jul 11 23:51:13 yoga-260 acpid: 1 total rule matched
Jul 11 23:51:13 yoga-260 acpid: completed netlink event "ac_adapter ACPI0003:00 00000080 00000001"
Jul 11 23:51:13 yoga-260 acpid: received netlink event "ibm/hotkey LEN0068:00 00000080 00006030"
Jul 11 23:51:13 yoga-260 acpid: 0 total rules matched
Jul 11 23:51:13 yoga-260 acpid: completed netlink event "ibm/hotkey LEN0068:00 00000080 00006030"
Jul 11 23:51:13 yoga-260 acpid: received netlink event "thermal_zone LNXTHERM:00 00000081 00000000"
Jul 11 23:51:13 yoga-260 acpid: 0 total rules matched
Jul 11 23:51:13 yoga-260 acpid: completed netlink event "thermal_zone LNXTHERM:00 00000081 00000000"
  1. ACアダプタ切断のログ
  2. ACアダプタ用のeventを見つける
  3. ACアダプタロギング用のscriptを%e を使って引数を渡しつつ実行
  4. ロギング用のscriptでログを出力
  5. action終了

うまく行ったようです :)

ということで他のイベントログを要らないので, /etc/default/acpid を編集して引数を消します.

--- a/default/acpid
+++ b/default/acpid
@@ -1,7 +1,7 @@
 # Options to pass to acpid
 #
 # OPTIONS are appended to the acpid command-line
-OPTIONS="-l"
+#OPTIONS="-l"

 # Linux kernel modules to load before starting acpid
 #

反映するために acpid を再起動します.

$ sudo service acpid restart
$ ps aux | grep [/]sbin/acpid
root     3990040  0.0  0.0   2352   780 ?        Ss   23:59   0:00 /usr/sbin/acpid

再度ログを確認しながらACアダプタの抜き差しをしてログが必要なものだけ出力されているのを確認しました.

sudo tail -f /var/log/syslog | grep acpid:
Jul 12 00:00:04 yoga-260 acpid: AC offline
Jul 12 00:00:07 yoga-260 acpid: AC online

良さそうです :)
サスペンドレジュームも設定してみようかな?

環境
$ dpkg-query -W acpid rsyslog systemd bsdutils
acpid   1:2.0.32-1
bsdutils        1:2.36.1-7
rsyslog 8.2102.0-2
systemd 247.3-5
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ arch
x86_64
$ sudo lshw | grep -E '^\ \ \ \ product:|^\ \ \ \ version:'
    product: 20FEA02WJP (LENOVO_MT_20FE_BU_Think_FM_ThinkPad Yoga 260)
    version: ThinkPad Yoga 260
]]>
https://matoken.org/blog/2021/07/12/output-acpid-log-to-syslog-part-2-acpi-event-action/feed/ 0
Debian環境でacpidのログをsyslogに出力する https://matoken.org/blog/2021/07/11/output-acpid-log-to-syslog/ https://matoken.org/blog/2021/07/11/output-acpid-log-to-syslog/#comments Sat, 10 Jul 2021 22:06:39 +0000 http://matoken.org/blog/?p=3298

ThinkPadの電源プラグのOn/Offで以前はイベントがlogに残っていたのですが,電源管理デーモンが動いていて電源の状態が取得できる状態でもいつの頃からか記録されなくなりました.停電した時間がわかって便利だったのでログ期記録できないか確認してみました.

acpitool で電源アダプタの状態を取得
$ acpitool | grep AC
  AC adapter     : online
$ acpitool | grep AC
  AC adapter     : off-line

ThinkPadのFANを制御する方法を調べて思い出したのでacpidのmanやオプションを確認すると, -l, --logevents オプションを使うとすべてのイベントをログに出力してくれるようです.

$ /sbin/acpid -h 2>&1 | grep '\-l,'
  -l, --logevents    Log all event activity.
$ man acpid | grep -i logevents -A1
       -l, --logevents
                   This option tells acpid to log information about all events and actions.

/etc/default/acpid ファイルを編集して,acpid の起動オプションに -l を追加します.

diff --git a/default/acpid b/default/acpid
index c651a78..a6a7add 100644
--- a/default/acpid
+++ b/default/acpid
@@ -1,7 +1,7 @@
 # Options to pass to acpid
 #
 # OPTIONS are appended to the acpid command-line
-#OPTIONS=""
+OPTIONS="-l"

 # Linux kernel modules to load before starting acpid
 #

acpid を再起動してオプションがついているのを確認します.

$ sudo service acpid restart
$ sudo service acpid status
● acpid.service - ACPI event daemon
     Loaded: loaded (/lib/systemd/system/acpid.service; disabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-07-11 05:57:54 JST; 44s ago
TriggeredBy: ● acpid.socket
             ● acpid.path
       Docs: man:acpid(8)
   Main PID: 2830732 (acpid)
      Tasks: 1 (limit: 9336)
     Memory: 288.0K
        CPU: 6ms
     CGroup: /system.slice/acpid.service
             └─2830732 /usr/sbin/acpid -l

Jul 11 05:57:54 yoga-260 systemd[1]: Started ACPI event daemon.
Jul 11 05:57:54 yoga-260 acpid[2830732]: starting up with netlink and the input layer
Jul 11 05:57:54 yoga-260 acpid[2830732]: 1 rule loaded
Jul 11 05:57:54 yoga-260 acpid[2830732]: waiting for events: event logging is on
$ ps aux | grep [/]sbin/acpid
root     2830732  0.0  0.0   2352   684 ?        Ss   05:57   0:00 /usr/sbin/acpid -l

acpid に -l オプションのついている状態でsyslogをtailしながら電源を抜き差ししてみると少し可読性が悪いですがログが出力されるのがわかりました.

$ sudo tail -f /var/log/syslog | grep acpid:
Jul 11 05:59:22 yoga-260 acpid: received netlink event "battery PNP0C0A:00 00000080 00000001"
Jul 11 05:59:22 yoga-260 acpid: 0 total rules matched
Jul 11 05:59:22 yoga-260 acpid: completed netlink event "battery PNP0C0A:00 00000080 00000001"
Jul 11 05:59:23 yoga-260 acpid: received netlink event "ac_adapter ACPI0003:00 00000080 00000000"
Jul 11 05:59:23 yoga-260 acpid: 0 total rules matched
Jul 11 05:59:23 yoga-260 acpid: completed netlink event "ac_adapter ACPI0003:00 00000080 00000000"
Jul 11 05:59:23 yoga-260 acpid: received netlink event "ibm/hotkey LEN0068:00 00000080 00006030"
Jul 11 05:59:23 yoga-260 acpid: 0 total rules matched
Jul 11 05:59:23 yoga-260 acpid: completed netlink event "ibm/hotkey LEN0068:00 00000080 00006030"
Jul 11 05:59:23 yoga-260 acpid: received netlink event "thermal_zone LNXTHERM:00 00000081 00000000"
Jul 11 05:59:23 yoga-260 acpid: 0 total rules matched
Jul 11 05:59:23 yoga-260 acpid: completed netlink event "thermal_zone LNXTHERM:00 00000081 00000000"
Jul 11 05:59:26 yoga-260 acpid: received netlink event "battery PNP0C0A:00 00000080 00000001"
Jul 11 05:59:26 yoga-260 acpid: 0 total rules matched
Jul 11 05:59:26 yoga-260 acpid: completed netlink event "battery PNP0C0A:00 00000080 00000001"
Jul 11 05:59:26 yoga-260 acpid: received netlink event "ac_adapter ACPI0003:00 00000080 00000001"
Jul 11 05:59:26 yoga-260 acpid: 0 total rules matched
Jul 11 05:59:26 yoga-260 acpid: completed netlink event "ac_adapter ACPI0003:00 00000080 00000001"
Jul 11 05:59:26 yoga-260 acpid: received netlink event "ibm/hotkey LEN0068:00 00000080 00006030"
Jul 11 05:59:26 yoga-260 acpid: 0 total rules matched
Jul 11 05:59:26 yoga-260 acpid: completed netlink event "ibm/hotkey LEN0068:00 00000080 00006030"
Jul 11 05:59:26 yoga-260 acpid: received netlink event "thermal_zone LNXTHERM:00 00000081 00000000"
Jul 11 05:59:26 yoga-260 acpid: 0 total rules matched
Jul 11 05:59:26 yoga-260 acpid: completed netlink event "thermal_zone LNXTHERM:00 00000081 00000000"

すべてのイベントが出力されるので,ボリュームや,輝度の調整でもこのように書き出されます.

Jul 11 06:01:12 t430s acpid: received input layer event "button/volumeup VOLUP 00000080 00000000 K"
Jul 11 06:01:12 t430s acpid: rule from 1840013[0:0] matched
Jul 11 06:01:12 t430s acpid: notifying client 1840013[0:0]
Jul 11 06:01:12 t430s acpid: 1 total rule matched
Jul 11 06:01:12 t430s acpid: completed input layer event "button/volumeup VOLUP 00000080 00000000 K"
Jul 11 06:01:13 t430s acpid: received input layer event "button/volumedown VOLDN 00000080 00000000 K"
Jul 11 06:01:13 t430s acpid: rule from 1840013[0:0] matched
Jul 11 06:01:13 t430s acpid: notifying client 1840013[0:0]
Jul 11 06:01:13 t430s acpid: 1 total rule matched
Jul 11 06:01:13 t430s acpid: completed input layer event "button/volumedown VOLDN 00000080 00000000 K"
Jul 11 06:01:16 t430s acpid: received input layer event "video/brightnessdown BRTDN 00000087 00000000 K"
Jul 11 06:01:16 t430s acpid: rule from 1840013[0:0] matched
Jul 11 06:01:16 t430s acpid: notifying client 1840013[0:0]
Jul 11 06:01:16 t430s acpid: 1 total rule matched
Jul 11 06:01:16 t430s acpid: completed input layer event "video/brightnessdown BRTDN 00000087 00000000 K"
Jul 11 06:01:16 t430s acpid: received input layer event "video/brightnessup BRTUP 00000086 00000000 K"
Jul 11 06:01:16 t430s acpid: rule from 1840013[0:0] matched
Jul 11 06:01:16 t430s acpid: notifying client 1840013[0:0]
Jul 11 06:01:16 t430s acpid: 1 total rule matched
Jul 11 06:01:16 t430s acpid: completed input layer event "video/brightnessup BRTUP 00000086 00000000 K"

以前よりログが冗長で可読性が悪いですがとりあえず動作しました.これで停電が発生したときに停電発生時間や,短い停電であれば停電間隔が確認できます.

環境1(実際はsid)
$ dpkg-query -W acpid rsyslog systemd
acpid   1:2.0.32-1
rsyslog 8.2102.0-2
systemd 247.3-5
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ arch
x86_64
$ sudo lshw | grep -E '^\ \ \ \ product:|^\ \ \ \ version:'
    product: 23533KJ (LENOVO_MT_2353)
    version: ThinkPad T430s
環境2
$ dpkg-query -W acpid rsyslog systemd
acpid   1:2.0.32-1
rsyslog 8.2102.0-2
systemd 247.3-5
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ arch
x86_64
$ sudo lshw | grep -E '^\ \ \ \ product:|^\ \ \ \ version:'
    product: 20FEA02WJP (LENOVO_MT_20FE_BU_Think_FM_ThinkPad Yoga 260)
    version: ThinkPad Yoga 260
]]>
https://matoken.org/blog/2021/07/11/output-acpid-log-to-syslog/feed/ 1
speedtest-cli が crontab で動作しなくて困る https://matoken.org/blog/2021/07/06/trouble-with-speedtest-cli-not-working-with-crontab/ https://matoken.org/blog/2021/07/06/trouble-with-speedtest-cli-not-working-with-crontab/#comments Mon, 05 Jul 2021 21:18:14 +0000 http://matoken.org/blog/?p=3287

インターネット速度計測サイトのSpeedtest.net というサイトがあります.

世界中にあるサーバのうち自分のアドレスから近いであろうサーバを選んで速度計測をしてくれるサービスです.

このサービスをcli で実行できるPython製 speedtest-cli というApache 2.0ライセンスのサードパーティのツールがあります.Debianだとパッケージもあるので導入も簡単です.

$ sudo apt install speedtest-cli
$ speedtest-cli -h
usage: speedtest-cli [-h] [--no-download] [--no-upload] [--single] [--bytes] [--share] [--simple] [--csv] [--csv-delimiter CSV_DELIMITER]
                     [--csv-header] [--json] [--list] [--server SERVER] [--exclude EXCLUDE] [--mini MINI] [--source SOURCE] [--timeout TIMEOUT]
                     [--secure] [--no-pre-allocate] [--version]

Command line interface for testing internet bandwidth using speedtest.net.
-------------------------------------------------------------------------- https://github.com/sivel/speedtest-cli

optional arguments:
  -h, --help            show this help message and exit
  --no-download         Do not perform download test
  --no-upload           Do not perform upload test
  --single              Only use a single connection instead of multiple. This simulates a typical file transfer.
  --bytes               Display values in bytes instead of bits. Does not affect the image generated by --share, nor output from --json or
                        --csv
  --share               Generate and provide a URL to the speedtest.net share results image, not displayed with --csv
  --simple              Suppress verbose output, only show basic information
  --csv                 Suppress verbose output, only show basic information in CSV format. Speeds listed in bit/s and not affected by --bytes
  --csv-delimiter CSV_DELIMITER
                        Single character delimiter to use in CSV output. Default ","
  --csv-header          Print CSV headers
  --json                Suppress verbose output, only show basic information in JSON format. Speeds listed in bit/s and not affected by --bytes
  --list                Display a list of speedtest.net servers sorted by distance
  --server SERVER       Specify a server ID to test against. Can be supplied multiple times
  --exclude EXCLUDE     Exclude a server from selection. Can be supplied multiple times
  --mini MINI           URL of the Speedtest Mini server
  --source SOURCE       Source IP address to bind to
  --timeout TIMEOUT     HTTP timeout in seconds. Default 10
  --secure              Use HTTPS instead of HTTP when communicating with speedtest.net operated servers
  --no-pre-allocate     Do not pre allocate upload data. Pre allocation is enabled by default to improve upload performance. To support systems
                        with insufficient memory, use this option to avoid a MemoryError
  --version             Show the version number and exit
matoken@t430s:/media/matoken/rootfs/home/matoken/Videos$

出力オプションで,csvやjsonで書き出すことも可能です.

$ speedtest-cli (1)
Retrieving speedtest.net configuration...
Testing from freebit (203.0.113.0)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by OpenGW (Shizuoka) [64.23 km]: 82.301 ms
Testing download speed................................................................................
Download: 1.51 Mbit/s
Testing upload speed......................................................................................................
Upload: 0.95 Mbit/s
$ speedtest-cli --simple (2)
Ping: 68.211 ms
Download: 8.11 Mbit/s
Upload: 0.84 Mbit/s
$ speedtest-cli --list | grep -i japan | grep -Ei 'kagoshima|miyazaki|kumamoto|ooita|fukuoka|saga|hitoyoshi' (3)
 8407) Allied Telesis Capital Corporation (Sagamihara, Japan) [175.03 km]
35106) yoshis.jp (KDDI-NET) (Fukuoka, Japan) [687.23 km]
38134) NousagiNetwork(@_0rze) (Fukuoka, Japan) [687.23 km]
38947) Rikimoto (Fukuoka, Japan) [687.23 km]
18709) extride inc (Hitoyoshi, Japan) [705.48 km]
$ speedtest-cli --simple --server 18709 (4)
Ping: 122.31 ms
Download: 6.01 Mbit/s
Upload: 0.81 Mbit/s
$ speedtest-cli --csv-header (5)
Server ID,Sponsor,Server Name,Timestamp,Distance,Ping,Download,Upload,Share,IP Address
$ speedtest-cli --csv (6)
42842,Mamireimu Net Work's,Nara,2021-06-23T09:15:44.814808Z,177.32698372902544,86.096,8215354.331324884,1350756.2707027544,,203.0.113.0
$ speedtest-cli --json | jq . (7)
{
  "download": 7961762.454176666,
  "upload": 1054738.8634894243,
  "ping": 73.207,
  "server": {
    "url": "http://speedtestooklaserverjapannagoyashizuoka.baobivawpvojawvianoipwqnpibvbqoubwuvbqasciboabowbcacacwcqcqx001.bar:8080/speedtest/upload.php",
    "lat": "34.9756",
    "lon": "138.3827",
    "name": "Shizuoka",
    "country": "Japan",
    "cc": "JP",
    "sponsor": "OpenGW",
    "id": "42413",
    "host": "speedtestooklaserverjapannagoyashizuoka.baobivawpvojawvianoipwqnpibvbqoubwuvbqasciboabowbcacacwcqcqx001.bar:8080",
    "d": 64.2282382602239,
    "latency": 73.207
  },
  "timestamp": "2021-06-23T09:19:28.880310Z",
  "bytes_sent": 1515520,
  "bytes_received": 10101900,
  "share": null,
  "client": {
    "ip": "203.0.113.0",
    "lat": "34.733",
    "lon": "137.7439",
    "isp": "freebit",
    "isprating": "3.7",
    "rating": "0",
    "ispdlavg": "0",
    "ispulavg": "0",
    "loggedin": "0",
    "country": "JP"
  }
}
  1. 既定値で実行すると自分のipアドレスのgeoipで近いサーバにpingを打って近そうなサーバを探して速度テストする.(物理的には鹿児島だけどgeoipでは静岡扱いなのでその周りが使われる)
  2. シンプルな表示
  3. 物理的に近そうな九州内のサーバを探す
  4. 物理的に一番近いサーバを指定
  5. csvヘッダを表示(計測はしない)
  6. csv形式で出力
  7. json形式で出力(して jq で整形)

これをcrontabに設定して定期的に実行し,速度の変化を見てみようと思いました.

crontabに */30 * * * * speedtest-cli --csv >> ~/log/speedtest.csv を設定して30分毎に速度テストをして ~/log/speedtest.csv に書き出してみます.

$ mkdir ~/log (1)
$ speedtest-cli --csv-header > ~/log/speedtest.csv (2)
$ crontab -e (3)
$ crontab -l | grep speedtest-cli (4)
*/30 * * * *    speedtest-cli --csv >> ~/log/speedtest.csv
  1. ログ格納ディレクトリ作成
  2. csvヘッダをログファイルに書き込み
  3. crontab -e で以下の行を追加
  4. crontabに登録されているのを確認

しかし,手動で実行時には失敗した頃がないのにcrontab 経由だとほぼ全てが失敗します.まれに成功することもありますが,10回に1回も成功しません.

以下のエラーが出力されます.

ERROR: Unable to connect to servers to test latency.

crontabでだけエラーとなるので,コマンドをshell script fileにしてそれを呼ぶようにしたり,リダイレクト方法を変更してみたり,sourceを見るとサーバリストの取得に失敗しているようなのでサーバを指定するようにしてみたけどサーバを指定してもサーバリストを取得するので意味がなかったりということを試していました.

もしかして毎0分,30分の実行するのが良くないのではと,crontabを以下のように書き換えて6分と36分に実行されるよう変更たところろ動作するようになりました.

$ crontab -l | grep speedtest-cli (1)
6,36 * * * *    speedtest-cli --csv >> ~/log/speedtest.csv

手動でも0分丁度に実行するとエラーになることを確認しました.

$ speedtest-cli
Retrieving speedtest.net configuration...
Testing from freebit (180.131.110.140)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
ERROR: Unable to connect to servers to test latency.

ということでとりあえずきりのいい時間からずらすと動くようになりました.

実はSpeedTest公式のCLI ツールもありこれだと今回の問題は起こらないようです.
バイナリしか提供されていませんが,macOS/Windows/Linux/FreeBSD版が提供されていて,Linuxはi386, x86_64, armlf, armhf, arm64 が提供されています.

こちらを使うと毎0分,30分に実行しても動作しました. csv, tsv, json, jsonl, json-pretty` での出力に対応しているしこちらを使うのもありかもしれません.ただsourceも無いし2019年のリリースからバージョンが上がっていないのでメンテされているのかちょっと不安です.

環境
$ dpkg-query -W speedtest-cli
speedtest-cli   2.1.3-2
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ arch
x86_64
]]>
https://matoken.org/blog/2021/07/06/trouble-with-speedtest-cli-not-working-with-crontab/feed/ 1
「Life is Strange」をLinuxでも日本語で遊ぶ https://matoken.org/blog/2021/06/29/play-life-is-strange-in-japanese-on-linux/ https://matoken.org/blog/2021/06/29/play-life-is-strange-in-japanese-on-linux/#respond Mon, 28 Jun 2021 22:26:20 +0000 http://matoken.org/blog/?p=3284

回線の調子が悪いので,久々に少しゲームを遊んでみようかと思いLinux版Steamを起動して「Life is Strange 2」の冒頭を遊んでみましたが,「Life is Strange – Episode 1」も無料のようなのでこれを先に遊んだほうがいいかな?と起動すると2で使えていた日本語が選べないようです.
Winows版の言語パックはあるようなのでどうにかならないかなと試してみました.

「Steam:Life is Strange – Episode 1」のページを見ると以下のような記述があります.

お知らせ: 日本国内のお客様にお知らせ:Life Is Strangeの日本語化DLC配信中!エピソード1またはコンプリート・シーズンをご購入後、無料のDLCをダウンロード及びインストールすることで日本語版をお楽しみいただけます。

以下のページがそれで,DLCとして日本語パックが提供されているようです.しかし実際にアクセスしてみるとWindows用のようでLinux版は日本語パックが導入できません.

展開してファイルを入れ替えたりしてどうにかならないかな?とも思いましたが,Steam Linux版にはProtonというWindows互換レイヤーを使ってWindows版のゲームを動かす仕組みがあるのでそれを試してみるとうまくいきました.

手順は以下のとおりです.

  • 「ライブラリ」の「Life is Strange」を右クリック,「プロパティ」,「互換性」,「特定のSteam Play互換ツールの利用を強制する」にチェックを付けてプロパティウィンドウを閉じる.
    Life is Strange01
  • 「プレイ」ボタンを押すと,Windows版がダウンロードされる.
  • ダウンロードが終わったらプレイせずに一旦キャンセル.
  • Life is Strange™ – Japanese Language Pack のページに移動して,「ダウンロード」ボタンを押して日本語パックを導入する.
  • 日本語で起動するようになっている.

Life is Strange02
Life is Strange03

テキストだけでなくボイスも日本語になっています.とりあえずEpisode 1 を一通りクリアしましたが問題なく動作しました.続きのEpisode 2〜5 もこのDLCで日本語化されるようです.
(回線を使いたくなかったのに結局ダウンロードしてますね🤔)

しかしなんでWindows版だけの対応なんだろう.検証するリソースが足りないのかな?とか思ったのですが,以下のレビューによるとWindows版とそれ以外ではパブリッシャーが違うようです.そのため扱いが違うので非対応ということのようです.

ストアページをよく見るとちゃんとパブリッシャー書いてありますね.

パブリッシャー: Square Enix, Feral interactive (Mac), Feral Interactive (Linux)

2はどうなっているかな?と見ると同じ状態です.でも何もしなくてもLinux版で日本語で遊べているので1でも対応してほしいなと思ったり.

パブリッシャー: Square Enix, Feral Interactive (Mac), Feral Interactive (Linux)

環境

Life is Strange steam

$ dpkg-query -W steam*
steam
steam-launcher  1:1.0.0.70
steam64
steamos-base-files
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ arch
x86_64
$ lspci | grep -i graphic
00:02.0 VGA compatible controller: Intel Corporation Skylake GT2 [HD Graphics 520] (rev 07)
$ lscpu | grep ^Model
Model:                           78
Model name:                      Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
]]>
https://matoken.org/blog/2021/06/29/play-life-is-strange-in-japanese-on-linux/feed/ 0
Discordの画面共有をなるべく低画質にして帯域を節約する(2021-06-21) https://matoken.org/blog/2021/06/21/discord-screen-sharing-with-low-quality/ https://matoken.org/blog/2021/06/21/discord-screen-sharing-with-low-quality/#respond Mon, 21 Jun 2021 14:24:46 +0000 http://matoken.org/blog/?p=3277

Discord Linux版での画面共有時の設定メモです.
※この設定は今の所ウェブアプリ版では出てこないので使えないと思います.

スライドの共有などのあまり画質やフレームレートの必要ないものの画面共有時には規定値の設定より低くしても問題なさそうです.

現時点(2021-06-21)での最低解像度,最低フレームレートの設定メモです.

解像度の設定

画面共有時には以前の480pから720pが最低になっています.

Discord resolution01

しかし,一旦画面共有を行った後に配信設定の「配信画質」→「解像度」から「480p」が選択できます.

Discord resolution02

フレームレートの設定

画面共有時のフレームレートでの設定は「15FPS」が最低ですが,配信設定のプルダウンメニューから「より読みやすいテキスト」を選択することで「5FPS」になるようです.

Discord fps01
Discord fps02

環境
$ /opt/local/Discord/Discord --version 2>&1 | head -1
Discord 0.0.15
~$ /opt/local/DiscordPTB/DiscordPTB --version 2>&1 | head -1
DiscordPtb 0.0.25
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ arch
x86_64
]]>
https://matoken.org/blog/2021/06/21/discord-screen-sharing-with-low-quality/feed/ 0
Barrierで装飾キーがロックされるのを解除する https://matoken.org/blog/2021/05/29/barrier/ https://matoken.org/blog/2021/05/29/barrier/#respond Sat, 29 May 2021 06:41:43 +0000 http://matoken.org/blog/?p=3247

Barrierというマルチプラットホームのキーボードマウス共有ソフトを常用しています.1台の端末のキーボードマウスで複数のマシンを操れます.Synergyのフォークです.
最近1台の端末をDebian Bullseye + i3wm にしてみたのですが,どうもキーボードがおかしくなります.CtrlやSuperが押しっぱなしになります.
以前から別のマシンでこの症状は出ていましたが今回は頻度がとても多くまともに動くことのほうが少ないです.これまでXorgを再起動して解決していましたが面倒すぎます.

ISSUEを探すと出てきました.未解決のようです(◞‸◟)
でもワークアラウンドがあったので試してみました.

The only thing that I’ve found to “reset” this (without leaving X) is the following …​ and it’s not ideal (at all):

#!/usr/bin/env bash

setxkbmap -layout us
xdotool keyup Shift_L Shift_R Control_L Control_R Alt_L Alt_R Super_L Super_R Hyper_L Hyper_R Caps_Lock 204 205 206 207

なるほど.
キーボード入力がおかしいのでリモートのssh経由で叩いてみます.

Note
もしコマンドが見つからない場合は, x11-xkb-utils, xdotool パッケージを入れてください.
$ sudo apt install x11-xkb-utils xdotool
$ DISPLAY=:0 setxkbmap -layout us
$ DISPLAY=:0 xdotool keyup Shift_L Shift_R Control_L Control_R Alt_L Alt_R Super_L Super_R Hyper_L Hyper_R Caps_Lock 204 205 206 207

使えるようになりました :)

確かに理想的ではありませんがとりあえずXorgの再起動が必要なくなったのでとても助かります.
バグが治るまではこれで凌ごうと思います.(もしくはrkvmに移行?)

環境
$ dpkg-query -W barrier xdotool x11-xkb-utils i3 xorg
barrier 2.3.3+dfsg-1.1
i3      4.19.1-1
x11-xkb-utils   7.7+5
xdotool 1:3.20160805.1-4
xorg    1:7.7+22
]]>
https://matoken.org/blog/2021/05/29/barrier/feed/ 0
vnStatでネットワークトラフィックを集計する https://matoken.org/blog/2021/05/28/vnstat/ https://matoken.org/blog/2021/05/28/vnstat/#respond Fri, 28 May 2021 14:17:09 +0000 http://matoken.org/blog/?p=3243

以下のエントリでipコマンドでネットワーク通信量が確認できました.

端末を起動してからの通信量は確認できますが,再起動したりするとデータ量はクリアされてしまいます.MRTGやZabbixなどを使うのは大げさな感じがします.
もう少しお手軽なものがないかなと少し探してvnStatというものを見つけたので今回試してみました.

Debianでは vnstatvnstati というパッケージが提供されています.vnstat が本体で, vnstati はイメージ出力のコマンドです.

まずは本体の vnstat を導入します.

$ sudo apt install vnstat

導入するとvnStatのデーモンが起動します.

$ sudo service vnstat status
● vnstat.service - vnStat network traffic monitor
     Loaded: loaded (/lib/systemd/system/vnstat.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-04-30 00:46:09 JST; 5min ago
       Docs: man:vnstatd(8)
             man:vnstat(1)
             man:vnstat.conf(5)
   Main PID: 2045411 (vnstatd)
      Tasks: 1 (limit: 18935)
     Memory: 808.0K
        CPU: 184ms
     CGroup: /system.slice/vnstat.service
             └─2045411 /usr/sbin/vnstatd -n

Apr 30 00:46:10 t430s vnstatd[2045411]: Interface "virbr0" added with 1000 Mbit bandwidth limit.
Apr 30 00:46:10 t430s vnstatd[2045411]: Interface "nm-br1" added with 1000 Mbit bandwidth limit.
Apr 30 00:46:10 t430s vnstatd[2045411]: Interface "anbox0" added with 1000 Mbit bandwidth limit.
Apr 30 00:46:10 t430s vnstatd[2045411]: Interface "lxcbr0" added with 1000 Mbit bandwidth limit.
Apr 30 00:46:10 t430s vnstatd[2045411]: Interface "docker0" added with 1000 Mbit bandwidth limit.
Apr 30 00:46:10 t430s vnstatd[2045411]: -> 7 new interfaces found.
Apr 30 00:46:10 t430s vnstatd[2045411]: Limits can be modified using the configuration file. See "man vnstat.conf".
Apr 30 00:46:10 t430s vnstatd[2045411]: Unwanted interfaces can be removed from monitoring with "vnstat --remove".
Apr 30 00:46:10 t430s vnstatd[2045411]: Info: vnStat daemon 2.6 started. (pid:2045411 uid:149 gid:165 64-bit)
Apr 30 00:46:10 t430s vnstatd[2045411]: Info: Monitoring (7): wlp3s0 (1000 Mbit) virbr0 (1000 Mbit) nm-br1 (1000 Mbit) lxcbr0 (1000 Mbit) enp0s2>

はじめはデータがないのでこんな感じの寂しい表示です.

$ vnstat                                                                                                            [169/1082]

                      rx      /      tx      /     total    /   estimated
 anbox0: Not enough data available yet.
 docker0: Not enough data available yet.
 enp0s25: Not enough data available yet.
 lxcbr0: Not enough data available yet.
 nm-br1: Not enough data available yet.
 virbr0: Not enough data available yet.
 wlp3s0: Not enough data available yet.

数分経ってから実行するとデータが記録されてログが出てきます.

$ vnstat

                      rx      /      tx      /     total    /   estimated
 anbox0: Not enough data available yet.
 docker0: Not enough data available yet.
 enp0s25: Not enough data available yet.
 lxcbr0: Not enough data available yet.
 nm-br1: Not enough data available yet.
 virbr0: Not enough data available yet.
 wlp3s0:
       2021-04     21.10 MiB  /    3.70 MiB  /   24.80 MiB  /   22.25 MiB
         today     21.10 MiB  /    3.70 MiB  /   24.80 MiB  /  673.77 MiB

ネットワークインターフェイスが複数あって,特定のインターフェイスの情報だけを確認したい場合は -i オプションでインターフェイスが指定できます.

$ vnstat -i wlp3s0
Database updated: 2021-04-30 00:53:40

   wlp3s0 since 2021-04-30

          rx:  21.10 MiB      tx:  3.70 MiB      total:  24.80 MiB

   monthly
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       2021-04     21.10 MiB |    3.70 MiB |   24.80 MiB |       82 bit/s
     ------------------------+-------------+-------------+---------------
     estimated     19.78 MiB |    2.47 MiB |   22.25 MiB |

   daily
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
         today     21.10 MiB |    3.70 MiB |   24.80 MiB |   64.60 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated    573.38 MiB |  100.39 MiB |  673.77 MiB |

複数のインターフェイスの合計を指定する場合は, + でインターフェイスをつなげて指定します.

$ vnstat -i usb0+wlp3s0

vnStatインストール時に存在しなかったインターフェイスは監視されません.

$ vnstat -i usb0
Error: Interface "usb0" not found in database.

新しいネットワークインターフェイスを追加します.ここでは usb0 を登録しました.

$ sudo vnstat --add -i usb0 (1)
Adding interface "usb0" for monitoring to database...

Restart the vnStat daemon if it is currently running in order to start monitoring "usb0".
$ sudo service vnstat restart   (2)
$ vnstat -i usb0 -d (3)

 usb0  /  daily

          day        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     2021-04-30     2.03 MiB |    8.18 MiB |   10.21 MiB |   12.90 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated     26.57 MiB |  107.12 MiB |  133.70 MiB |
  1. usb0 インターフェイスを登録
  2. 反映のためにvNstatを再起動する.
  3. 暫く待ってからカウントされているのを確認.

インターフェイスが切断されているときは disabled の表示になりますが,再接続されるとまたカウントされます.

$ vnstat | grep :
 usb0 [disabled]:
 wlp4s0:

情報の確認はいくつかの表示ができます.サマリー,5分毎,1時間毎,日毎,月毎,年毎,トップなど.
既定値がサマリーのようです.

-5 で5分毎(ここではwlp3s0を5分x6表示)
$ vnstat -i wlp3s0 -5 6

 wlp3s0  /  5 minute

         time        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     2021-05-24
         14:35      1.43 MiB |    1.27 MiB |    2.70 MiB |   75.52 kbit/s
         14:40      7.11 MiB |    1.44 MiB |    8.55 MiB |  238.96 kbit/s
         14:45      1.60 MiB |    1.28 MiB |    2.87 MiB |   80.34 kbit/s
         14:50      1.12 MiB |    1.17 MiB |    2.29 MiB |   63.94 kbit/s
         14:55      1.49 MiB |    1.50 MiB |    2.99 MiB |   83.47 kbit/s
         15:00    748.04 KiB |    1.18 MiB |    1.91 MiB |   53.41 kbit/s
     ------------------------+-------------+-------------+---------------
-h で1時間毎(ここでは1時間x3表示)
$ vnstat -h 3

 wlp4s0  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     2021-05-24
         05:00      3.28 MiB |  623.99 KiB |    3.88 MiB |    9.05 kbit/s
         17:00    510.09 MiB |    7.29 MiB |  517.38 MiB |    1.21 Mbit/s
         18:00    286.84 MiB |    8.32 MiB |  295.16 MiB |    1.65 Mbit/s
     ------------------------+-------------+-------------+---------------
-d で日毎(ここでは1日x3表示)
$ vnstat -d 3

 wlp3s0+enp0s25+usb0  /  daily

          day        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     2021-05-23   936.47 MiB |  820.25 MiB |    1.72 GiB |  170.56 kbit/s
     2021-05-24     1.56 GiB |  300.01 MiB |    1.85 GiB |  183.94 kbit/s
     2021-05-28   483.40 MiB |  372.19 MiB |  855.60 MiB |   83.07 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated    642.75 MiB |  494.88 MiB |    1.11 GiB |

estimated も表示されます.これはこの調子で使い続けるとこのくらいという推測のようで利用時間や利用量が少なかったり,利用状況が変わる場合信頼できない値になります.

-m で月毎
$ vnstat -m

 wlp3s0+enp0s25+usb0  /  monthly

        month        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       2021-04      1.54 GiB |  571.46 MiB |    2.09 GiB |    6.94 kbit/s
       2021-05     19.13 GiB |    4.53 GiB |   23.66 GiB |  303.40 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated     76.48 GiB |   18.12 GiB |   94.60 GiB |
-y で年毎
$ vnstat -y

 wlp4s0  /  yearly

         year        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
          2021     47.48 GiB |    3.16 GiB |   50.64 GiB |   34.07 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated    117.29 GiB |    7.81 GiB |  125.09 GiB |
-t でtop(ここではTop3)
$ vnstat -t 3

 wlp4s0  /  top 3

    #      day          rx      |     tx      |    total    |   avg. rate
   -----------------------------+-------------+-------------+---------------
    1   2021-05-19     7.76 GiB |    1.52 GiB |    9.29 GiB |  923.28 kbit/s
    2   2021-05-27     8.01 GiB |  373.46 MiB |    8.37 GiB |  832.45 kbit/s
    3   2021-05-18     5.66 GiB |  165.91 MiB |    5.83 GiB |  579.24 kbit/s
   -----------------------------+-------------+-------------+---------------
開始( -b ),終了( -e )期間指定(ここでは2021-05-18〜2021-05-25を指定)
$ vnstat -i usb0 -b 2021-05-18 -e 2021-05-25
Database updated: 2021-05-24 05:09:40

   usb0 [disabled] since 2021-05-17

          rx:  5.84 GiB      tx:  1.03 GiB      total:  6.87 GiB

   monthly
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       2021-05      5.84 GiB |    1.03 GiB |    6.87 GiB |   29.41 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated      7.80 GiB |    1.37 GiB |    9.17 GiB |

   daily
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     2021-05-23     3.24 GiB |  756.16 MiB |    3.98 GiB |  395.74 kbit/s
     2021-05-24    45.06 MiB |   10.71 MiB |   55.78 MiB |   25.18 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated    210.01 MiB |   49.92 MiB |  259.93 MiB |
-hg, --hoursgraph で1時間ごとのグラフ
$ vnstat -hg
 eth0                                                                     22:15
  ^                                                                     t
  |                                                                     t
  |                                                                     t
  |                                                                     t
  |                                                                     t
  |                                                                     t
  |                                                                     t
  |                                                                     t
  |                                                                    rt  t
  |                                                              rt r  rt rt
 -+--------------------------------------------------------------------------->
  |  23 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22

 h  rx (MiB)   tx (MiB)  ][  h  rx (MiB)   tx (MiB)  ][  h  rx (MiB)   tx (MiB)
23        0.0        0.0 ][ 07        0.0        0.0 ][ 15        0.0        0.0
00        0.0        0.0 ][ 08        0.0        0.0 ][ 16        0.0        0.0
01        0.0        0.0 ][ 09        0.0        0.0 ][ 17        0.0        0.0
02        0.0        0.0 ][ 10        0.0        0.0 ][ 18        3.3        9.1
03        0.0        0.0 ][ 11        0.0        0.0 ][ 19       27.0       19.4
04        0.0        0.0 ][ 12        0.0        0.0 ][ 20       25.0       14.6
05        0.0        0.0 ][ 13        0.0        0.0 ][ 21       31.0      150.8
06        0.0        0.0 ][ 14        0.0        0.0 ][ 22       20.3       37.2
-l でリアルタイム(^cで終了,統計が表示される)
$ vnstat -l
Monitoring wlp4s0...    (press CTRL-C to stop)

   rx:     7.39 Mbit/s   632 p/s          tx:   234.20 kbit/s   306 p/s^C


 wlp4s0  /  traffic statistics

                           rx         |       tx
--------------------------------------+------------------
  bytes                   241.31 MiB  |       10.07 MiB
--------------------------------------+------------------
          max            8.33 Mbit/s  |   322.19 kbit/s
      average          322.69 kbit/s  |    13.47 kbit/s
          min                0 bit/s  |         0 bit/s
--------------------------------------+------------------
  packets                     187533  |           92295
--------------------------------------+------------------
          max                716 p/s  |         382 p/s
      average                 29 p/s  |          14 p/s
          min                  0 p/s  |           0 p/s
--------------------------------------+------------------
  time                104.55 minutes

機関の指定もできるようですが,使い方が悪いのか機関によってはうまく使えません.ここではサマリ表示で指定していない期間の2021-05-24も表示されていて, -h 表示でデータが出てこない.

$ vnstat -i usb0 --begin "2021-05-23 13:00" --end "2021-05-23 20:00"
Database updated: 2021-05-24 05:09:40

   usb0 [disabled] since 2021-05-17

          rx:  5.84 GiB      tx:  1.03 GiB      total:  6.87 GiB

   monthly
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       2021-05      5.84 GiB |    1.03 GiB |    6.87 GiB |   29.41 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated      7.80 GiB |    1.37 GiB |    9.17 GiB |

   daily
                     rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     2021-05-23     3.24 GiB |  756.16 MiB |    3.98 GiB |  395.74 kbit/s
     2021-05-24    45.06 MiB |   10.71 MiB |   55.78 MiB |   25.18 kbit/s
     ------------------------+-------------+-------------+---------------
     estimated    210.01 MiB |   49.92 MiB |  259.93 MiB |
$ vnstat -i usb0 --begin "2021-05-23 13:00" --end "2021-05-23 20:00" --hours

 usb0 [disabled]  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
                            no data available
     ------------------------+-------------+-------------+---------------

vnstati も試してみます.
これは vNstat の画像出力コマンドです.Debianではvnstatとは別パッケージの vnstati に分かれているのでこれを導入します.

$ sudo apt install vnstati

範囲などのオプションは vnstat と共通です.

$ vnstati -i usb0 -h 7 -o /tmp/today.png

vnstati

環境1
$ dpkg-query -W vnstat vnstati
vnstat  2.6-3
vnstati 2.6-3
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ arch
x86_64
環境2
$ dpkg-query -W vnstat vnstati
vnstat  2.6-3
vnstati 2.6-3
$ lsb_release -dr
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
$ arch
x86_64
環境3
$ dpkg-query -W vnstat
vnstat  2.6-1
$ lsb_release -dr
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
$ arch
x86_64
]]>
https://matoken.org/blog/2021/05/28/vnstat/feed/ 0
Debian 10 Buster testing をリリース後に apt update するとエラーになる https://matoken.org/blog/2019/07/11/apt-update-after-releasing-debian-10-buster-testing-results-in-an-error/ https://matoken.org/blog/2019/07/11/apt-update-after-releasing-debian-10-buster-testing-results-in-an-error/#respond Wed, 10 Jul 2019 21:22:00 +0000 http://matoken.org/blog/?p=2420

2019-07-06 に Debian Buster 10 がリリースされました.

Debian 10 Buster testing 環境でリリース後に apt update をするとエラーになってしまいます.

$ sudo apt update
Get:1 http://security.debian.org/debian-security buster/updates InRelease [39.1 kB]
Get:2 http://deb.debian.org/debian buster InRelease [118 kB]
N: Repository 'http://security.debian.org/debian-security buster/updates InRelease' changed its 'Version' value from '' to '10'
E: Repository 'http://security.debian.org/debian-security buster/updates InRelease' changed its 'Suite' value from 'testing' to 'stable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.
Do you want to accept these changes and continue updating from this repository? [y/N]
N: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Version' value from '' to '10.0'
E: Repository 'http://deb.debian.org/debian buster InRelease' changed its 'Suite' value from 'testing' to 'stable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.
Do you want to accept these changes and continue updating from this repository? [y/N]
Reading package lists... Done
E: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease
E: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease
E: Some index files failed to download. They have been ignored, or old ones used instead.

--allow-releaseinfo-change を指定してAPT にリリースを情報を確認したことを教えます.

$ sudo apt --allow-releaseinfo-change update

次からはオプション無しで実行してもエラーが出なくなります.

$ sudo apt update
Hit:1 http://deb.debian.org/debian buster InRelease
Hit:2 http://security.debian.org/debian-security buster/updates InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.

ちなみに stable でなく testing 環境を使い続けたい場合は /etc/apt/sources.list を現在の Debian testing の bullseye に修正すればいいはず.

環境
$ dpkg-query -W apt
apt     1.8.2
$ hostnamectl | egrep 'Operating System|Architecture'
  Operating System: Debian GNU/Linux 10 (buster)
      Architecture: x86-64

]]>
https://matoken.org/blog/2019/07/11/apt-update-after-releasing-debian-10-buster-testing-results-in-an-error/feed/ 0