How artemsen/swayimg works
Swayimg is a customizable image viewer for Wayland and DRM. Its principal workflow accepts file, pipe, or command output; maintains an image list; decodes supported image and preview formats; then displays content in viewer or gallery mode, with slideshow and animation support. Lua configuration exposes application controls, and Wayland/DRM provide output backends. The graph follows the visible application initialization and Lua configuration excerpts plus README capabilities; many format and rendering internals were not sampled, so those relationships are documented at subsystem level.
Main entry points: application.cpp Application loop · luaengine.cpp Lua engine · render.cpp Rendering · viewer.cpp Viewer mode
Components 18
Startup and events
- Command line
src/main.cpp - Application loop
src/application.cpp - File/event monitoring
src/fsmonitor.cpp
Image content
- Image list
src/imagelist.cpp - Image model
src/image.hpp - Format factory
src/formatfactory.cpp - Format decoders
src/formats - Font preview
src/font.cpp - Video storyboard
src/formats/video.cpp
Viewing modes
- Viewer mode
src/viewer.cpp - Gallery mode
src/gallery.cpp - Slideshow
src/slideshow.cpp
Presentation
- Rendering
src/render.cpp - Wayland output
src/ui_wayland.cpp - DRM output
src/ui_drm.cpp
Scripting
- Lua engine
src/luaengine.cpp - Lua bindings
src/external/luabridge/detail/Namespace.h
Other components
- Viewer user
Connections 24
- Viewer user → Command line: starts viewer
README.md - Command line → Application loop: starts app
- Application loop → Lua engine: initializes config
src/application.cpp - Application loop → File/event monitoring: initializes monitor
src/application.cpp - Application loop → Image list: initializes list
src/application.cpp - Application loop → Wayland output: selects backend
src/application.cpp - Application loop → DRM output: selects backend
- Image list → Image model: holds entries
- Format factory → Format decoders: dispatches decoding
- Format decoders → Image model: produces images
- Font preview → Image model: provides preview
- Video storyboard → Image model: provides storyboard
README.md - Application loop → Viewer mode: activates mode
src/application.cpp - Application loop → Gallery mode: initializes mode
src/application.cpp - Viewer mode → Rendering: renders content
- Gallery mode → Rendering: renders thumbnails
- Slideshow → Viewer mode: advances images
README.md - Rendering → Wayland output: draws output
- Rendering → DRM output: draws output
- Lua engine → Lua bindings: registers API
- Lua engine → Format factory: configures formats
src/luaengine.cpp - Lua engine → Image list: configures list
src/luaengine.cpp - Lua engine → Gallery mode: controls gallery
src/luaengine.cpp - Lua engine → Viewer mode: controls viewer
src/luaengine.cpp