sxiv

提供: ArchWiki
2015年2月16日 (月) 17:07時点におけるKusakata (トーク | 投稿記録)による版 (ページの作成:「Category:グラフィックとデスクトップパブリッシング en:Sxiv {{Lowercase title}} {{Related articles start}} {{Related|feh}} {{Related articles en...」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

関連記事

sxiv (Simple X Image Viewer) は C で書かれている軽量でスクリプト可能な画像ビューアです。

インストール

公式リポジトリsxivインストールしてください。

sxiv にキーボードショートカットを設定

sxiv supports external key events. First you have to press Ctrl-x to send the next key to the external key-handler. The external key-handler requires an executable file ~/.config/sxiv/exec/key-handler and passes the key combination pressed as well the name of the current image as arguments.

In this example, we will add the bindings Ctrl+d to execute mv filename ~/.trash, Ctrl+c to copy the current image's name to the clipboard with xclip, and Ctrl+w to set the current wallpaper with nitrogen.

~/.config/sxiv/exec/key-handler
#!/bin/sh

case "$1" in
"C-d")
        mv "$2" ~/.trash ;;
"C-r")
        convert -rotate 90 "$2" "$2" ;;
"C-c")
        echo -n "$2" | xclip -selection clipboard ;;
"C-w")
        nitrogen --save --set-zoom-fill "$2" ;;
esac

Be sure to mark the script as executable

$ chmod +x ~/.config/sxiv/exec/key-handler

Create .trash folder if it does not exist:

$ mkdir ~/.trash
ヒント: You may want to use a standards-compliant trashcan (like trash-cliAUR or bashtrashAUR) rather than mv "$2" ~/.trash.

Tips and tricks

ファイルを開いた後にディレクトリの画像をブラウズ

Place this script in /usr/local/bin and call it like this:

$ scriptname a_single_image.jpg

Alternatively you can also install the script as a package from the AUR: sxiv-rifleAUR.

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

ステータスバーに画像サイズを表示

Place the following executable script in ~/.config/sxiv/exec/image-info and make sure that you have the exiv2 package installed:

~/.config/sxiv/exec/image-info
#!/bin/sh

# Example for ~/.config/sxiv/exec/image-info
# Called by sxiv(1) whenever an image gets loaded,
# with the name of the image file as its first argument.
# The output is displayed in sxiv's status bar.

s=" | " # field separator

filename=$(basename "$1")
filesize=$(du -Hh "$1" | cut -f 1)

geometry=$(identify -format '%wx%h' "$1[0]")

tags=$(exiv2 -q pr -pi "$1" | awk '$1~"Keywords" { printf("%s,", $4); }')
tags=${tags%,}

echo "${filesize}${s}${geometry}${tags:+$s}${tags}${s}${filename}"

参照