Krolyxon
Commit bda7086

Branches

Refs →

nsxivexampleswin-title

27 lines · 865 B · Bourne Again Shell (bash)

1#!/bin/sh
2
3# Example for $XDG_CONFIG_HOME/nsxiv/exec/win-title
4# Called by nsxiv(1) on each redraw.
5# The output is set as nsxiv's window title.
6#
7# Arguments, "Optional" arguments might be empty:
8# $1: resolved absolute path of the current file
9# $2: current file number
10# $3: total file number
11# $4: image width (Optional: Disabled on thumbnails mode)
12# $5: image height (Optional: Disabled on thumbnails mode)
13# $6: current zoom (Optional: Disabled on thumbnails mode)
14#
15# The term file is used rather than image as nsxiv does not
16# precheck that the input files are valid images. Total file
17# count may be different from the actual count of valid images.
18
19exec 2>/dev/null
20
21filename="${1##*/}"
22
23if [ -n "$4" ]; then # image mode
24 printf "%s" "nsxiv - ${filename} | ${4}x${5} ${6}% [${2}/${3}]"
25else
26 printf "%s" "nsxiv - ${filename} [${2}/${3}]"
27fi