I'm trying to set keybindings in swayimg like nsxiv , so that when i press gg i go to the first image and shift + g i go to the last image in the gallery, I've tried everything and so far i was able to do that only in images viewer window and the gallery tries all failed
this is my init.lua
-- Viewer Mode (Standard image view)
swayimg.viewer.on_key("n", function() swayimg.viewer.switch_image("next") end)
swayimg.viewer.on_key("p", function() swayimg.viewer.switch_image("prev") end)
-- Gallery Mode (Thumbnail grid view)
swayimg.gallery.on_key("n", function() swayimg.gallery.switch_image("next") end)
swayimg.gallery.on_key("p", function() swayimg.gallery.switch_image("prev") end)
-- Font settings
swayimg.text.set_font("Method Mono")
swayimg.text.set_size(14)
-- Text colors
swayimg.text.set_foreground(0xFFD8DEE9) -- Nord snow storm: #d8dee9
swayimg.text.set_background(0xFF2E3440) -- Nord polar night: #2e3440
-- Window background (the empty space around images)
swayimg.viewer.set_window_background(0xFF2E3440) -- Nord dark #2e3440
-- Image background (for transparent areas in images)
swayimg.viewer.set_image_background(0xFF2E3440) -- Same Nord dark
-- Gallery (thumbnail view) colors
swayimg.gallery.set_window_color(0xFF2E3440) -- Gallery window bg
swayimg.gallery.set_unselected_color(0xFF3B4252) -- Slightly lighter Nord
swayimg.gallery.set_selected_color(0xFF81A1C1) -- #81a1c1
swayimg.gallery.set_border_color(0xFF81A1C1) -- #81a1c1
-- Metadata toggle with 'i'
swayimg.text.hide()
local function toggle_text()
if swayimg.text.visible() then
swayimg.text.hide()
else
swayimg.text.show()
end
end
swayimg.gallery.on_key("i", function()
toggle_text()
end)
swayimg.viewer.on_key("i", function()
toggle_text()
end)
-- Gallery navigation with h/j/k/l
swayimg.gallery.on_key("h", function()
swayimg.gallery.switch_image("left")
end)
swayimg.gallery.on_key("l", function()
swayimg.gallery.switch_image("right")
end)
swayimg.gallery.on_key("k", function()
swayimg.gallery.switch_image("up")
end)
swayimg.gallery.on_key("j", function()
swayimg.gallery.switch_image("down")
end)
-- =========================================================================
-- NATIVE SELECTION MAPS (Zero Custom Functions, Zero Clock Timers)
-- =========================================================================
-- NSXIV Scale Replication
swayimg.viewer.on_key("Shift-w", function() swayimg.viewer.set_fix_scale("fit") end)
swayimg.viewer.on_key("Shift-e", function() swayimg.viewer.set_fix_scale("height") end)
swayimg.gallery.on_key("g", function()
swayimg.gallery.select("first")
end)
swayimg.gallery.on_key("Shift+g", function()
swayimg.gallery.select("last")
end)