artemsen / swayimg

Image viewer for Wayland
MIT License
380 stars 31 forks source link

How to get full path of the image #204

Closed luravoid closed 1 month ago

luravoid commented 1 month ago

when i use exec notify-send % as a binding, it only prints the name of the file, not the full path

artemsen commented 1 month ago

% is not a full path, but the path you specify when run swayimg, so: swayimg /full/path/to/image -> % is /full/path/to/image swayimg realtive/path/to/image -> % is relative/path/to/image swayimg image -> % is image

luravoid commented 1 month ago

Is there a way to get the full path of an image when I'm in its directory?

I want to be able to:

cd ~/Pictures/Backgrounds && swayimg

and then print the full path of the image instead of the relative path using a keybinding.

artemsen commented 1 month ago

You can use

swayimg ~/Pictures/Backgrounds
luravoid commented 1 month ago

The issue is that I run swayimg from a keybinding in yazi, and it automatically takes me to the directory of the images when I run it.

programs.yazi.keymap = {
    manager.prepend_keymap = [
      {
        on = ["I"];
        run = "shell --confirm 'swayimg --gallery'";
        desc = "Preview all images in the current directory with swayimg";
      }

It would be nice to have an option to always be able to get the full path, regardless of the current directory.

artemsen commented 1 month ago

Just create a simple script swayimg_pwd:

#!/bin/sh
swayimg --gallery "$(pwd)"

and modify the yazi config

run = "shell --confirm swayimg_pwd";
luravoid commented 1 month ago

thanks, this solves my issue.