Difference between revisions of "Sxiv"

From ArchWiki
Jump to navigation Jump to search
(+external links)
(Page cleanup: Added summary, added installation help, added proper templates)
Line 3: Line 3:
 
{{i18n|sxiv}}
 
{{i18n|sxiv}}
 
{{Article summary start}}
 
{{Article summary start}}
{{Article summary text|sxiv is a lightweight image viewer that is scriptable}}
+
{{Article summary text|This article discusses the installation and basic configuration of {{Pkg|sxiv}}.}}
 +
{{Article summary heading|External Links}}
 +
{{Article summary text| [http://github.com/muennich/sxiv sxiv on github]}}
 
{{Article summary end}}
 
{{Article summary end}}
  
sxiv is a lightweight image viewer written in C.
+
'''sxiv''', Simple [[X]] Image Viewer is a lightweight image viewer written in C. It is a lightweight image viewer that is scriptable.
 +
 
 +
== Installation ==
 +
 
 +
{{Pkg|sxiv}} can be found in the Community repositories.
  
 
== Assigning keyboard shortcuts to sxiv ==
 
== Assigning keyboard shortcuts to sxiv ==
Line 12: Line 18:
 
sxiv is scriptable, but to do this, you have to edit config.h and compile sxiv as follows:
 
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 ^d: "mv file ~/.trash", and "echo file | xclip" to put the full path and filename of the current image into the clipboard with ^c.
+
As an example we will assign the following command to {{Keypress|^d}}: {{ic|mv file ~/.trash}}, and {{ic|echo file | xclip}} to put the full path and filename of the current image into the clipboard with {{Keypress|^c}}.
  
 
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.
 
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.
  
How to make this work:
+
=== Tutorial ===
  
get latest PKGBUILD from abs:
+
Get latest PKGBUILD from abs
 
  # abs community/sxiv
 
  # abs community/sxiv
 
(notice how the prompt above is a root prompt denoted by a pound-sign (#), so you may have to use sudo for example)
 
(notice how the prompt above is a root prompt denoted by a pound-sign (#), so you may have to use sudo for example)
Line 29: Line 35:
  
 
enable scripting in config.h by adding the following after #ifdef _FEATURE_CONFIG:
 
enable scripting in config.h by adding the following after #ifdef _FEATURE_CONFIG:
<pre>/* enable external commands (defined below)? 0=off, 1=on: */
+
/* enable external commands (defined below)? 0=off, 1=on: */
#define EXT_COMMANDS 1
+
#define EXT_COMMANDS 1
</pre>
 
  
 
edit config.h, to add the line for the "d" and "c" shortcut:
 
edit config.h, to add the line for the "d" and "c" shortcut:
<pre>       /* run shell command line on current file ("$SXIV_IMG"): */
+
{{Hc|head=config.h|output=<nowiki>
 +
        /* run shell command line on current file ("$SXIV_IMG"): */
 
         { true,  XK_less,          it_shell_cmd,        (arg_t) \
 
         { true,  XK_less,          it_shell_cmd,        (arg_t) \
 
                         "mogrify -rotate -90 \"$SXIV_IMG\"" },
 
                         "mogrify -rotate -90 \"$SXIV_IMG\"" },
Line 48: Line 54:
 
         { true,  XK_c,            it_shell_cmd,        (arg_t) \
 
         { true,  XK_c,            it_shell_cmd,        (arg_t) \
 
                         "echo \"$SXIV_IMG\" | xclip" },
 
                         "echo \"$SXIV_IMG\" | xclip" },
};</pre>
+
};</nowiki>}}
  
 
After saving config.h, create new checksums for modified files (config.h in this case):
 
After saving config.h, create new checksums for modified files (config.h in this case):
Line 65: Line 71:
 
  $ sxiv -tsr ~/pictures
 
  $ sxiv -tsr ~/pictures
  
you can delete selected pictures by hitting "CTRL+d". This will move your selected pic to ~/.trash.
+
{{Box GREEN|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.}}
 
 
Pressing "CTRL+c" copies the full path and file name of the current picture to the clipboard.
 
 
 
==External links==
 
* https://github.com/muennich/sxiv
 

Revision as of 21:11, 8 June 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Template:Article summary start Template:Article summary text 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

sxiv can be found in the Community 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

(notice how 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

enable scripting in config.h by adding the following after #ifdef _FEATURE_CONFIG:

/* enable external commands (defined below)? 0=off, 1=on: */
#define EXT_COMMANDS 1

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.