Difference between revisions of "Sxiv"

From ArchWiki
Jump to: navigation, search
(Added feh as related program)
(added script to browse through images in directory after opening a single file; altered installation note)
Line 13: Line 13:
 
== Installation ==
 
== Installation ==
  
{{Pkg|sxiv}} can be found in the Community repositories.
+
[[pacman|Install]] {{pkg|sxiv}}, which is available in the [[Official Repositories|official repositories]].
  
 
== Assigning keyboard shortcuts to sxiv ==
 
== Assigning keyboard shortcuts to sxiv ==
Line 70: Line 70:
 
Congratulations, you can now delete selected pictures by hitting {{Keypress|CTRL+D}}. This will move your selected pic to ~/.trash. Pressing {{Keypress|CTRL+C}} copies the full path and file name of the current picture to the clipboard.
 
Congratulations, you can now delete selected pictures by hitting {{Keypress|CTRL+D}}. This will move your selected pic to ~/.trash. Pressing {{Keypress|CTRL+C}} copies the full path and file name of the current picture to the clipboard.
  
==Web Resources==
+
==Tips and Tricks==
 +
===Browse through images in directory after opening a single file===
 +
Place [http://git.savannah.gnu.org/cgit/ranger.git/tree/doc/examples/rifle_sxiv.sh 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]].
 +
 
 +
==See also==
 
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=112643 forum thread].
 
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=112643 forum thread].

Revision as of 15:53, 17 May 2013

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 image viewer written in C. It is a lightweight image viewer that is scriptable.

Installation

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:

As an example we will assign the following command to Template:Keypress: mv file ~/.trash, and echo file to put the full path and filename of the current image into the clipboard with Template:Keypress.

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

Tutorial

Get latest PKGBUILD from abs

# abs community/sxiv
Note: The prompt above is a root prompt, denoted by a pound-sign (#), so you may have to use sudo, for example.

copy source to your own workspace:

$ cp -r /var/abs/community/sxiv ~/sources

move to source directory to start the work:

$ cd ~/sources/sxiv

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

config.h
        /* 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 \"$SXIV_IMG\" | xclip" },
};

After saving config.h, create new checksums for modified files (config.h in this case):

$ makepkg -g >> PKGBUILD

Extract the source files; you can just run makepkg to do it for you:

$ makepkg

Compile sxiv and install it:

$ makepkg -efi

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

Congratulations, you can now delete selected pictures by hitting Template:Keypress. This will move your selected pic to ~/.trash. Pressing Template:Keypress copies the full path and file name of the current picture to the clipboard.

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.

See also