feat(app): the recorder window

Run with no command, `komorebi-recorder` opens a small window with Record and
Stop. It is untitled and borderless because komorebi does not manage windows
without a title, so opening it does not move the layout under investigation, and
it keeps itself out of the video (by process name on macOS, with
`WDA_EXCLUDEFROMCAPTURE` on Windows). `komorebi-recorder-gui` is the same
program built for the GUI subsystem on Windows, so that a shortcut opens no
console; both are in the zips and the installer.
This commit is contained in:
LGUG2Z committed 2026-10-27 22:22:56 -07:00
1 parent 05d87908c5
commit 5291a24fd4
15 files changed
+4399 -81

No files matched your search

Generated
+3332 -69
View File
File diff suppressed because it is too large. Load diff
+2
View File
@@ -42,6 +42,8 @@ komorebi-recorder displays # which displays can be recorde
komorebi-recorder record --duration 30 --out ./repro
```
Run `komorebi-recorder` with no command for a small window with Record and Stop buttons instead.
On macOS the terminal needs the Screen Recording permission, as `komorebi` does. For a useful recording, start komorebi
with `--log-level trace` first: the recorder never changes komorebi's log level, it only warns. A session made with
`--no-video` has everything but the screen. [Recording a bug repro](docs/usage/recording-a-bug-repro.md) has the rest:
+224 -4
View File
@@ -9,17 +9,30 @@
[
"Apache-2.0",
[
"ab_glyph 0.2.32 registry+https://github.com/rust-lang/crates.io-index",
"ab_glyph_rasterizer 0.1.10 registry+https://github.com/rust-lang/crates.io-index",
"accesskit 0.21.1 registry+https://github.com/rust-lang/crates.io-index",
"accesskit_consumer 0.31.0 registry+https://github.com/rust-lang/crates.io-index",
"accesskit_macos 0.22.2 registry+https://github.com/rust-lang/crates.io-index",
"accesskit_windows 0.29.2 registry+https://github.com/rust-lang/crates.io-index",
"accesskit_winit 0.29.2 registry+https://github.com/rust-lang/crates.io-index",
"addr2line 0.25.1 registry+https://github.com/rust-lang/crates.io-index",
"adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index",
"ahash 0.8.12 registry+https://github.com/rust-lang/crates.io-index",
"anstream 1.0.0 registry+https://github.com/rust-lang/crates.io-index",
"anstyle 1.0.14 registry+https://github.com/rust-lang/crates.io-index",
"anstyle-parse 1.0.0 registry+https://github.com/rust-lang/crates.io-index",
"anstyle-query 1.1.5 registry+https://github.com/rust-lang/crates.io-index",
"anstyle-wincon 3.0.11 registry+https://github.com/rust-lang/crates.io-index",
"arboard 3.6.1 registry+https://github.com/rust-lang/crates.io-index",
"autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index",
"backtrace 0.3.76 registry+https://github.com/rust-lang/crates.io-index",
"bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index",
"bitflags 2.11.1 registry+https://github.com/rust-lang/crates.io-index",
"bytemuck 1.25.0 registry+https://github.com/rust-lang/crates.io-index",
"bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index",
"cfg-if 1.0.4 registry+https://github.com/rust-lang/crates.io-index",
"cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"chrono 0.4.44 registry+https://github.com/rust-lang/crates.io-index",
"clap 4.6.1 registry+https://github.com/rust-lang/crates.io-index",
"clap_builder 4.6.0 registry+https://github.com/rust-lang/crates.io-index",
@@ -28,34 +41,69 @@
"color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index",
"color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index",
"colorchoice 1.0.5 registry+https://github.com/rust-lang/crates.io-index",
"core-foundation 0.9.4 registry+https://github.com/rust-lang/crates.io-index",
"core-foundation-sys 0.8.7 registry+https://github.com/rust-lang/crates.io-index",
"core-graphics 0.23.2 registry+https://github.com/rust-lang/crates.io-index",
"core-graphics-types 0.1.3 registry+https://github.com/rust-lang/crates.io-index",
"crc32fast 1.5.0 registry+https://github.com/rust-lang/crates.io-index",
"crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index",
"crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index",
"ctrlc 3.5.2 registry+https://github.com/rust-lang/crates.io-index",
"cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index",
"dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index",
"dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index",
"dispatch2 0.3.1 registry+https://github.com/rust-lang/crates.io-index",
"displaydoc 0.2.5 registry+https://github.com/rust-lang/crates.io-index",
"document-features 0.2.12 registry+https://github.com/rust-lang/crates.io-index",
"dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index",
"dunce 1.0.5 registry+https://github.com/rust-lang/crates.io-index",
"dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index",
"ecolor 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"eframe 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"egui 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"egui-winit 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"egui_glow 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"emath 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"epaint 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"epaint_default_fonts 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index",
"eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index",
"fastrand 2.4.1 registry+https://github.com/rust-lang/crates.io-index",
"fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index",
"flate2 1.1.9 registry+https://github.com/rust-lang/crates.io-index",
"foreign-types 0.5.0 registry+https://github.com/rust-lang/crates.io-index",
"foreign-types-macros 0.2.3 registry+https://github.com/rust-lang/crates.io-index",
"foreign-types-shared 0.3.1 registry+https://github.com/rust-lang/crates.io-index",
"form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index",
"getrandom 0.4.2 registry+https://github.com/rust-lang/crates.io-index",
"gimli 0.32.3 registry+https://github.com/rust-lang/crates.io-index",
"gl_generator 0.14.0 registry+https://github.com/rust-lang/crates.io-index",
"glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index",
"glutin 0.32.3 registry+https://github.com/rust-lang/crates.io-index",
"glutin_egl_sys 0.7.1 registry+https://github.com/rust-lang/crates.io-index",
"glutin_wgl_sys 0.6.1 registry+https://github.com/rust-lang/crates.io-index",
"half 2.7.1 registry+https://github.com/rust-lang/crates.io-index",
"hashbrown 0.15.5 registry+https://github.com/rust-lang/crates.io-index",
"heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index",
"iana-time-zone 0.1.65 registry+https://github.com/rust-lang/crates.io-index",
"idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index",
"idna_adapter 1.2.2 registry+https://github.com/rust-lang/crates.io-index",
"image 0.25.10 registry+https://github.com/rust-lang/crates.io-index",
"indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index",
"is_terminal_polyfill 1.70.2 registry+https://github.com/rust-lang/crates.io-index",
"itoa 1.0.18 registry+https://github.com/rust-lang/crates.io-index",
"khronos_api 3.1.0 registry+https://github.com/rust-lang/crates.io-index",
"lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index",
"libc 0.2.186 registry+https://github.com/rust-lang/crates.io-index",
"litrs 1.0.0 registry+https://github.com/rust-lang/crates.io-index",
"lock_api 0.4.14 registry+https://github.com/rust-lang/crates.io-index",
"log 0.4.29 registry+https://github.com/rust-lang/crates.io-index",
"miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index",
"moxcms 0.8.1 registry+https://github.com/rust-lang/crates.io-index",
"nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index",
"ntapi 0.4.3 registry+https://github.com/rust-lang/crates.io-index",
"num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index",
"objc2-app-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-av-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-core-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-core-graphics 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
@@ -66,12 +114,18 @@
"object 0.37.3 registry+https://github.com/rust-lang/crates.io-index",
"once_cell 1.21.4 registry+https://github.com/rust-lang/crates.io-index",
"once_cell_polyfill 1.70.2 registry+https://github.com/rust-lang/crates.io-index",
"owned_ttf_parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index",
"parking_lot 0.12.5 registry+https://github.com/rust-lang/crates.io-index",
"parking_lot_core 0.9.12 registry+https://github.com/rust-lang/crates.io-index",
"percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index",
"pin-project-lite 0.2.17 registry+https://github.com/rust-lang/crates.io-index",
"png 0.18.1 registry+https://github.com/rust-lang/crates.io-index",
"proc-macro2 1.0.106 registry+https://github.com/rust-lang/crates.io-index",
"profiling 1.0.17 registry+https://github.com/rust-lang/crates.io-index",
"pxfm 0.1.29 registry+https://github.com/rust-lang/crates.io-index",
"quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index",
"quote 1.0.45 registry+https://github.com/rust-lang/crates.io-index",
"raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index",
"ref-cast 1.0.25 registry+https://github.com/rust-lang/crates.io-index",
"ref-cast-impl 1.0.25 registry+https://github.com/rust-lang/crates.io-index",
"rustc-demangle 0.1.27 registry+https://github.com/rust-lang/crates.io-index",
@@ -85,22 +139,41 @@
"serde_json 1.0.149 registry+https://github.com/rust-lang/crates.io-index",
"serde_json_lenient 0.2.4 registry+https://github.com/rust-lang/crates.io-index",
"smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index",
"smol_str 0.2.2 registry+https://github.com/rust-lang/crates.io-index",
"stable_deref_trait 1.2.1 registry+https://github.com/rust-lang/crates.io-index",
"static_assertions 1.1.0 registry+https://github.com/rust-lang/crates.io-index",
"syn 2.0.117 registry+https://github.com/rust-lang/crates.io-index",
"tempfile 3.27.0 registry+https://github.com/rust-lang/crates.io-index",
"terminal_size 0.4.4 registry+https://github.com/rust-lang/crates.io-index",
"thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index",
"ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index",
"unicode-ident 1.0.24 registry+https://github.com/rust-lang/crates.io-index",
"unicode-segmentation 1.13.2 registry+https://github.com/rust-lang/crates.io-index",
"url 2.5.8 registry+https://github.com/rust-lang/crates.io-index",
"utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index",
"utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index",
"version_check 0.9.5 registry+https://github.com/rust-lang/crates.io-index",
"web-time 1.1.0 registry+https://github.com/rust-lang/crates.io-index",
"webbrowser 1.2.5 registry+https://github.com/rust-lang/crates.io-index",
"weezl 0.1.12 registry+https://github.com/rust-lang/crates.io-index",
"winapi 0.3.9 registry+https://github.com/rust-lang/crates.io-index",
"windows 0.61.3 registry+https://github.com/rust-lang/crates.io-index",
"windows 0.62.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-collections 0.2.0 registry+https://github.com/rust-lang/crates.io-index",
"windows-collections 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-core 0.61.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-core 0.62.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-future 0.2.1 registry+https://github.com/rust-lang/crates.io-index",
"windows-future 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-implement 0.60.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-interface 0.59.3 registry+https://github.com/rust-lang/crates.io-index",
"windows-link 0.1.3 registry+https://github.com/rust-lang/crates.io-index",
"windows-link 0.2.1 registry+https://github.com/rust-lang/crates.io-index",
"windows-numerics 0.2.0 registry+https://github.com/rust-lang/crates.io-index",
"windows-numerics 0.3.1 registry+https://github.com/rust-lang/crates.io-index",
"windows-result 0.3.4 registry+https://github.com/rust-lang/crates.io-index",
"windows-result 0.4.1 registry+https://github.com/rust-lang/crates.io-index",
"windows-strings 0.4.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-strings 0.5.1 registry+https://github.com/rust-lang/crates.io-index",
"windows-sys 0.52.0 registry+https://github.com/rust-lang/crates.io-index",
"windows-sys 0.59.0 registry+https://github.com/rust-lang/crates.io-index",
@@ -108,9 +181,15 @@
"windows-sys 0.61.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-targets 0.52.6 registry+https://github.com/rust-lang/crates.io-index",
"windows-targets 0.53.5 registry+https://github.com/rust-lang/crates.io-index",
"windows-threading 0.1.0 registry+https://github.com/rust-lang/crates.io-index",
"windows-threading 0.2.1 registry+https://github.com/rust-lang/crates.io-index",
"windows_x86_64_msvc 0.52.6 registry+https://github.com/rust-lang/crates.io-index",
"windows_x86_64_msvc 0.53.1 registry+https://github.com/rust-lang/crates.io-index"
"windows_x86_64_msvc 0.53.1 registry+https://github.com/rust-lang/crates.io-index",
"winit 0.30.13 registry+https://github.com/rust-lang/crates.io-index",
"zerocopy 0.8.48 registry+https://github.com/rust-lang/crates.io-index",
"zerocopy-derive 0.8.48 registry+https://github.com/rust-lang/crates.io-index",
"zune-core 0.5.1 registry+https://github.com/rust-lang/crates.io-index",
"zune-jpeg 0.5.15 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
@@ -119,9 +198,25 @@
"rustix 1.1.4 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
"BSD-2-Clause",
[
"zerocopy 0.8.48 registry+https://github.com/rust-lang/crates.io-index",
"zerocopy-derive 0.8.48 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
"BSD-3-Clause",
[
"moxcms 0.8.1 registry+https://github.com/rust-lang/crates.io-index",
"pxfm 0.1.29 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
"BSL-1.0",
[
"clipboard-win 5.4.1 registry+https://github.com/rust-lang/crates.io-index",
"error-code 3.3.2 registry+https://github.com/rust-lang/crates.io-index",
"ryu 1.0.23 registry+https://github.com/rust-lang/crates.io-index"
]
],
@@ -131,6 +226,12 @@
"dunce 1.0.5 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
"ISC",
[
"libloading 0.8.9 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
"LicenseRef-Komorebi-2.0",
[
@@ -140,19 +241,31 @@
[
"MIT",
[
"accesskit 0.21.1 registry+https://github.com/rust-lang/crates.io-index",
"accesskit_consumer 0.31.0 registry+https://github.com/rust-lang/crates.io-index",
"accesskit_macos 0.22.2 registry+https://github.com/rust-lang/crates.io-index",
"accesskit_windows 0.29.2 registry+https://github.com/rust-lang/crates.io-index",
"addr2line 0.25.1 registry+https://github.com/rust-lang/crates.io-index",
"adler2 2.0.1 registry+https://github.com/rust-lang/crates.io-index",
"ahash 0.8.12 registry+https://github.com/rust-lang/crates.io-index",
"anstream 1.0.0 registry+https://github.com/rust-lang/crates.io-index",
"anstyle 1.0.14 registry+https://github.com/rust-lang/crates.io-index",
"anstyle-parse 1.0.0 registry+https://github.com/rust-lang/crates.io-index",
"anstyle-query 1.1.5 registry+https://github.com/rust-lang/crates.io-index",
"anstyle-wincon 3.0.11 registry+https://github.com/rust-lang/crates.io-index",
"arboard 3.6.1 registry+https://github.com/rust-lang/crates.io-index",
"autocfg 1.5.0 registry+https://github.com/rust-lang/crates.io-index",
"backtrace 0.3.76 registry+https://github.com/rust-lang/crates.io-index",
"bitflags 1.3.2 registry+https://github.com/rust-lang/crates.io-index",
"bitflags 2.11.1 registry+https://github.com/rust-lang/crates.io-index",
"block2 0.5.1 registry+https://github.com/rust-lang/crates.io-index",
"block2 0.6.2 registry+https://github.com/rust-lang/crates.io-index",
"bytemuck 1.25.0 registry+https://github.com/rust-lang/crates.io-index",
"bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index",
"byteorder-lite 0.1.0 registry+https://github.com/rust-lang/crates.io-index",
"cfg-if 1.0.4 registry+https://github.com/rust-lang/crates.io-index",
"cfg_aliases 0.2.1 registry+https://github.com/rust-lang/crates.io-index",
"cgl 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"chrono 0.4.44 registry+https://github.com/rust-lang/crates.io-index",
"clap 4.6.1 registry+https://github.com/rust-lang/crates.io-index",
"clap_builder 4.6.0 registry+https://github.com/rust-lang/crates.io-index",
@@ -161,43 +274,79 @@
"color-eyre 0.6.5 registry+https://github.com/rust-lang/crates.io-index",
"color-spantrace 0.3.0 registry+https://github.com/rust-lang/crates.io-index",
"colorchoice 1.0.5 registry+https://github.com/rust-lang/crates.io-index",
"core-foundation 0.9.4 registry+https://github.com/rust-lang/crates.io-index",
"core-foundation-sys 0.8.7 registry+https://github.com/rust-lang/crates.io-index",
"core-graphics 0.23.2 registry+https://github.com/rust-lang/crates.io-index",
"core-graphics-types 0.1.3 registry+https://github.com/rust-lang/crates.io-index",
"crc32fast 1.5.0 registry+https://github.com/rust-lang/crates.io-index",
"crossbeam-channel 0.5.15 registry+https://github.com/rust-lang/crates.io-index",
"crossbeam-utils 0.8.21 registry+https://github.com/rust-lang/crates.io-index",
"ctrlc 3.5.2 registry+https://github.com/rust-lang/crates.io-index",
"cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index",
"dirs 6.0.0 registry+https://github.com/rust-lang/crates.io-index",
"dirs-sys 0.5.0 registry+https://github.com/rust-lang/crates.io-index",
"dispatch 0.2.0 registry+https://github.com/rust-lang/crates.io-index",
"dispatch2 0.3.1 registry+https://github.com/rust-lang/crates.io-index",
"displaydoc 0.2.5 registry+https://github.com/rust-lang/crates.io-index",
"document-features 0.2.12 registry+https://github.com/rust-lang/crates.io-index",
"dpi 0.1.2 registry+https://github.com/rust-lang/crates.io-index",
"dyn-clone 1.0.20 registry+https://github.com/rust-lang/crates.io-index",
"ecolor 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"eframe 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"egui 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"egui-winit 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"egui_glow 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"emath 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"epaint 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"epaint_default_fonts 0.33.3 registry+https://github.com/rust-lang/crates.io-index",
"errno 0.3.14 registry+https://github.com/rust-lang/crates.io-index",
"eyre 0.6.12 registry+https://github.com/rust-lang/crates.io-index",
"fastrand 2.4.1 registry+https://github.com/rust-lang/crates.io-index",
"fax 0.2.7 registry+https://github.com/rust-lang/crates.io-index",
"fdeflate 0.3.7 registry+https://github.com/rust-lang/crates.io-index",
"flate2 1.1.9 registry+https://github.com/rust-lang/crates.io-index",
"foreign-types 0.5.0 registry+https://github.com/rust-lang/crates.io-index",
"foreign-types-macros 0.2.3 registry+https://github.com/rust-lang/crates.io-index",
"foreign-types-shared 0.3.1 registry+https://github.com/rust-lang/crates.io-index",
"form_urlencoded 1.2.2 registry+https://github.com/rust-lang/crates.io-index",
"getrandom 0.4.2 registry+https://github.com/rust-lang/crates.io-index",
"gimli 0.32.3 registry+https://github.com/rust-lang/crates.io-index",
"glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index",
"glutin-winit 0.5.0 registry+https://github.com/rust-lang/crates.io-index",
"half 2.7.1 registry+https://github.com/rust-lang/crates.io-index",
"hashbrown 0.15.5 registry+https://github.com/rust-lang/crates.io-index",
"heck 0.5.0 registry+https://github.com/rust-lang/crates.io-index",
"iana-time-zone 0.1.65 registry+https://github.com/rust-lang/crates.io-index",
"idna 1.1.0 registry+https://github.com/rust-lang/crates.io-index",
"idna_adapter 1.2.2 registry+https://github.com/rust-lang/crates.io-index",
"image 0.25.10 registry+https://github.com/rust-lang/crates.io-index",
"indenter 0.3.4 registry+https://github.com/rust-lang/crates.io-index",
"is_terminal_polyfill 1.70.2 registry+https://github.com/rust-lang/crates.io-index",
"itoa 1.0.18 registry+https://github.com/rust-lang/crates.io-index",
"lazy_static 1.5.0 registry+https://github.com/rust-lang/crates.io-index",
"libc 0.2.186 registry+https://github.com/rust-lang/crates.io-index",
"litrs 1.0.0 registry+https://github.com/rust-lang/crates.io-index",
"lock_api 0.4.14 registry+https://github.com/rust-lang/crates.io-index",
"log 0.4.29 registry+https://github.com/rust-lang/crates.io-index",
"memchr 2.8.0 registry+https://github.com/rust-lang/crates.io-index",
"memoffset 0.9.1 registry+https://github.com/rust-lang/crates.io-index",
"miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index",
"nix 0.31.2 registry+https://github.com/rust-lang/crates.io-index",
"nohash-hasher 0.2.0 registry+https://github.com/rust-lang/crates.io-index",
"ntapi 0.4.3 registry+https://github.com/rust-lang/crates.io-index",
"num-traits 0.2.19 registry+https://github.com/rust-lang/crates.io-index",
"objc-sys 0.3.5 registry+https://github.com/rust-lang/crates.io-index",
"objc2 0.5.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2 0.6.4 registry+https://github.com/rust-lang/crates.io-index",
"objc2-app-kit 0.2.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-app-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-av-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-core-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-core-graphics 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-core-media 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-core-video 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-encode 4.1.0 registry+https://github.com/rust-lang/crates.io-index",
"objc2-foundation 0.2.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-io-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-screen-capture-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
@@ -207,10 +356,14 @@
"owo-colors 4.3.0 registry+https://github.com/rust-lang/crates.io-index",
"parking_lot 0.12.5 registry+https://github.com/rust-lang/crates.io-index",
"parking_lot_core 0.9.12 registry+https://github.com/rust-lang/crates.io-index",
"percent-encoding 2.3.2 registry+https://github.com/rust-lang/crates.io-index",
"pin-project-lite 0.2.17 registry+https://github.com/rust-lang/crates.io-index",
"png 0.18.1 registry+https://github.com/rust-lang/crates.io-index",
"proc-macro2 1.0.106 registry+https://github.com/rust-lang/crates.io-index",
"profiling 1.0.17 registry+https://github.com/rust-lang/crates.io-index",
"quick-error 2.0.1 registry+https://github.com/rust-lang/crates.io-index",
"quote 1.0.45 registry+https://github.com/rust-lang/crates.io-index",
"raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index",
"ref-cast 1.0.25 registry+https://github.com/rust-lang/crates.io-index",
"ref-cast-impl 1.0.25 registry+https://github.com/rust-lang/crates.io-index",
"rustc-demangle 0.1.27 registry+https://github.com/rust-lang/crates.io-index",
@@ -227,29 +380,50 @@
"sharded-slab 0.1.7 registry+https://github.com/rust-lang/crates.io-index",
"simd-adler32 0.3.9 registry+https://github.com/rust-lang/crates.io-index",
"smallvec 1.15.1 registry+https://github.com/rust-lang/crates.io-index",
"smol_str 0.2.2 registry+https://github.com/rust-lang/crates.io-index",
"stable_deref_trait 1.2.1 registry+https://github.com/rust-lang/crates.io-index",
"static_assertions 1.1.0 registry+https://github.com/rust-lang/crates.io-index",
"strsim 0.11.1 registry+https://github.com/rust-lang/crates.io-index",
"syn 2.0.117 registry+https://github.com/rust-lang/crates.io-index",
"synstructure 0.13.2 registry+https://github.com/rust-lang/crates.io-index",
"sysinfo 0.38.4 registry+https://github.com/rust-lang/crates.io-index",
"tempfile 3.27.0 registry+https://github.com/rust-lang/crates.io-index",
"terminal_size 0.4.4 registry+https://github.com/rust-lang/crates.io-index",
"thread_local 1.1.9 registry+https://github.com/rust-lang/crates.io-index",
"tiff 0.11.3 registry+https://github.com/rust-lang/crates.io-index",
"tracing 0.1.44 registry+https://github.com/rust-lang/crates.io-index",
"tracing-core 0.1.36 registry+https://github.com/rust-lang/crates.io-index",
"tracing-error 0.2.1 registry+https://github.com/rust-lang/crates.io-index",
"tracing-subscriber 0.3.23 registry+https://github.com/rust-lang/crates.io-index",
"ttf-parser 0.25.1 registry+https://github.com/rust-lang/crates.io-index",
"uds_windows 1.2.1 registry+https://github.com/rust-lang/crates.io-index",
"unicode-ident 1.0.24 registry+https://github.com/rust-lang/crates.io-index",
"unicode-segmentation 1.13.2 registry+https://github.com/rust-lang/crates.io-index",
"url 2.5.8 registry+https://github.com/rust-lang/crates.io-index",
"utf8_iter 1.0.4 registry+https://github.com/rust-lang/crates.io-index",
"utf8parse 0.2.2 registry+https://github.com/rust-lang/crates.io-index",
"version_check 0.9.5 registry+https://github.com/rust-lang/crates.io-index",
"web-time 1.1.0 registry+https://github.com/rust-lang/crates.io-index",
"webbrowser 1.2.5 registry+https://github.com/rust-lang/crates.io-index",
"weezl 0.1.12 registry+https://github.com/rust-lang/crates.io-index",
"winapi 0.3.9 registry+https://github.com/rust-lang/crates.io-index",
"windows 0.61.3 registry+https://github.com/rust-lang/crates.io-index",
"windows 0.62.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-collections 0.2.0 registry+https://github.com/rust-lang/crates.io-index",
"windows-collections 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-core 0.61.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-core 0.62.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-future 0.2.1 registry+https://github.com/rust-lang/crates.io-index",
"windows-future 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-implement 0.60.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-interface 0.59.3 registry+https://github.com/rust-lang/crates.io-index",
"windows-link 0.1.3 registry+https://github.com/rust-lang/crates.io-index",
"windows-link 0.2.1 registry+https://github.com/rust-lang/crates.io-index",
"windows-numerics 0.2.0 registry+https://github.com/rust-lang/crates.io-index",
"windows-numerics 0.3.1 registry+https://github.com/rust-lang/crates.io-index",
"windows-result 0.3.4 registry+https://github.com/rust-lang/crates.io-index",
"windows-result 0.4.1 registry+https://github.com/rust-lang/crates.io-index",
"windows-strings 0.4.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-strings 0.5.1 registry+https://github.com/rust-lang/crates.io-index",
"windows-sys 0.52.0 registry+https://github.com/rust-lang/crates.io-index",
"windows-sys 0.59.0 registry+https://github.com/rust-lang/crates.io-index",
@@ -257,10 +431,16 @@
"windows-sys 0.61.2 registry+https://github.com/rust-lang/crates.io-index",
"windows-targets 0.52.6 registry+https://github.com/rust-lang/crates.io-index",
"windows-targets 0.53.5 registry+https://github.com/rust-lang/crates.io-index",
"windows-threading 0.1.0 registry+https://github.com/rust-lang/crates.io-index",
"windows-threading 0.2.1 registry+https://github.com/rust-lang/crates.io-index",
"windows_x86_64_msvc 0.52.6 registry+https://github.com/rust-lang/crates.io-index",
"windows_x86_64_msvc 0.53.1 registry+https://github.com/rust-lang/crates.io-index",
"zmij 1.0.21 registry+https://github.com/rust-lang/crates.io-index"
"xml-rs 0.8.28 registry+https://github.com/rust-lang/crates.io-index",
"zerocopy 0.8.48 registry+https://github.com/rust-lang/crates.io-index",
"zerocopy-derive 0.8.48 registry+https://github.com/rust-lang/crates.io-index",
"zmij 1.0.21 registry+https://github.com/rust-lang/crates.io-index",
"zune-core 0.5.1 registry+https://github.com/rust-lang/crates.io-index",
"zune-jpeg 0.5.15 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
@@ -275,30 +455,70 @@
"option-ext 0.2.0 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
"OFL-1.1",
[
"epaint_default_fonts 0.33.3 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
"Ubuntu-font-1.0",
[
"epaint_default_fonts 0.33.3 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
"Unicode-3.0",
[
"unicode-ident 1.0.24 registry+https://github.com/rust-lang/crates.io-index"
"icu_collections 2.2.0 registry+https://github.com/rust-lang/crates.io-index",
"icu_locale_core 2.2.0 registry+https://github.com/rust-lang/crates.io-index",
"icu_normalizer 2.2.0 registry+https://github.com/rust-lang/crates.io-index",
"icu_normalizer_data 2.2.0 registry+https://github.com/rust-lang/crates.io-index",
"icu_properties 2.2.0 registry+https://github.com/rust-lang/crates.io-index",
"icu_properties_data 2.2.0 registry+https://github.com/rust-lang/crates.io-index",
"icu_provider 2.2.0 registry+https://github.com/rust-lang/crates.io-index",
"litemap 0.8.2 registry+https://github.com/rust-lang/crates.io-index",
"potential_utf 0.1.5 registry+https://github.com/rust-lang/crates.io-index",
"tinystr 0.8.3 registry+https://github.com/rust-lang/crates.io-index",
"unicode-ident 1.0.24 registry+https://github.com/rust-lang/crates.io-index",
"writeable 0.6.3 registry+https://github.com/rust-lang/crates.io-index",
"yoke 0.8.2 registry+https://github.com/rust-lang/crates.io-index",
"yoke-derive 0.8.2 registry+https://github.com/rust-lang/crates.io-index",
"zerofrom 0.1.7 registry+https://github.com/rust-lang/crates.io-index",
"zerofrom-derive 0.1.7 registry+https://github.com/rust-lang/crates.io-index",
"zerotrie 0.2.4 registry+https://github.com/rust-lang/crates.io-index",
"zerovec 0.11.6 registry+https://github.com/rust-lang/crates.io-index",
"zerovec-derive 0.11.3 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
"Unlicense",
[
"byteorder-lite 0.1.0 registry+https://github.com/rust-lang/crates.io-index",
"memchr 2.8.0 registry+https://github.com/rust-lang/crates.io-index"
]
],
[
"Zlib",
[
"bytemuck 1.25.0 registry+https://github.com/rust-lang/crates.io-index",
"bytemuck_derive 1.10.2 registry+https://github.com/rust-lang/crates.io-index",
"cursor-icon 1.2.0 registry+https://github.com/rust-lang/crates.io-index",
"dispatch2 0.3.1 registry+https://github.com/rust-lang/crates.io-index",
"foldhash 0.1.5 registry+https://github.com/rust-lang/crates.io-index",
"glow 0.16.0 registry+https://github.com/rust-lang/crates.io-index",
"miniz_oxide 0.8.9 registry+https://github.com/rust-lang/crates.io-index",
"objc2-app-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-av-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-core-foundation 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-core-graphics 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-core-media 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-core-video 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-io-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"objc2-screen-capture-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index"
"objc2-screen-capture-kit 0.3.2 registry+https://github.com/rust-lang/crates.io-index",
"raw-window-handle 0.6.2 registry+https://github.com/rust-lang/crates.io-index",
"zune-core 0.5.1 registry+https://github.com/rust-lang/crates.io-index",
"zune-jpeg 0.5.15 registry+https://github.com/rust-lang/crates.io-index"
]
]
]
+10
View File
@@ -102,6 +102,16 @@ the locked file.
The wire protocol is the same on both. The recorder's own binary does not depend on either komorebi's crates.
### The program's own windows
The recorder window and the viewer must not be in the video they are recording, and komorebi must not tile them.
| | macOS | Windows |
|---|---|---|
| left out of the video | by name: every process called `komorebi-recorder` is excluded from the capture | each window asks to be left out of captures with `WDA_EXCLUDEFROMCAPTURE` (Windows 10 version 2004 and later) |
| left alone by komorebi | the windows have no title, which komorebi does not manage | the same, and `KOMOREBI_RECORDER_PROBE_WINDOW=1` makes a window ask komorebi whether it would manage it and write the answer to `komorebi-recorder-window-probe.txt` in the temp directory |
| executables | `komorebi-recorder` | `komorebi-recorder.exe` (console: run commands with this one) and `komorebi-recorder-gui.exe` (no console window) |
## Degraded modes
- `record --no-video` records everything but the screen, on the same clock. It asks the system nothing about displays and
+8
View File
@@ -6,6 +6,7 @@ was the OS doing, at 00:12.5 in the video?" and the other way around.
```
komorebi-recorder record --duration 30 # record without a window
komorebi-recorder # or open the Record / Stop window
```
It is built for the situations where komorebi bugs actually show up: laptops that get docked and undocked, woken with the
@@ -44,6 +45,7 @@ directory; a session recorded on one OS can be investigated on the other. What d
Start komorebi with `komorebi.exe --log-level debug` before recording a bug. (`RUST_LOG=debug` also
prints every dependency's log; `RUST_LOG=komorebi=debug` does not.)
`komorebi-recorder record --no-video` records without the screen.
The recorder window keeps itself out of the video (Windows 10 version 2004 or later).
## Before you record
@@ -53,12 +55,18 @@ prints every dependency's log; `RUST_LOG=komorebi=debug` does not.)
repro, start komorebi with `komorebi --log-level trace` (or `RUST_LOG=komorebi=trace`) first. At the default `info`
level most of what the window manager _decided_ is not in the log.
The recorder window is borderless and untitled on purpose: komorebi does not manage windows without a title, so opening
it does not move your layout around while you are trying to reproduce a layout bug. It is also excluded from the video, as is any other `komorebi-recorder` process.
## Recording
Press **Record**, reproduce the problem, press **Stop**. The window shows live counters, recent events (a display being
unplugged, a wake) and any warnings. The session is written to
`~/Library/Application Support/komorebi/recordings/<UTC timestamp>/` unless you pass `--out`.
With every display ticked, the recorder follows _all_ displays, including ones connected while it is recording. Untick a
display to record only the others.
Headless recording is the same thing without the window; Ctrl-C, `SIGTERM` or `--duration` stops and finalizes it:
```
+1
View File
@@ -13,6 +13,7 @@ crossbeam-channel = { workspace = true }
ctrlc = { version = "3", features = ["termination"] }
dirs = { workspace = true }
dunce = { workspace = true }
eframe = { workspace = true }
parking_lot = { workspace = true }
png = "0.18"
schemars = { workspace = true }
+591
View File
@@ -0,0 +1,591 @@
//! The recorder window: Record / Stop, live counters and warnings.
//!
//! This is what `komorebi-recorder` opens when it is run with no subcommand, and with `gui`: [`run`]
//! shows a small window and keeps it until it is closed. It is the same recorder as
//! `komorebi-recorder record`, with a window instead of Ctrl-C.
//!
//! # What the window does
//!
//! | control | effect |
//! |---|---|
//! | Record | starts a recording on a thread named `recorder` ([`recorder::record`]), with the options the window was started with, the displays ticked below and the predicate typed under Advanced |
//! | Stop | asks the recording to finish ([`Live::request_stop`]); it indexes and finalizes the session, which the window shows as "finalizing..." |
//! | Open session..., Open last | open the viewer on a recording, in a process of its own |
//! | Copy path, Open in the file manager | after a recording: copy where the session was saved, or show it (Finder or Explorer) |
//!
//! While idle the list of displays is read again every second, so a display that was docked or
//! undocked appears or disappears and a new one starts ticked. With every display ticked the
//! recorder follows all of them, including any connected while recording; with one unticked it
//! records only the ticked ones. While recording the window shows counters (video frames and the
//! frames dropped, the size of komorebi's log, the number of komorebi events, the OS trace and each
//! of its streams), the most recent incidents to the recording environment, and any warnings.
//!
//! The window does not mark where a bug is: that is done afterwards, in the viewer.
//!
//! Closing the window while recording, or delivering SIGINT or SIGTERM to the process (the handler
//! also runs on SIGHUP on Unix, and on Ctrl-C on Windows), finishes and indexes the session first
//! rather than leaving it half-written, and only then closes the window.
//!
//! # Staying out of the video and out of the layout
//!
//! The window is for use on the machine whose behavior is being recorded, so it must not appear in
//! the video and must not be tiled by komorebi.
//!
//! - **Not in the video.** On macOS the capture filter excludes this whole application (this
//! process and every process named `komorebi-recorder`), so the controls never appear in the
//! video. On Windows a whole monitor is captured, so about once a second the window asks Windows
//! to leave it out of captures (`WDA_EXCLUDEFROMCAPTURE`) through
//! [`crate::platform::window::Chrome`].
//! - **Not tiled.** The window is deliberately borderless and untitled, with its own drag handle
//! and close button, and always on top. komorebi does not manage windows that have no title (komorebi
//! for Mac rejects them in `Window::should_manage`), so opening the recorder does not perturb the
//! very layout being observed: a titled window would be tiled into the workspace. On Windows
//! `KOMOREBI_RECORDER_PROBE_WINDOW=1` makes the window ask komorebi whether it would manage it
//! (see [`crate::platform::window::PROBE_VARIABLE`]).
//!
//! The window needs an `egui::Context` to draw and a screen to record, so it has no example. Its
//! logic that does not need either is covered by this module's unit test
//! (`the_latest_session_is_the_last_by_name_and_must_be_a_session`).
use crate::capture::DisplayDescriptor;
use crate::cli::RecordArgs;
use crate::platform::capture;
use crate::platform::shell;
use crate::recorder;
use crate::recorder::Live;
use crate::recorder::Phase;
use crate::timecode;
use color_eyre::eyre;
use eframe::egui;
use std::path::PathBuf;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::thread::JoinHandle;
use std::time::Duration;
use std::time::Instant;
/// Returns the newest session in `recordings`: sessions are folders named for when they began, so
/// the last by name is the latest.
///
/// A folder counts as a session only if it has a session manifest
/// ([`MANIFEST_FILE`](crate::session::MANIFEST_FILE)): a newer folder that is not a session is
/// passed over. `None` if there is no session, or `recordings` cannot be read (it does not exist,
/// or is not a folder). The window offers the result as "Open last", with
/// [`default_recordings_dir`](crate::session::default_recordings_dir) as `recordings`.
///
/// # Example
///
/// ```rust
/// use komorebi_recorder::app::latest_session_in;
/// use komorebi_recorder::session::MANIFEST_FILE;
///
/// let name = format!("komorebi-recorder-doc-latest-{}", std::process::id());
/// let recordings = std::env::temp_dir().join(name);
/// for session in ["20261026T100000Z", "20261026T120000Z", "20261025T090000Z"] {
/// std::fs::create_dir_all(recordings.join(session))?;
/// std::fs::write(recordings.join(session).join(MANIFEST_FILE), "{}")?;
/// }
/// // a newer folder that is not a session does not count
/// std::fs::create_dir_all(recordings.join("20261027T000000Z"))?;
///
/// assert_eq!(
/// latest_session_in(&recordings),
/// Some(recordings.join("20261026T120000Z")),
/// );
/// assert_eq!(latest_session_in(&recordings.join("nothing-here")), None);
/// # std::fs::remove_dir_all(&recordings)?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
#[must_use]
pub fn latest_session_in(recordings: &std::path::Path) -> Option<PathBuf> {
std::fs::read_dir(recordings)
.ok()?
.filter_map(Result::ok)
.map(|entry| entry.path())
.filter(|path| path.join(crate::session::MANIFEST_FILE).is_file())
.max()
}
/// Open the viewer, in its own process, on `session` if given. A separate process, so that
/// reviewing a recording can never disturb one being made, and kept out of the video (by name on
/// macOS, and by each of its windows asking on Windows).
fn open_viewer(session: Option<&std::path::Path>) -> std::io::Result<()> {
// on Windows the viewer is the build without a console, so that no console window opens with it
let this = std::env::current_exe()?;
let gui = this.with_file_name(format!(
"komorebi-recorder-gui{}",
std::env::consts::EXE_SUFFIX
));
let program = if cfg!(windows) && gui.is_file() {
gui
} else {
this
};
let mut command = std::process::Command::new(program);
// no console window flashing up for it
#[cfg(windows)]
crate::platform::process::isolate(&mut command);
command.arg("view");
if let Some(session) = session {
command.arg(session);
}
command.spawn().map(|_| ())
}
/// Set by SIGINT/SIGTERM: the window finishes any recording in progress, then closes.
static QUIT: AtomicBool = AtomicBool::new(false);
/// How often the list of attached displays is refreshed while idle.
const DISPLAY_REFRESH: Duration = Duration::from_secs(1);
/// Opens the recorder window and runs it until it is closed.
///
/// `args` are the options of `komorebi-recorder record` that the window starts from, such as
/// `--fps`, `--codec` and `--no-komorebi`. Each recording uses them, except that the displays ticked in
/// the window replace `--display` (every display ticked means every display, including any
/// connected while recording) and a predicate typed under Advanced replaces `--predicate`.
///
/// This blocks the calling thread: the window's event loop runs on it. It installs a handler for
/// SIGINT and SIGTERM (it also runs on SIGHUP on Unix, and on Ctrl-C on Windows) that asks the
/// window to finish any recording in progress and close, so that killing the window, or logging
/// out, still finalizes the session. Failing to install the handler (another is already
/// installed) is ignored.
///
/// A recording that fails does not make this fail: the window shows why, and can record again.
///
/// The window is 420 by 380 points (at least 360 by 260), borderless, untitled and always on top:
/// see the [module documentation](self#staying-out-of-the-video-and-out-of-the-layout). Needs a
/// window, so there is no example.
///
/// # Errors
///
/// Returns an error saying "the recorder window failed" if the window cannot be created or its
/// event loop fails (for example, there is no display or no usable graphics adapter).
pub fn run(args: RecordArgs) -> eyre::Result<()> {
// killing the window (or logging out) must still finalize a recording in progress
let _ = ctrlc::set_handler(|| QUIT.store(true, Ordering::SeqCst));
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
// no title: komorebi leaves untitled windows alone
.with_title("")
.with_decorations(false)
.with_inner_size([420.0, 380.0])
.with_min_inner_size([360.0, 260.0])
.with_always_on_top(),
..Default::default()
};
eframe::run_native(
"komorebi-recorder",
options,
Box::new(|_creation_context| Ok(Box::new(RecorderApp::new(args)))),
)
.map_err(|error| eyre::Report::msg(format!("the recorder window failed: {error}")))
}
type Worker = JoinHandle<eyre::Result<PathBuf>>;
struct RecorderApp {
chrome: crate::platform::window::Chrome,
args: RecordArgs,
live: Arc<Live>,
worker: Option<Worker>,
permission: bool,
displays: Vec<(DisplayDescriptor, bool)>,
displays_refreshed: Instant,
last: Option<Result<PathBuf, String>>,
closing: bool,
predicate: String,
show_streams: bool,
}
impl RecorderApp {
fn new(args: RecordArgs) -> Self {
let mut app = Self {
chrome: crate::platform::window::Chrome::default(),
predicate: args.predicate.clone().unwrap_or_default(),
args,
live: Live::new(),
worker: None,
permission: capture::has_permission(),
displays: Vec::new(),
displays_refreshed: Instant::now() - DISPLAY_REFRESH,
last: None,
closing: false,
show_streams: false,
};
app.refresh_displays();
app
}
/// Re-read the attached displays (cheap, and needs no permission), keeping the ticks of the
/// ones that are still there. Displays that were docked or undocked since the last look
/// appear and disappear here, and a new one starts ticked.
fn refresh_displays(&mut self) {
self.displays_refreshed = Instant::now();
let Ok(present) = capture::active_displays() else {
return;
};
let previous: Vec<(u32, bool)> = self
.displays
.iter()
.map(|(display, selected)| (display.id, *selected))
.collect();
self.displays = present
.into_iter()
.map(|display| {
let selected = previous
.iter()
.find(|(id, _)| *id == display.id)
.is_none_or(|(_, selected)| *selected);
(display, selected)
})
.collect();
}
fn recording(&self) -> bool {
self.worker.is_some()
}
fn start(&mut self) {
let mut args = self.args.clone();
// with every display ticked, record *every* display including ones connected while
// recording; otherwise only the ticked ones
args.displays = if self.displays.iter().all(|(_, selected)| *selected) {
Vec::new()
} else {
self.displays
.iter()
.filter(|(_, selected)| *selected)
.map(|(display, _)| display.id)
.collect()
};
let predicate = self.predicate.trim();
args.predicate = (!predicate.is_empty()).then(|| predicate.to_string());
let options = args.to_options();
self.live.reset();
self.last = None;
let live = self.live.clone();
match std::thread::Builder::new()
.name("recorder".to_string())
.spawn(move || recorder::record(&options, &live))
{
Ok(worker) => self.worker = Some(worker),
Err(error) => self.last = Some(Err(format!("could not start recording: {error}"))),
}
}
fn poll(&mut self, context: &egui::Context) {
if !self.recording() && self.displays_refreshed.elapsed() >= DISPLAY_REFRESH {
self.refresh_displays();
}
if self.worker.as_ref().is_some_and(JoinHandle::is_finished)
&& let Some(worker) = self.worker.take()
{
self.last = Some(match worker.join() {
Ok(Ok(dir)) => Ok(dir),
Ok(Err(error)) => Err(format!("{error:#}")),
Err(_) => Err("the recording thread panicked".to_string()),
});
self.live.reset();
}
let quit_signalled = QUIT.load(Ordering::SeqCst);
if (quit_signalled || context.input(|input| input.viewport().close_requested()))
&& self.recording()
{
// finish and index the session before exiting rather than leaving it half-written
context.send_viewport_cmd(egui::ViewportCommand::CancelClose);
self.live.request_stop();
self.closing = true;
}
if (self.closing || quit_signalled) && !self.recording() {
context.send_viewport_cmd(egui::ViewportCommand::Close);
}
}
}
fn human_bytes(bytes: u64) -> String {
const UNITS: [&str; 4] = ["B", "KB", "MB", "GB"];
let mut value = bytes as f64;
let mut unit = 0;
while value >= 1024.0 && unit < UNITS.len() - 1 {
value /= 1024.0;
unit += 1;
}
if unit == 0 {
format!("{bytes} B")
} else {
format!("{value:.1} {}", UNITS[unit])
}
}
impl eframe::App for RecorderApp {
fn update(&mut self, context: &egui::Context, _frame: &mut eframe::Frame) {
self.chrome.tick();
self.poll(context);
context.request_repaint_after(Duration::from_millis(200));
let snapshot = self.live.snapshot();
let recording = self.recording();
let busy = matches!(snapshot.phase, Phase::Starting | Phase::Stopping);
egui::CentralPanel::default().show(context, |ui| {
// drag handle and close button, since there is no title bar
let header = egui::Rect::from_min_size(
ui.min_rect().min,
egui::vec2(ui.available_width(), 24.0),
);
let drag = ui.interact(header, ui.id().with("drag"), egui::Sense::drag());
if drag.drag_started() {
context.send_viewport_cmd(egui::ViewportCommand::StartDrag);
}
ui.horizontal(|ui| {
ui.label(egui::RichText::new("komorebi-recorder").strong());
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if ui.button("×").on_hover_text("Close").clicked() {
context.send_viewport_cmd(egui::ViewportCommand::Close);
}
});
});
ui.separator();
ui.horizontal(|ui| {
let can_record = !recording && self.permission && !self.displays.is_empty();
if ui
.add_enabled(
can_record,
egui::Button::new("Record").min_size([110.0, 32.0].into()),
)
.clicked()
{
self.start();
}
if ui
.add_enabled(
recording && !busy && !self.live.stop_requested(),
egui::Button::new("Stop").min_size([110.0, 32.0].into()),
)
.clicked()
{
self.live.request_stop();
}
let state = match snapshot.phase {
Phase::Starting => "starting...".to_string(),
Phase::Recording => format!("REC {}", timecode::format(snapshot.elapsed_s)),
Phase::Stopping => "finalizing...".to_string(),
_ => "ready".to_string(),
};
ui.label(egui::RichText::new(state).size(18.0).monospace());
});
ui.separator();
// reviewing: open a recording in the viewer, which is its own window
ui.horizontal(|ui| {
ui.label(egui::RichText::new("Review").small().weak());
if ui
.button("Open session…")
.on_hover_text("play and scrub a recording")
.clicked()
&& let Err(error) = open_viewer(None)
{
self.last = Some(Err(format!("could not open the viewer: {error}")));
}
let last = match &self.last {
Some(Ok(dir)) => Some(dir.clone()),
_ => latest_session_in(&crate::session::default_recordings_dir()),
};
if ui
.add_enabled(last.is_some(), egui::Button::new("Open last"))
.on_hover_text("the most recent recording")
.clicked()
&& let Some(dir) = last
&& let Err(error) = open_viewer(Some(&dir))
{
self.last = Some(Err(format!("could not open the viewer: {error}")));
}
});
ui.separator();
if !self.permission {
ui.colored_label(
egui::Color32::YELLOW,
"Screen Recording permission is needed to record the screen.",
);
if ui.button("Grant permission").clicked() {
match capture::ensure_permission() {
Ok(()) => self.permission = true,
Err(error) => self.last = Some(Err(format!("{error:#}"))),
}
}
} else {
ui.add_enabled_ui(!recording, |ui| {
ui.horizontal_wrapped(|ui| {
ui.label("Displays:");
for (display, selected) in &mut self.displays {
ui.checkbox(
selected,
format!(
"{} ({}×{})",
display.id, display.width_points, display.height_points
),
);
}
});
});
}
if recording {
ui.add_space(6.0);
egui::Grid::new("counters").num_columns(2).show(ui, |ui| {
ui.label("displays");
ui.label(if snapshot.displays_retrying.is_empty() {
format!("{} recording", snapshot.displays_recording)
} else {
format!(
"{} recording, waiting to retry {:?}",
snapshot.displays_recording, snapshot.displays_retrying
)
});
ui.end_row();
ui.label("video frames");
ui.label(format!(
"{} ({} dropped)",
snapshot.frames, snapshot.dropped
));
ui.end_row();
ui.label("komorebi log");
ui.label(human_bytes(snapshot.log_bytes));
ui.end_row();
ui.label("komorebi events");
ui.label(snapshot.events.to_string());
ui.end_row();
ui.label("OS trace");
ui.label(format!(
"{} events, {} across {} streams",
snapshot.oslog_events,
human_bytes(snapshot.oslog_bytes),
snapshot.streams.len()
));
ui.end_row();
});
ui.collapsing("OS trace streams", |ui| {
self.show_streams = true;
for stream in &snapshot.streams {
ui.label(format!(
"{}: {} events, {}",
stream.name,
stream.events,
human_bytes(stream.bytes)
));
}
});
} else {
ui.collapsing("Advanced", |ui| {
ui.label("`system` OS trace predicate (blank for the default):");
ui.text_edit_singleline(&mut self.predicate);
});
}
if !snapshot.incidents.is_empty() {
ui.add_space(6.0);
ui.label(egui::RichText::new("Recent events").small().weak());
for incident in snapshot.incidents.iter().rev().take(4) {
ui.label(egui::RichText::new(incident).small().weak());
}
}
if !snapshot.warnings.is_empty() {
ui.add_space(6.0);
egui::ScrollArea::vertical()
.max_height(110.0)
.id_salt("warnings")
.show(ui, |ui| {
for warning in &snapshot.warnings {
ui.colored_label(egui::Color32::YELLOW, format!("! {warning}"));
}
});
}
match &self.last {
Some(Ok(dir)) => {
ui.add_space(8.0);
ui.separator();
ui.label("Saved session:");
ui.monospace(dir.display().to_string());
ui.horizontal(|ui| {
if ui.button("Copy path").clicked() {
context.copy_text(dir.display().to_string());
}
if ui
.button(format!("Open in {}", shell::FILE_MANAGER))
.clicked()
{
shell::reveal(dir);
}
});
ui.label(format!(
"Investigate it: komorebi-recorder brief {}",
dir.display()
));
}
Some(Err(error)) => {
ui.add_space(8.0);
ui.colored_label(egui::Color32::LIGHT_RED, error);
}
None => {}
}
});
}
}
#[cfg(test)]
mod tests {
use super::*;
fn temp(name: &str) -> PathBuf {
let dir = std::env::temp_dir().join(format!(
"komorebi-recorder-app-{name}-{}",
std::process::id()
));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).expect("dir");
dir
}
#[test]
fn the_latest_session_is_the_last_by_name_and_must_be_a_session() {
let recordings = temp("recordings");
for name in ["20261026T100000Z", "20261026T120000Z", "20261025T090000Z"] {
let dir = recordings.join(name);
std::fs::create_dir_all(&dir).expect("dir");
std::fs::write(dir.join(crate::session::MANIFEST_FILE), "{}").expect("manifest");
}
// a newer folder that is not a session does not count
std::fs::create_dir_all(recordings.join("20261027T000000Z")).expect("dir");
assert_eq!(
latest_session_in(&recordings),
Some(recordings.join("20261026T120000Z"))
);
assert_eq!(latest_session_in(&recordings.join("nothing-here")), None);
}
}
@@ -0,0 +1,18 @@
//! The same program as `komorebi-recorder`, built for the Windows GUI subsystem: it opens no
//! console window, which is what a shortcut or the recorder window launching the viewer wants.
//! Its output goes nowhere, so use `komorebi-recorder` to run a command and read what it prints.
//! (On other systems there is no such distinction and this is the same binary.)
//!
//! `main` is [`komorebi_recorder::cli::main`], as it is for `komorebi-recorder`: it reads the
//! command line and runs the command, and with no command opens the recorder window
//! ([`komorebi_recorder::app::run`]). The recorder window starts the viewer by running this
//! executable with `view` when it is next to the one that is running (on Windows), so that
//! opening a recording does not open a console window beside it.
#![cfg_attr(windows, windows_subsystem = "windows")]
use color_eyre::eyre;
use std::process::ExitCode;
fn main() -> eyre::Result<ExitCode> {
komorebi_recorder::cli::main()
}
+8 -8
View File
@@ -38,6 +38,8 @@ pub struct Opts {
/// What `komorebi-recorder` was asked to do.
#[derive(Subcommand)]
pub enum Command {
/// Open the recorder window with Record / Stop buttons (the default)
Gui(RecordArgs),
/// Record without a window; Ctrl-C (or --duration) stops and finalizes the session
Record(RecordArgs),
/// List the displays that can be recorded
@@ -92,6 +94,7 @@ pub fn execute(command: Command) -> std::process::ExitCode {
/// Returns whatever error the command fails with; [`execute`] turns it into an exit status.
pub fn run(command: Command) -> eyre::Result<()> {
match command {
Command::Gui(args) => crate::app::run(args),
Command::Record(args) => record::record(&args),
Command::Displays => record::displays(),
Command::Reindex(args) => reindex(&args),
@@ -100,7 +103,7 @@ pub fn run(command: Command) -> eyre::Result<()> {
/// What both binaries (`komorebi-recorder` and, on Windows, the no-console
/// `komorebi-recorder-gui`) do: read the command line and run it.
/// No command prints the usage.
/// No command opens the recorder window.
///
/// # Errors
///
@@ -113,13 +116,10 @@ pub fn main() -> eyre::Result<std::process::ExitCode> {
crate::platform::init();
let opts = Opts::parse();
let Some(command) = opts.command else {
use clap::CommandFactory;
Opts::command().print_help()?;
return Ok(std::process::ExitCode::from(2));
};
Ok(execute(command))
Ok(execute(
opts.command
.unwrap_or_else(|| Command::Gui(RecordArgs::default())),
))
}
fn reindex(args: &ReindexArgs) -> eyre::Result<()> {
+2
View File
@@ -55,6 +55,7 @@
//! | [`annotations`] | the bug regions, notes and findings written into a session |
//! | [`recovery`] | rebuilding a session whose recorder died |
//! | [`cli`] | the command line |
//! | [`app`] | the recorder window |
//!
//! # What is not supported
//!
@@ -69,6 +70,7 @@
pub mod analysis;
pub mod annotations;
pub mod app;
pub mod capture;
pub mod cli;
pub mod clock;
+2
View File
@@ -13,6 +13,7 @@
//! | [`capture`] | can we capture, which displays exist, the real [`CaptureBackend`], a video's duration |
//! | [`power`] | hearing about sleep, wake, lock and display changes as they happen |
//! | [`session`] | is the screen locked, is this user's session in front |
//! | [`window`] | what the program's own windows do about being recorded and being tiled |
//!
//! A third host, `unsupported`, builds on anything else so that the investigation commands (which
//! only read a session directory) still work on a Linux agent box; recording there says so.
@@ -60,6 +61,7 @@ pub use imp::process;
pub use imp::session;
pub use imp::shell;
pub use imp::trace;
pub mod window;
/// Whether this host has an OS trace to record alongside komorebi's own output.
///
@@ -30,6 +30,7 @@ pub mod process;
pub mod session;
pub mod shell;
pub mod trace;
pub mod window;
/// Does what Windows needs once, first thing in `main`: makes the process per-monitor DPI aware
/// ([`capture::become_per_monitor_dpi_aware`]), so that every size and position it reads is in
@@ -0,0 +1,75 @@
//! This program's own windows, on Windows, and what Windows says about any window.
//!
//! The recorder window and the viewer must not be in the video they are recording, and komorebi
//! must not tile them. A Mac records by application and excludes the recorder's by name; Windows
//! captures a whole monitor, so each window asks to be left out of captures
//! (`WDA_EXCLUDEFROMCAPTURE`, Windows 10 version 2004 and later; before that the only option
//! blanks the window in the video, which is worse, so it is not used).
//!
//! | item | for |
//! |---|---|
//! | [`exclude_from_capture`] | asking for this process's windows to be left out of captures |
//! | [`own_window_handles`] | the handles of those windows, as komorebi knows windows |
//!
//! This module is not part of the facade: [`crate::platform::window`], which is shared by every
//! host, calls it. Nothing tests it automatically; it acts on real windows, and is checked on a
//! real machine (see `docs/dev/windows-checkpoints.md`).
use std::ffi::c_void;
use windows::Win32::Foundation::HWND;
use windows::Win32::Foundation::LPARAM;
use windows::Win32::System::Threading::GetCurrentProcessId;
use windows::Win32::UI::WindowsAndMessaging::EnumWindows;
use windows::Win32::UI::WindowsAndMessaging::GetWindowThreadProcessId;
use windows::Win32::UI::WindowsAndMessaging::IsWindowVisible;
use windows::Win32::UI::WindowsAndMessaging::SetWindowDisplayAffinity;
use windows::Win32::UI::WindowsAndMessaging::WDA_EXCLUDEFROMCAPTURE;
use windows::core::BOOL;
unsafe extern "system" fn collect(window: HWND, found: LPARAM) -> BOOL {
// SAFETY: `found` is the address of the vector `own_windows` passed to `EnumWindows`
let found = unsafe { &mut *(found.0 as *mut Vec<isize>) };
let mut pid = 0_u32;
// SAFETY: `window` is a handle `EnumWindows` just gave us
unsafe { GetWindowThreadProcessId(window, Some(&raw mut pid)) };
// SAFETY: no preconditions
if pid == unsafe { GetCurrentProcessId() } && unsafe { IsWindowVisible(window) }.as_bool() {
found.push(window.0 as isize);
}
BOOL(1)
}
fn own_windows() -> Vec<isize> {
let mut found: Vec<isize> = Vec::new();
// SAFETY: `found` outlives the call and `collect` only touches it during it
let _ = unsafe { EnumWindows(Some(collect), LPARAM(&raw mut found as isize)) };
found
}
/// Returns the handles of this process's visible top-level windows, as komorebi knows windows: the
/// window handle as a `u32`, the number komorebi for Windows calls a window's `hwnd`.
#[must_use]
pub fn own_window_handles() -> Vec<u32> {
own_windows()
.into_iter()
.map(|window| window as usize as u32)
.collect()
}
/// Asks for each of this process's visible top-level windows to be left out of screen captures
/// (`WDA_EXCLUDEFROMCAPTURE`), and returns how many accepted. None accept on a Windows too old for
/// it (before Windows 10 version 2004). A window created after the call is not covered until it is
/// called again.
pub fn exclude_from_capture() -> usize {
own_windows()
.into_iter()
.filter(|window| {
// SAFETY: a window of this process, which is the only kind this may be called for
unsafe {
SetWindowDisplayAffinity(HWND(*window as *mut c_void), WDA_EXCLUDEFROMCAPTURE)
}
.is_ok()
})
.count()
}
+120
View File
@@ -0,0 +1,120 @@
//! What this program's windows do about being in the video and being tiled, which differs by OS.
//!
//! The recorder window ([`crate::app`]) and the viewer must not be in the video they are
//! recording, and komorebi must not tile them. The two hosts get there differently:
//!
//! | | macOS | Windows |
//! |---|---|---|
//! | left out of the video | the recorder excludes its own processes from the capture by name ([`crate::capture`]) | each window asks to be left out of captures, because Windows captures a whole monitor |
//! | left alone by komorebi | the windows are created with no title, which komorebi for Mac does not manage unless the program is one of its titleless applications | the windows have no title here too; whether komorebi for Windows leaves an untitled window alone is what [`PROBE_VARIABLE`] finds out on a real machine |
//!
//! A window's update loop calls [`Chrome::tick`], which does the part that needs doing again and
//! again on Windows: windows are created after the last call (the viewer opened from the recorder,
//! a dialog), so the request to be left out of captures is repeated. On macOS it does nothing.
//!
use crate::komorebi_link;
use std::time::Duration;
use std::time::Instant;
/// How often the windows are asked to be excluded again: a window created after the last time (the
/// viewer opened from the recorder, a dialog) is caught by the next.
const TICK: Duration = Duration::from_secs(1);
/// How long after the first tick komorebi is asked about this program's windows, so that they
/// have been shown and komorebi has had its chance to act on them.
const PROBE_AFTER: Duration = Duration::from_secs(3);
/// The environment variable that makes a window ask komorebi about itself.
///
/// With `KOMOREBI_RECORDER_PROBE_WINDOW` set (to any value, `1` by convention), a window asks
/// komorebi whether it would manage it, three seconds after [`Chrome`] first ticks, and writes the
/// answer to `komorebi-recorder-window-probe.txt` in the temp directory: how to find out on a
/// real machine whether the window is left alone, and what komorebi says if not. On a host that
/// has no such windows the file says so.
pub const PROBE_VARIABLE: &str = "KOMOREBI_RECORDER_PROBE_WINDOW";
/// Per-window housekeeping for a window's update loop. Call [`tick`](Chrome::tick) on every frame:
/// it is cheap, and does something about once a second.
///
/// A `Chrome` has no automated test: what it does is act on the windows of the running process.
/// On Windows it is checked by running the recorder (see `docs/dev/windows-checkpoints.md`).
pub struct Chrome {
last: Instant,
began: Instant,
probed: bool,
}
impl Default for Chrome {
fn default() -> Self {
let now = Instant::now();
Self {
// due at once
last: now.checked_sub(TICK).unwrap_or(now),
began: now,
probed: false,
}
}
}
impl Chrome {
/// Does what is due, if anything: at most once a second, and the first call at once.
///
/// On Windows each of the process's visible top-level windows is asked to be left out of
/// screen captures, which a window created since the last tick needs. A Windows too old for
/// it (before Windows 10 version 2004) refuses, and that is not reported here; `doctor` says
/// so. If [`PROBE_VARIABLE`] is set, the first tick at least three seconds after the `Chrome`
/// was created also asks komorebi about the process's windows, once, and writes the answer to
/// `komorebi-recorder-window-probe.txt` in the temp directory. On other hosts only the probe
/// does anything, and it writes that this program has no windows komorebi could know.
pub fn tick(&mut self) {
if self.last.elapsed() < TICK {
return;
}
self.last = Instant::now();
// an older Windows cannot do this, which is not worth interrupting anyone for; `doctor`
// says so
#[cfg(windows)]
let _ = super::win::window::exclude_from_capture();
if !self.probed && self.began.elapsed() >= PROBE_AFTER {
self.probed = true;
if std::env::var_os(PROBE_VARIABLE).is_some() {
probe();
}
}
}
}
/// Ask komorebi about this program's windows and write what it says down.
fn probe() {
#[cfg(windows)]
let handles = super::win::window::own_window_handles();
#[cfg(not(windows))]
let handles: Vec<u32> = Vec::new();
let mut text = String::new();
if handles.is_empty() {
text.push_str("this program has no visible windows of its own that komorebi could know\n");
}
for hwnd in handles {
text.push_str(&format!("window {hwnd}:\n"));
match komorebi_link::send_query(&komorebi_link::Message::DebugWindow(hwnd)) {
Ok(reply) if reply.trim().is_empty() => {
text.push_str(" komorebi gave no answer (busy, paused, or no such window)\n");
}
Ok(reply) => {
text.push_str(" komorebi says:\n");
text.push_str(&reply);
text.push('\n');
}
Err(error) => text.push_str(&format!(" could not ask komorebi: {error}\n")),
}
}
let _ = std::fs::write(
std::env::temp_dir().join("komorebi-recorder-window-probe.txt"),
text,
);
}
+5
View File
@@ -88,6 +88,9 @@
<Component Id='binary0' Guid='*'>
<File Id='exe0' Name='komorebi-recorder.exe' DiskId='1' Source='$(var.CargoTargetBinDir)\komorebi-recorder.exe' KeyPath='yes' />
</Component>
<Component Id='binary1' Guid='*'>
<File Id='exe1' Name='komorebi-recorder-gui.exe' DiskId='1' Source='$(var.CargoTargetBinDir)\komorebi-recorder-gui.exe' KeyPath='yes' />
</Component>
</Directory>
</Directory>
</Directory>
@@ -98,6 +101,8 @@
<ComponentRef Id='binary0' />
<ComponentRef Id='binary1' />
<Feature Id='Environment' Title='PATH Environment Variable' Description='Add the install location of the [ProductName] executable to the PATH system environment variable. This allows the [ProductName] executable to be called from any location.' Level='1' Absent='allow'>
<ComponentRef Id='Path' />
</Feature>