From ArchWiki
Revision as of 06:42, 6 October 2013 by Flu (Talk | contribs) (Capital letters, format.)

Jump to: navigation, search

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary heading Template:Article summary text Template:Article summary end

sxiv, Simple X Image Viewer is a lightweight and scriptable image viewer written in C.


Install sxiv, which is available in the official repositories.

Assigning keyboard shortcuts to sxiv

sxiv is scriptable, but to do this, you have to edit config.h and compile sxiv as follows. See ABS for details on customizing official packages.

In this example, the following command to Ctrl+d: mv file ~/.trash, and echo -n file to put the full path and filename of the current image into the clipboard with CTRL+c, and nitrogen --save --set-zoom-fill file to set the current image as wallpaper with CTRL+w

So when sxiv is started in thumbnail mode on a folder, one can see all files in that folder, select random thumbnails, and hit CTRL+d to move them to a custom "trash" folder.

Edit config.h, to add the line for the d and c shortcut:

        /* run shell command line on current file ("$SXIV_IMG"): */
        { true,   XK_less,          it_shell_cmd,         (arg_t) \
                        "mogrify -rotate -90 \"$SXIV_IMG\"" },
        { true,   XK_greater,       it_shell_cmd,         (arg_t) \
                        "mogrify -rotate +90 \"$SXIV_IMG\"" },
        { true,   XK_comma,         it_shell_cmd,         (arg_t) \
                        "jpegtran -rotate 270 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" },
        { true,   XK_period,        it_shell_cmd,         (arg_t) \
                        "jpegtran -rotate  90 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" },
//insert the lines below
        { true,   XK_d,             it_shell_cmd,         (arg_t) \
                        "mv \"$SXIV_IMG\" ~/.trash" },
        { true,   XK_c,             it_shell_cmd,         (arg_t) \
                        "echo -n \"$SXIV_IMG\" | xclip" },
        { true,   XK_w,             it_shell_cmd,         (arg_t) \
                        "nitrogen --save --set-wallpaper \"$SXIV_IMG\"" },

Create .trash folder if it doesn't exist:

$ mkdir ~/.trash

Now when you start sxiv in thumbnail mode on a folder of pictures, i.e.:

$ sxiv -tsr ~/pictures

You can now delete selected pictures by hitting Ctrl+d. This will move your selected pic to ~/.trash. Pressing Ctrl+c copies the full path and file name of the current picture to the clipboard. Pressing Ctrl+w will make the set the picture as wallpaper using Nitrogen.

Tips and tricks

Browse through images in directory after opening a single file

Place this script in $PATH and call it like this:

$ scriptname a_single_image.jpg

As indicated in the comments of the script, it may be used to have this behavior when opening images from within ranger.

Creating a desktop entry

Using a desktop environment some users may prefer to have sxiv listed in the start menu or list of installed programs. This can be done easily by creating the following ~/.local/share/applications/sxiv.desktop file:

[Desktop Entry]
Comment=A Simple X Image Viewer
Exec=sxiv %f

As for the icon, you can for example take this image and place it in ~.local/share/icons/hicolor/<size>/apps/sxiv.png

See also