artemsen / swayimg

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

bind multiple commands with `--config` #202

Open salahoued opened 1 month ago

salahoued commented 1 month ago

Hi, I want to write a script that allows me to browse a directory of images, and when on exit (pressing q) the current image is written to a file last_page.txt, and then exit. So when running the script again it read the file last_page.txt and pass it to swayimg that way it starts up at the last page/image.

last_page=~/last_page_sway.txt
curr_page="$(cat $last_page)"

swayimg \
    -p 0,0 \
    --config='keys.viewer.q=exec echo "%" > ~/last_page_sway.txt; exit' \
    $curr_page

The issue is, when pressing q, the current_file is not written to last_page.txt and it just exits

I have commented out the q keybind in the config file for both the viewer and gallery.

artemsen commented 1 month ago

There is a problem handling the exit action. This action has high priority and terminates the program before any other actions are performed. I don't know how to fix it without breaking everything else, sorry =)

salahoued commented 1 month ago

No, there is no problem. It's just that I'm used to it CTRL+q: for a Kivy app I did, and q for imv.

I can, just add a keybind s for example to save then q to exit.

But most of all I thank you for this work

litoj commented 2 weeks ago

I have a similar issue of keybindings not getting overriden, only appended. When I have Shift+s=scale fit it toggles the slideshow (because that is the default binding) and also executes my binding. I don't remember this happening in the previous version though (now on 3.4)

Edit: I noticed the scale action is not yet in 3.4, that's why it started the slideshow - because it ignored the invalid mapping. If there could pop up a message with the invalid binding that would be very useful.

artemsen commented 2 weeks ago

When I have Shift+s=scale fit it toggles the slideshow

It was #203, fixed in master.