Files
dotfiles/common/swayimg/init.lua
T
connor a2dc43d665 Standardise across machines; add genuinely-customised app config
Two passes, both aimed at a consistent experience rather than a faithful
snapshot of each machine's accidents.

Standardisation. Audited every host-layer config present on more than one
machine and asked whether the difference was intent or drift:
  - mpv was byte-identical; swayimg differed only because system76 still
    had the shipped default and the work laptop had the real config; bob
    differed by one setting the work laptop was simply missing.
  - user-dirs.dirs disagreed with BOTH machines and with zshenv, which has
    said $HOME/downloads all along. Standardised on that.
  - mimeapps.list is now the union of both machines' associations.
  - swaync's config and style are shared; only wallust's generated
    colors.css stays per host, alongside hypr's and waybar's.
All of the above moved to common/.

Dropped as pure state rather than config: gtk-2.0 (file-chooser geometry),
pavucontrol.ini (window size), zoom.conf (a per-install random_key) and
zoomus.conf (panel widths). gtk-3.0 stays per host — its bookmarks encode
the two different home directories.

App config. GIMP, inkscape, FreeCAD, cura, OrcaSlicer, LightBurn and OBS
all hold real settings, so a curated subset of each is now tracked:
settings, keybindings and user content, but not session state, tool
options, device lists or window geometry. kicad is skipped — both library
tables hold a single entry, i.e. untouched defaults.

Content lives once in common/ even when only one machine has the app; the
host configs decide who gets the link. That is the distinction that lets
53% of link sources be shared while the NAS still does not get GIMP.

Two exclusions on credential grounds: obs-studio/plugin_config holds a
websocket server_password, and gh is dropped entirely because `gh auth
login` writes a token into hosts.yml — now also blocked by name.
2026-09-14 15:05:30 -04:00

149 lines
6.5 KiB
Lua

