Go to file
NRK 2093f36661 make thumbnail caching safer against concurrent writes
by writing to a tmpfile first, and then renaming it to the desired
target - multiple nsxiv instances writing thumbnail at the same time are
guaranteed not to stomp over one another.

rename() is guaranteed to be atomic by POSIX. however, it can fail with
EXDEV if both the files don't reside in the same filesystem. and so we
cannot make the tmpfile something like "/tmp/nsxiv-XXXXXX".

instead, create the tmpfile inside the cache_dir to reduce chances of
EXDEV occuring.
2023-10-01 17:02:35 +06:00
.github/workflows various README nits (#470) 2023-08-31 18:06:43 +00:00
etc various README nits (#470) 2023-08-31 18:06:43 +00:00
icon Embed new nsxiv icon (#163) 2021-11-13 17:43:15 +00:00
.editorconfig editorconfig: only apply to .c and .h files (#433) 2023-04-10 17:13:44 +00:00
.gitignore Embed new nsxiv icon (#163) 2021-11-13 17:43:15 +00:00
autoreload.c apply clang-format 2023-03-11 18:37:04 +06:00
commands.c centralize script handling logic (#477) 2023-09-30 08:53:32 +00:00
commands.h add a pick quit keybind (#432) 2023-04-14 19:45:39 +00:00
config.def.h config.h: allow all values to be NULL 2023-06-23 22:10:27 +06:00
config.mk config.mk: do not explicitly set CC (#455) 2023-07-16 18:16:23 +00:00
image.c centralize script handling logic (#477) 2023-09-30 08:53:32 +00:00
LICENSE Added LICENSE 2011-01-18 15:29:18 +01:00
main.c centralize script handling logic (#477) 2023-09-30 08:53:32 +00:00
Makefile add support for long-opts (#332) 2022-08-16 10:43:50 +02:00
nsxiv.h centralize script handling logic (#477) 2023-09-30 08:53:32 +00:00
options.c add compiled features into --version output (#462) 2023-07-08 06:53:57 +00:00
optparse.h add support for long-opts (#332) 2022-08-16 10:43:50 +02:00
README.md various README nits (#470) 2023-08-31 18:06:43 +00:00
thumbs.c make thumbnail caching safer against concurrent writes 2023-10-01 17:02:35 +06:00
utf8.h code-style: general cleanups (#137) 2021-10-29 02:00:53 +06:00
util.c apply clang-format 2023-03-11 18:37:04 +06:00
window.c config.h: allow all values to be NULL 2023-06-23 22:10:27 +06:00

nsxiv

Codeberg tags license loc

Neo (or New or Not) Simple (or Small or Suckless) X Image Viewer

nsxiv is a fork of the now-unmaintained sxiv with the purpose of being a (mostly) drop-in replacement for sxiv, maintaining its interface and adding simple, sensible features. nsxiv is free software licensed under GPL-2.0-or-later and aims to be easy to modify and customize.

Please file a bug report if something does not work as documented or expected on Codeberg after making sure you are using the latest release. Contributions are welcome, see CONTRIBUTING to get started.

Features

  • Basic image operations like zooming, panning, rotating
  • Basic support for animated/multi-frame images
  • Thumbnail mode: grid of selectable previews of all images
  • Ability to cache thumbnails for fast re-loading
  • Automatically refreshing modified images
  • Customizable keyboard and mouse mappings via config.h
  • Scriptability via key-handler
  • Displaying image information in status bar via image-info & thumb-info
  • Customizable window title via win-title

Screenshots

Image mode with default colors:

Image

Thumbnail mode with custom colors:

Thumb

Installing via package manager

nsxiv is available on the following distributions/repositories. If you don't see your distro listed here, either contact your distro's package maintainer or consider packaging it yourself and adding it to the respective community repo.

Dependencies

nsxiv requires the following software to be installed:

  • X11
  • Imlib2 (built with X11 support)

The following dependencies are optional:

  • inotify*: Used for auto-reloading images on change. Disabled via HAVE_INOTIFY=0.
  • libXft, freetype2, fontconfig: Used for the status bar. Disabled via HAVE_LIBFONTS=0.
  • libexif: Used for auto-orientation and exif thumbnails. Disable via HAVE_LIBEXIF=0.

The following dependencies are only used if your imlib2 version is lower than v1.8.0. If your imlib2 version is v1.8.0 (or above) then the following dependencies are unused and won't be built (even if you enable it explicitly).

  • giflib: Used for animated gif playback. Disabled via HAVE_LIBGIF=0.
  • libwebp: Used for animated webp playback. (NOTE: animated webp also requires Imlib2 v1.7.5 or above) Disabled via HAVE_LIBWEBP=0.

Please make sure to install the corresponding development packages in case that you want to build nsxiv on a distribution with separate runtime and development packages (e.g. *-dev on Debian).

* inotify is a Linux-specific API for monitoring filesystem changes. It's not natively available on *BSD systems but can be enabed via installing and linking against libinotify-kqueue.

Building

nsxiv is built using the commands:

$ make

You can pass HAVE_X=0 to make to disable an optional dependency. For example:

$ make HAVE_LIBEXIF=0

will disable libexif support. Alternatively they can be disabled via editing config.mk. OPT_DEP_DEFAULT=0 can be used to disable all optional dependencies.

Installing nsxiv:

# make install

Installing desktop entry:

# make install-desktop

Installing icons:

# make install-icon

Installing all of the above:

# make install-all

Please note, that these requires root privileges. By default, nsxiv is installed using the prefix /usr/local, so the full path of the executable will be /usr/local/bin/nsxiv, the .desktop entry will be /usr/local/share/applications/nsxiv.desktop and the icon path will be /usr/local/share/icons/hicolor/{size}/apps/nsxiv.png.

You can install nsxiv into a directory of your choice by changing this command to:

$ make PREFIX="/your/dir" install

Example scripts are installed using EGPREFIX which defaults to /usr/local/share/doc/nsxiv/examples. You can change EGPREFIX the same way you can change PREFIX shown above.

The build-time specific settings of nsxiv can be found in the file config.h. Please check and change them, so that they fit your needs. If the file config.h does not already exist, then you have to create it with the following command:

$ make config.h

Usage

Refer to the man-page for the documentation:

$ man nsxiv

You may also view the man-page online. However, note that the online man-page might not accurately represent your local copy.

F.A.Q.

  • Can I open remote urls with nsxiv?
    Yes, see nsxiv-url

  • Can I open all the images in a directory?
    Yes, see nsxiv-rifle

  • Can I set default arguments for nsxiv?
    Yes, see nsxiv-env

  • Can I pipe images into nsxiv?
    Yes, see nsxiv-pipe

You may also wish to see the known issues.

Customization

The main method of customizing nsxiv is by setting values for the variables in config.h, or by using Xresources as explained in the manual. If these options are not sufficient, you may implement your own features by following this guide.

Due to our limited project scope, certain features or customization cannot be merged into nsxiv mainline. Following the spirit of suckless software, we host the nsxiv-extra repo where users are free to submit whatever patches or scripts they wish.

If you think your custom features can be beneficial for the general user base and is within our project scope, please submit it as a pull request on this repository, then we may merge it to mainline.

Description on how to use or submit patches can be found on nsxiv-extra's README.

Download

You can browse the source code repository on Codeberg or get a copy using git with the following command:

$ git clone https://codeberg.org/nsxiv/nsxiv.git

You can view the changelog here

Similar projects

If nsxiv isn't able to fit your needs, check out the image viewer section of suckless rocks to find other minimal image viewers to try out.

Below are a couple other lesser known projects not listed in suckless rocks.

  • MAGE: A smaller/more-suckless version of sxiv.
  • div: Minimal and extensive, aimed at C devs willing to build their own features.
  • mpv-image-viewer: Lua script to turn mpv into an image viewer. Supports thumbnails via mpv-gallery-view.