-- General config
swayimg.set_mode("viewer") -- mode at startup
swayimg.enable_antialiasing(true) -- anti-aliasing
swayimg.enable_decoration(true) -- window title/buttons/borders
swayimg.enable_overlay(false) -- window overlay mode
swayimg.enable_exif_orientation(true) -- image orientation by EXIF
swayimg.set_dnd_button("MouseRight") -- drag-and-drop mouse button
-- Image list configuration
swayimg.imagelist.set_order("numeric") -- list order
swayimg.imagelist.enable_reverse(false) -- reverse order
swayimg.imagelist.enable_recursive(false) -- recursive directory reading
swayimg.imagelist.enable_adjacent(false) -- add adjacent files from same dir
swayimg.imagelist.enable_fsmon(true) -- enable file system monitoring
-- Text overlay configuration
swayimg.text.set_font("FiraCode Nerd Font") -- font name
swayimg.text.set_size(12) -- font size in pixels
swayimg.text.set_spacing(0) -- line spacing
swayimg.text.set_padding(10) -- padding from window edge
swayimg.text.set_foreground(0xffcccccc) -- foreground text color
swayimg.text.set_background(0x00000000) -- text background color
swayimg.text.set_shadow(0x0d000000) -- text shadow color
swayimg.text.set_timeout(5) -- layer hide timeout
swayimg.text.set_status_timeout(3) -- status message hide timeout
-- Image viewer mode
swayimg.viewer.set_default_scale("optimal") -- default image scale
swayimg.viewer.set_default_position("center") -- default image position
swayimg.viewer.set_drag_button("MouseLeft") -- mouse button to drag image
swayimg.viewer.set_window_background(0xff000000) -- window background color
swayimg.viewer.set_image_chessboard(20, 0xff333333, 0xff4c4c4c) -- chessboard
swayimg.viewer.enable_centering(true) -- enable automatic centering
swayimg.viewer.enable_loop(true) -- enable image list loop mode
swayimg.viewer.limit_preload(1) -- number of images to preload
swayimg.viewer.limit_history(1) -- number of the history cache
swayimg.viewer.set_mark_color(0xff808080) -- mark icon color
swayimg.viewer.set_pinch_factor(1.0) -- pinch gesture factor
swayimg.viewer.set_text("topleft", { -- top left text block scheme
"File: {name}",
"Format: {format}",
"File size: {sizehr}",
"File time: {time}",
"EXIF date: {meta.Exif.Photo.DateTimeOriginal}",
"EXIF camera: {meta.Exif.Image.Model}"
})
swayimg.viewer.set_text("topright", { -- top right text block scheme
"Image: {list.index} of {list.total}",
"Frame: {frame.index} of {frame.total}",
"Size: {frame.width}x{frame.height}"
})
swayimg.viewer.set_text("bottomleft", { -- bottom left text block scheme
"Scale: {scale}"
})
-- Key and mouse bindings in viewer mode (example only, not all):
-- bind Escape key for exit
swayimg.viewer.on_key("Escape", function()
swayimg.exit()
end)
swayimg.viewer.on_key("q", function()
swayimg.exit()
end)
swayimg.viewer.on_key("h", function()
swayimg.viewer.switch_image("prev")
end)
swayimg.viewer.on_key("l", function()
swayimg.viewer.switch_image("next")
end)
-- bind mouse vertical scroll button with pressed Ctrl to zoom in the image at mouse pointer coordinates
swayimg.viewer.on_mouse("Ctrl-ScrollUp", function()
local pos = swayimg.get_mouse_pos()
local scale = swayimg.viewer.get_scale()
scale = scale + scale / 10
swayimg.viewer.set_abs_scale(scale, pos.x, pos.y);
end)
-- Slide show mode, same config as for viewer mode with the following defaults:
swayimg.slideshow.set_timeout(5) -- timeout to switch image
swayimg.slideshow.set_default_scale("fit") -- default image scale
swayimg.slideshow.set_window_background("auto") -- window background mode
swayimg.slideshow.limit_history(0) -- number of the history cache
swayimg.slideshow.set_text("topleft", { "{name}" }) -- top left text block scheme
-- Gallery mode
swayimg.gallery.set_aspect("fill") -- thumbnail aspect ratio
swayimg.gallery.set_thumb_size(200) -- thumbnail size in pixels
swayimg.gallery.set_padding_size(5) -- padding between thumbnails
swayimg.gallery.set_border_size(5) -- border size for selected thumbnail
swayimg.gallery.set_border_color(0xffaaaaaa) -- border color for selected thumbnail
swayimg.gallery.set_selected_scale(1.15) -- scale for selected thumbnail
swayimg.gallery.set_selected_color(0xff404040) -- background color for selected thumbnail
swayimg.gallery.set_unselected_color(0xff202020) -- background color for unselected thumbnail
swayimg.gallery.set_window_color(0xff000000) -- window background color
swayimg.gallery.set_pinch_factor(100.0) -- pinch gesture factor
swayimg.gallery.enable_hover(true) -- enable mouse following
swayimg.gallery.limit_cache(100) -- number of thumbnails stored in memory
swayimg.gallery.enable_embedded_thumb(true) -- use embedded thumbnails
swayimg.gallery.enable_preload(false) -- preloading invisible thumbnails
swayimg.gallery.enable_pstore(false) -- enable persistent storage for thumbnails
swayimg.gallery.set_text("topleft", { -- top left text block scheme
"File: {name}"
})
swayimg.gallery.set_text("topright", { -- top right text block scheme
"{list.index} of {list.total}"
})
-- Key and mouse bindings in gallery mode (example only, not all):
-- bind Enter key to open image in viewer
swayimg.gallery.on_key("Return", function()
swayimg.set_mode("viewer")
end)
--
-- Other configuration examples
--
-- force set scale mode on window resize (useful for tiling compositors)
swayimg.on_window_resize(function()
swayimg.viewer.set_fix_scale("optimal")
end)
-- bind the Delete key in slide show mode to delete the current file and display a status message
swayimg.slideshow.on_key("Delete", function()
local image = swayimg.slideshow.get_image()
os.remove(image.path)
swayimg.text.set_status("File "..image.path.." removed")
end)
-- set a custom window title in gallery mode
swayimg.gallery.on_image_change(function()
local image = swayimg.gallery.get_image()
swayimg.set_title("Gallery: "..image.path)
end)
-- print paths to all marked files by pressing Ctrl-p in gallery mode
swayimg.gallery.on_key("Ctrl-p", function()
local entries = swayimg.imagelist.get()
for _, entry in ipairs(entries) do
if entry.mark then
print(entry.path)
end
end
end)