https://wiki.archlinux.org/api.php?action=feedcontributions&user=Shmibs&feedformat=atomArchWiki - User contributions [en]2024-03-29T08:03:11ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Sxiv&diff=390874Sxiv2015-08-11T20:25:38Z<p>Shmibs: </p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Graphics and desktop publishing]]<br />
[[ja:Sxiv]]<br />
{{Related articles start}}<br />
{{Related|feh}}<br />
{{Related articles end}}<br />
<br />
[http://github.com/muennich/sxiv sxiv] , Simple [[X]] Image Viewer is a lightweight and scriptable image viewer written in C. <br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] {{Pkg|sxiv}}, which is available in the [[official repositories]].<br />
<br />
== Assigning keyboard shortcuts to sxiv ==<br />
sxiv supports external key events. First you have to press {{ic|Ctrl-x}} to send the next key to the external key-handler. The external key-handler requires an executable file {{ic|~/.config/sxiv/exec/key-handler}} and passes the key combination pressed via argument as well the names of the currently marked images as stdin (or, if none are marked, the currently selected image).<br />
<br />
In this example, we will add the bindings {{ic|Ctrl+d}} to execute {{ic|mv ''filename'' ~/.trash}}, {{ic|Ctrl+c}} to copy the current images' names to the clipboard with {{Pkg|xclip}}, and {{ic|Ctrl+w}} to set the current wallpaper with [[nitrogen]]. Obviously, some commands may only make sense with a single image as an argument, so you may want to revise this to handle cases when those are passed more than one.<br />
<br />
{{hc|~/.config/sxiv/exec/key-handler|<nowiki><br />
#!/bin/sh<br />
while read file<br />
do<br />
case "$1" in<br />
"C-d")<br />
mv "$file" ~/.trash ;;<br />
"C-r")<br />
convert -rotate 90 "$file" "$file" ;;<br />
"C-c")<br />
echo -n "$file" | xclip -selection clipboard ;;<br />
"C-w")<br />
nitrogen --save --set-zoom-fill "$file" ;;<br />
esac<br />
done<br />
</nowiki>}}<br />
<br />
Be sure to mark the script as executable<br />
$ chmod +x ~/.config/sxiv/exec/key-handler<br />
<br />
Create {{ic|.trash}} folder if it does not exist:<br />
$ mkdir ~/.trash<br />
<br />
{{Tip|You may want to use a [http://freedesktop.org/wiki/Specifications/trash-spec/ standards-compliant trashcan] (like {{AUR|trash-cli}} or {{AUR|bashtrash}}) rather than {{ic|mv "$2" ~/.trash}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Browse through images in directory after opening a single file ===<br />
<br />
Place [http://git.savannah.gnu.org/cgit/ranger.git/tree/doc/examples/rifle_sxiv.sh this script] in {{ic|/usr/local/bin}} and call it like this:<br />
$ ''scriptname'' a_single_image.jpg<br />
<br />
Alternatively you can also install the script as a package from the AUR: {{AUR|sxiv-rifle}}. <br />
<br />
As indicated in the comments of the script, it may be used to have this behavior when opening images from within [[ranger]].<br />
<br />
=== Showing the image size in the status bar ===<br />
<br />
Place the following executable script in {{ic|~/.config/sxiv/exec/image-info}} and make sure that you have the {{Pkg|exiv2}} package installed:<br />
<br />
{{hc|~/.config/sxiv/exec/image-info|<nowiki><br />
#!/bin/sh<br />
<br />
# Example for ~/.config/sxiv/exec/image-info<br />
# Called by sxiv(1) whenever an image gets loaded,<br />
# with the name of the image file as its first argument.<br />
# The output is displayed in sxiv's status bar.<br />
<br />
s=" | " # field separator<br />
<br />
filename=$(basename "$1")<br />
filesize=$(du -Hh "$1" | cut -f 1)<br />
<br />
geometry=$(identify -format '%wx%h' "$1[0]")<br />
<br />
tags=$(exiv2 -q pr -pi "$1" | awk '$1~"Keywords" { printf("%s,", $4); }')<br />
tags=${tags%,}<br />
<br />
echo "${filesize}${s}${geometry}${tags:+$s}${tags}${s}${filename}"<br />
</nowiki>}}<br />
<br />
== See also ==<br />
<br />
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=112643 forum thread].</div>Shmibshttps://wiki.archlinux.org/index.php?title=Sxiv&diff=390873Sxiv2015-08-11T20:23:47Z<p>Shmibs: </p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Graphics and desktop publishing]]<br />
[[ja:Sxiv]]<br />
{{Related articles start}}<br />
{{Related|feh}}<br />
{{Related articles end}}<br />
<br />
[http://github.com/muennich/sxiv sxiv] , Simple [[X]] Image Viewer is a lightweight and scriptable image viewer written in C. <br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] {{Pkg|sxiv}}, which is available in the [[official repositories]].<br />
<br />
== Assigning keyboard shortcuts to sxiv ==<br />
sxiv supports external key events. First you have to press {{ic|Ctrl-x}} to send the next key to the external key-handler. The external key-handler requires an executable file {{ic|~/.config/sxiv/exec/key-handler}} and passes the key combination pressed as well the names of the currently marked images as arguments (or, if none are marked, the currently selected image).<br />
<br />
In this example, we will add the bindings {{ic|Ctrl+d}} to execute {{ic|mv ''filename'' ~/.trash}}, {{ic|Ctrl+c}} to copy the current images' names to the clipboard with {{Pkg|xclip}}, and {{ic|Ctrl+w}} to set the current wallpaper with [[nitrogen]]. Obviously, some commands may only make sense with a single image as an argument, so you may want to revise this to handle cases when those are passed more than one.<br />
<br />
{{hc|~/.config/sxiv/exec/key-handler|<nowiki><br />
#!/bin/sh<br />
while read file<br />
do<br />
case "$1" in<br />
"C-d")<br />
mv "$file" ~/.trash ;;<br />
"C-r")<br />
convert -rotate 90 "$file" "$file" ;;<br />
"C-c")<br />
echo -n "$file" | xclip -selection clipboard ;;<br />
"C-w")<br />
nitrogen --save --set-zoom-fill "$file" ;;<br />
esac<br />
done<br />
</nowiki>}}<br />
<br />
Be sure to mark the script as executable<br />
$ chmod +x ~/.config/sxiv/exec/key-handler<br />
<br />
Create {{ic|.trash}} folder if it does not exist:<br />
$ mkdir ~/.trash<br />
<br />
{{Tip|You may want to use a [http://freedesktop.org/wiki/Specifications/trash-spec/ standards-compliant trashcan] (like {{AUR|trash-cli}} or {{AUR|bashtrash}}) rather than {{ic|mv "$2" ~/.trash}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Browse through images in directory after opening a single file ===<br />
<br />
Place [http://git.savannah.gnu.org/cgit/ranger.git/tree/doc/examples/rifle_sxiv.sh this script] in {{ic|/usr/local/bin}} and call it like this:<br />
$ ''scriptname'' a_single_image.jpg<br />
<br />
Alternatively you can also install the script as a package from the AUR: {{AUR|sxiv-rifle}}. <br />
<br />
As indicated in the comments of the script, it may be used to have this behavior when opening images from within [[ranger]].<br />
<br />
=== Showing the image size in the status bar ===<br />
<br />
Place the following executable script in {{ic|~/.config/sxiv/exec/image-info}} and make sure that you have the {{Pkg|exiv2}} package installed:<br />
<br />
{{hc|~/.config/sxiv/exec/image-info|<nowiki><br />
#!/bin/sh<br />
<br />
# Example for ~/.config/sxiv/exec/image-info<br />
# Called by sxiv(1) whenever an image gets loaded,<br />
# with the name of the image file as its first argument.<br />
# The output is displayed in sxiv's status bar.<br />
<br />
s=" | " # field separator<br />
<br />
filename=$(basename "$1")<br />
filesize=$(du -Hh "$1" | cut -f 1)<br />
<br />
geometry=$(identify -format '%wx%h' "$1[0]")<br />
<br />
tags=$(exiv2 -q pr -pi "$1" | awk '$1~"Keywords" { printf("%s,", $4); }')<br />
tags=${tags%,}<br />
<br />
echo "${filesize}${s}${geometry}${tags:+$s}${tags}${s}${filename}"<br />
</nowiki>}}<br />
<br />
== See also ==<br />
<br />
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=112643 forum thread].</div>Shmibshttps://wiki.archlinux.org/index.php?title=Sxiv&diff=291778Sxiv2014-01-06T07:08:44Z<p>Shmibs: cleanup</p>
<hr />
<div>[[Category:Graphics and desktop publishing]]<br />
{{Lowercase title}}<br />
{{Article summary start}}<br />
{{Article summary text|This article discusses the installation and basic configuration of {{Pkg|sxiv}}.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|feh}}<br />
{{Article summary heading|External Links}}<br />
{{Article summary text| [http://github.com/muennich/sxiv sxiv on github]}}<br />
{{Article summary end}}<br />
<br />
'''sxiv''', Simple [[X]] Image Viewer is a lightweight and scriptable image viewer written in C. <br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] {{Pkg|sxiv}}, which is available in the [[official repositories]].<br />
<br />
== Assigning keyboard shortcuts to sxiv ==<br />
When unrecognised key combos are pressed, sxiv will try to execute the file {{ic|~/.sxiv/exec/key-handler}} if it exists, passing the combo pressed and the name of the current image as arguments.<br />
<br />
In this example, we will add the bindings {{ic|Ctrl+d}} to execute {{ic|mv ''filename'' ~/.trash}}, {{ic|Ctrl+c}} to copy the current image's name to the clipboard with {{Pkg|xclip}}, and {{ic|Ctrl+w}} to set the current wallpaper with [[nitrogen]]. <br />
<br />
{{hc|~/.sxiv/exec/key-handler|<nowiki><br />
#!/bin/sh<br />
<br />
case "$1" in<br />
"C-d")<br />
mv "$2" ~/.trash ;;<br />
"C-c")<br />
echo -n "$2" | xclip -selection clipboard ;;<br />
"C-w")<br />
nitrogen --save --set-zoom-fill "$2" ;;<br />
esac<br />
</nowiki>}}<br />
<br />
Be sure to mark the script as executable<br />
$ chmod +x ~/.sxiv/exec/key-handler<br />
<br />
Create {{ic|.trash}} folder if it does not exist:<br />
$ mkdir ~/.trash<br />
<br />
{{Tip|You may want to use a [http://freedesktop.org/wiki/Specifications/trash-spec/ standards-compliant trashcan] (like {{AUR|trash-cli}} or {{AUR|bashtrash}}) rather than {{ic|mv "$2" ~/.trash}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Browse through images in directory after opening a single file ===<br />
<br />
Place [http://git.savannah.gnu.org/cgit/ranger.git/tree/doc/examples/rifle_sxiv.sh this script] in {{ic|/usr/local/bin}} and call it like this:<br />
$ ''scriptname'' a_single_image.jpg<br />
<br />
Alternatively you can also install the script as a package from the AUR: {{aur|sxiv-rifle}} <br />
<br />
{{Warning|This script may not work with some characters, like {{ic|…}}. Correct the internal ''grep'' options to make it work: {{bc|# sed -i 's/grep/grep -a/' /usr/local/bin/''scriptname''}}}}<br />
As indicated in the comments of the script, it may be used to have this behavior when opening images from within [[ranger]].<br />
<br />
=== Showing the image size in the status bar ===<br />
<br />
Place the following executable script in {{ic|~/.sxiv/exec/image-info}} and make sure that you have the {{Pkg|exiv2}} package installed:<br />
<br />
{{hc|~/.sxiv/exec/image-info|<nowiki><br />
#!/bin/sh<br />
<br />
# Example for ~/.sxiv/exec/image-info<br />
# Called by sxiv(1) whenever an image gets loaded,<br />
# with the name of the image file as its first argument.<br />
# The output is displayed in sxiv's status bar.<br />
<br />
s=" | " # field separator<br />
<br />
filename=$(basename "$1")<br />
filesize=$(du -Hh "$1" | cut -f 1)<br />
<br />
geometry=$(identify -format '%wx%h' "$1[0]")<br />
<br />
tags=$(exiv2 -q pr -pi "$1" | awk '$1~"Keywords" { printf("%s,", $4); }')<br />
tags=${tags%,}<br />
<br />
echo "${filesize}${s}${geometry}${tags:+$s}${tags}${s}${filename}"<br />
</nowiki>}}<br />
<br />
=== Creating a desktop entry ===<br />
<br />
Using a desktop environment some users may prefer to have ''sxiv'' listed in the start menu or list of installed programs. This can be done easily by creating the following {{ic|~/.local/share/applications/sxiv.desktop}} file: <br />
<br />
[Desktop Entry]<br />
Name=sxiv<br />
Comment=A Simple X Image Viewer<br />
Exec=sxiv %f<br />
Terminal=false<br />
Type=Application<br />
Icon=sxiv<br />
Categories=GTK;Graphics;2DGraphics;Viewer;<br />
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-pcx;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-sun-raster;image/x-tga;image/x-xbitmap;image/x-xpixmap;image/svg+xml;<br />
<br />
{{Tip|You can modify {{ic|1=Exec=sxiv %f}} in order to use a user friendly [[#Browse_through_images_in_directory_after_opening_a_single_file|script]].}}<br />
As for the icon, you can for example take [https://github-camo.global.ssl.fastly.net/7da9a42099cafc9a8a66b97d2a6d7f7f95d0a79d/687474703a2f2f6d75656e6e6963682e6769746875622e636f6d2f737869762f696d672f696d6167652e706e67 this] image and place it in {{ic|~/.local/share/icons/hicolor/''size''/apps/sxiv.png}}<br />
<br />
== See also ==<br />
<br />
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=112643 forum thread].</div>Shmibshttps://wiki.archlinux.org/index.php?title=Sxiv&diff=291777Sxiv2014-01-06T07:06:18Z<p>Shmibs: cleanup</p>
<hr />
<div>[[Category:Graphics and desktop publishing]]<br />
{{Lowercase title}}<br />
{{Article summary start}}<br />
{{Article summary text|This article discusses the installation and basic configuration of {{Pkg|sxiv}}.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|feh}}<br />
{{Article summary heading|External Links}}<br />
{{Article summary text| [http://github.com/muennich/sxiv sxiv on github]}}<br />
{{Article summary end}}<br />
<br />
'''sxiv''', Simple [[X]] Image Viewer is a lightweight and scriptable image viewer written in C. <br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] {{Pkg|sxiv}}, which is available in the [[official repositories]].<br />
<br />
== Assigning keyboard shortcuts to sxiv ==<br />
<br />
''sxiv'' is scriptable. When unrecognised key combos are pressed, sxiv will try to execute the file {{ic|~/.sxiv/exec/key-handler}} if it exists, passing the combo pressed and the name of the current image as arguments.<br />
<br />
In this example, we will add the bindings {{ic|Ctrl+d}} to execute {{ic|mv FILENAME ~/.trash}}, {{ic|Ctrl+c}} to copy the current image's name to the clipboard with {{Pkg|xclip}}, and {{ic|Ctrl+w}} to set the current wallpaper with [[nitrogen]]. <br />
<br />
{{hc|~/.sxiv/exec/key-handler|<nowiki><br />
#!/bin/sh<br />
<br />
case "$1" in<br />
"C-d")<br />
mv "$2" ~/.trash ;;<br />
"C-c")<br />
echo -n "$2" | xclip -selection clipboard ;;<br />
"C-w")<br />
nitrogen --save --set-zoom-fill "$2" ;;<br />
esac<br />
</nowiki>}}<br />
<br />
Be sure to mark the script as executable<br />
$ chmod +x ~/.sxiv/exec/key-handler<br />
<br />
Create {{ic|.trash}} folder if it does not exist:<br />
$ mkdir ~/.trash<br />
<br />
{{Tip|You may want to use a [http://freedesktop.org/wiki/Specifications/trash-spec/ standards-compliant trashcan] (like {{AUR|trash-cli}} or {{AUR|bashtrash}}) rather than {{ic|mv "$2" ~/.trash}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Browse through images in directory after opening a single file ===<br />
<br />
Place [http://git.savannah.gnu.org/cgit/ranger.git/tree/doc/examples/rifle_sxiv.sh this script] in {{ic|/usr/local/bin}} and call it like this:<br />
$ ''scriptname'' a_single_image.jpg<br />
<br />
Alternatively you can also install the script as a package from the AUR: {{aur|sxiv-rifle}} <br />
<br />
{{Warning|This script may not work with some characters, like {{ic|…}}. Correct the internal ''grep'' options to make it work: {{bc|# sed -i 's/grep/grep -a/' /usr/local/bin/''scriptname''}}}}<br />
As indicated in the comments of the script, it may be used to have this behavior when opening images from within [[ranger]].<br />
<br />
=== Showing the image size in the status bar ===<br />
<br />
Place the following executable script in {{ic|~/.sxiv/exec/image-info}} and make sure that you have the {{Pkg|exiv2}} package installed:<br />
<br />
{{hc|~/.sxiv/exec/image-info|<nowiki><br />
#!/bin/sh<br />
<br />
# Example for ~/.sxiv/exec/image-info<br />
# Called by sxiv(1) whenever an image gets loaded,<br />
# with the name of the image file as its first argument.<br />
# The output is displayed in sxiv's status bar.<br />
<br />
s=" | " # field separator<br />
<br />
filename=$(basename "$1")<br />
filesize=$(du -Hh "$1" | cut -f 1)<br />
<br />
geometry=$(identify -format '%wx%h' "$1[0]")<br />
<br />
tags=$(exiv2 -q pr -pi "$1" | awk '$1~"Keywords" { printf("%s,", $4); }')<br />
tags=${tags%,}<br />
<br />
echo "${filesize}${s}${geometry}${tags:+$s}${tags}${s}${filename}"<br />
</nowiki>}}<br />
<br />
=== Creating a desktop entry ===<br />
<br />
Using a desktop environment some users may prefer to have ''sxiv'' listed in the start menu or list of installed programs. This can be done easily by creating the following {{ic|~/.local/share/applications/sxiv.desktop}} file: <br />
<br />
[Desktop Entry]<br />
Name=sxiv<br />
Comment=A Simple X Image Viewer<br />
Exec=sxiv %f<br />
Terminal=false<br />
Type=Application<br />
Icon=sxiv<br />
Categories=GTK;Graphics;2DGraphics;Viewer;<br />
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-pcx;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-sun-raster;image/x-tga;image/x-xbitmap;image/x-xpixmap;image/svg+xml;<br />
<br />
{{Tip|You can modify {{ic|1=Exec=sxiv %f}} in order to use a user friendly [[#Browse_through_images_in_directory_after_opening_a_single_file|script]].}}<br />
As for the icon, you can for example take [https://github-camo.global.ssl.fastly.net/7da9a42099cafc9a8a66b97d2a6d7f7f95d0a79d/687474703a2f2f6d75656e6e6963682e6769746875622e636f6d2f737869762f696d672f696d6167652e706e67 this] image and place it in {{ic|~/.local/share/icons/hicolor/''size''/apps/sxiv.png}}<br />
<br />
== See also ==<br />
<br />
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=112643 forum thread].</div>Shmibshttps://wiki.archlinux.org/index.php?title=Sxiv&diff=291773Sxiv2014-01-06T06:41:52Z<p>Shmibs: keyboard shortcuts are now handled via external commands</p>
<hr />
<div>[[Category:Graphics and desktop publishing]]<br />
{{Lowercase title}}<br />
{{Article summary start}}<br />
{{Article summary text|This article discusses the installation and basic configuration of {{Pkg|sxiv}}.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|feh}}<br />
{{Article summary heading|External Links}}<br />
{{Article summary text| [http://github.com/muennich/sxiv sxiv on github]}}<br />
{{Article summary end}}<br />
<br />
'''sxiv''', Simple [[X]] Image Viewer is a lightweight and scriptable image viewer written in C. <br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] {{Pkg|sxiv}}, which is available in the [[official repositories]].<br />
<br />
== Assigning keyboard shortcuts to sxiv ==<br />
<br />
''sxiv'' is scriptable. When unrecognised key combos are pressed, sxiv will try to execute the file {{ic|~/.sxiv/exec/key-handler}} if it exists, passing the combo pressed and the name of the current image as arguments.<br />
<br />
In this example, we will add the commands {{ic|Ctrl+d}} to execute {{ic|mv FILENAME ~/.trash}}, and {{ic|echo -n FILENAME | xclip}} to put the full path and filename of the current image into the clipboard with {{ic|Ctrl+c}}, and {{ic|nitrogen --save --set-zoom-fill FILENAME}} to set the current image as wallpaper with {{ic|Ctrl+w}} <br />
<br />
{{hc|~/.sxiv/exec/key-handler|<nowiki><br />
#!/bin/sh<br />
<br />
case "$1" in<br />
"C-d")<br />
mv "$2" ~/.trash ;;<br />
"C-c")<br />
echo -n "$2" | xclip ;;<br />
"C-w")<br />
nitrogen --save --set-zoom-fill "$2" ;;<br />
esac<br />
</nowiki>}}<br />
<br />
Be sure to mark the script as executable<br />
$ chmod +x ~/.sxiv/exec/key-handler<br />
<br />
Create {{ic|.trash}} folder if it does not exist:<br />
$ mkdir ~/.trash<br />
<br />
{{Tip|You may want to use a standard compliant trashcan (like {{AUR|trash-cli}} or {{AUR|bashtrash}}) instead of {{ic|mv \"$SXIV_IMG\" ~/.trash}}.}}<br />
<br />
Now when you start ''sxiv'' in thumbnail mode on a folder of pictures, i.e.:<br />
$ sxiv -tsr ~/pictures<br />
<br />
You can now delete selected pictures by hitting {{ic|Ctrl+d}}. This will move your selected pic to {{ic|~/.trash}}. Pressing {{ic|Ctrl+c}} copies the full path and file name of the current picture to the clipboard. Pressing {{ic|Ctrl+w}} will make the set the picture as wallpaper using Nitrogen.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Browse through images in directory after opening a single file ===<br />
<br />
Place [http://git.savannah.gnu.org/cgit/ranger.git/tree/doc/examples/rifle_sxiv.sh this script] in {{ic|/usr/local/bin}} and call it like this:<br />
$ ''scriptname'' a_single_image.jpg<br />
<br />
Alternatively you can also install the script as a package from the AUR: {{aur|sxiv-rifle}} <br />
<br />
{{Warning|This script may not work with some characters, like {{ic|…}}. Correct the internal ''grep'' options to make it work: {{bc|# sed -i 's/grep/grep -a/' /usr/local/bin/''scriptname''}}}}<br />
As indicated in the comments of the script, it may be used to have this behavior when opening images from within [[ranger]].<br />
<br />
=== Showing the image size in the status bar ===<br />
<br />
Place the following executable script in {{ic|~/.sxiv/exec/image-info}} and make sure that you have the {{Pkg|exiv2}} package installed:<br />
<br />
{{hc|~/.sxiv/exec/image-info|<nowiki><br />
#!/bin/sh<br />
<br />
# Example for ~/.sxiv/exec/image-info<br />
# Called by sxiv(1) whenever an image gets loaded,<br />
# with the name of the image file as its first argument.<br />
# The output is displayed in sxiv's status bar.<br />
<br />
s=" | " # field separator<br />
<br />
filename=$(basename "$1")<br />
filesize=$(du -Hh "$1" | cut -f 1)<br />
<br />
geometry=$(identify -format '%wx%h' "$1[0]")<br />
<br />
tags=$(exiv2 -q pr -pi "$1" | awk '$1~"Keywords" { printf("%s,", $4); }')<br />
tags=${tags%,}<br />
<br />
echo "${filesize}${s}${geometry}${tags:+$s}${tags}${s}${filename}"<br />
</nowiki>}}<br />
<br />
=== Creating a desktop entry ===<br />
<br />
Using a desktop environment some users may prefer to have ''sxiv'' listed in the start menu or list of installed programs. This can be done easily by creating the following {{ic|~/.local/share/applications/sxiv.desktop}} file: <br />
<br />
[Desktop Entry]<br />
Name=sxiv<br />
Comment=A Simple X Image Viewer<br />
Exec=sxiv %f<br />
Terminal=false<br />
Type=Application<br />
Icon=sxiv<br />
Categories=GTK;Graphics;2DGraphics;Viewer;<br />
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-pcx;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-sun-raster;image/x-tga;image/x-xbitmap;image/x-xpixmap;image/svg+xml;<br />
<br />
{{Tip|You can modify {{ic|1=Exec=sxiv %f}} in order to use a user friendly [[#Browse_through_images_in_directory_after_opening_a_single_file|script]].}}<br />
As for the icon, you can for example take [https://github-camo.global.ssl.fastly.net/7da9a42099cafc9a8a66b97d2a6d7f7f95d0a79d/687474703a2f2f6d75656e6e6963682e6769746875622e636f6d2f737869762f696d672f696d6167652e706e67 this] image and place it in {{ic|~/.local/share/icons/hicolor/''size''/apps/sxiv.png}}<br />
<br />
== See also ==<br />
<br />
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=112643 forum thread].</div>Shmibshttps://wiki.archlinux.org/index.php?title=Sxiv&diff=291772Sxiv2014-01-06T05:41:02Z<p>Shmibs: "scriptable" is not the right word for compile-time configuration</p>
<hr />
<div>[[Category:Graphics and desktop publishing]]<br />
{{Lowercase title}}<br />
{{Article summary start}}<br />
{{Article summary text|This article discusses the installation and basic configuration of {{Pkg|sxiv}}.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|feh}}<br />
{{Article summary heading|External Links}}<br />
{{Article summary text| [http://github.com/muennich/sxiv sxiv on github]}}<br />
{{Article summary end}}<br />
<br />
'''sxiv''', Simple [[X]] Image Viewer is a lightweight and scriptable image viewer written in C. <br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] {{Pkg|sxiv}}, which is available in the [[official repositories]].<br />
<br />
== Assigning keyboard shortcuts to sxiv ==<br />
<br />
''sxiv'' is configurable, but to do this, you have to edit {{ic|config.h}} and compile ''sxiv'' as follows. See [[ABS]] for details on customizing official packages.<br />
<br />
In this example, the following command to {{ic|Ctrl+d}}: {{ic|mv file ~/.trash}}, and {{ic|echo -n file | xclip}} to put the full path and filename of the current image into the clipboard with {{ic|Ctrl+c}}, and {{ic|nitrogen --save --set-zoom-fill file}} to set the current image as wallpaper with {{ic|Ctrl+w}} <br />
<br />
So when ''sxiv'' is started in thumbnail mode on a folder, one can see all files in that folder, select random thumbnails, and hit {{ic|Ctrl+d}} to move them to a custom "trash" folder.<br />
<br />
Edit {{ic|config.h}}, to add the line for the {{ic|d}} and {{ic|c}} shortcut:<br />
{{hc|config.h|<nowiki><br />
/* run shell command line on current file ("$SXIV_IMG"): */<br />
{ true, XK_less, it_shell_cmd, (arg_t) \<br />
"mogrify -rotate -90 \"$SXIV_IMG\"" },<br />
{ true, XK_greater, it_shell_cmd, (arg_t) \<br />
"mogrify -rotate +90 \"$SXIV_IMG\"" },<br />
{ true, XK_comma, it_shell_cmd, (arg_t) \<br />
"jpegtran -rotate 270 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" },<br />
{ true, XK_period, it_shell_cmd, (arg_t) \<br />
"jpegtran -rotate 90 -copy all -outfile \"$SXIV_IMG\" \"$SXIV_IMG\"" },<br />
//insert the lines below<br />
{ true, XK_d, it_shell_cmd, (arg_t) \<br />
"mv \"$SXIV_IMG\" ~/.trash" },<br />
{ true, XK_c, it_shell_cmd, (arg_t) \<br />
"echo -n \"$SXIV_IMG\" | xclip" },<br />
{ true, XK_w, it_shell_cmd, (arg_t) \<br />
"nitrogen --save --set-wallpaper \"$SXIV_IMG\"" },<br />
};<br />
</nowiki>}}<br />
<br />
Create {{ic|.trash}} folder if it does not exist:<br />
$ mkdir ~/.trash<br />
<br />
{{Tip|Yu may want to use a standard compliant trasher (like {{AUR|trash-cli}} or {{AUR|bashtrash}}) instead of {{ic|mv \"$SXIV_IMG\" ~/.trash}}.}}<br />
<br />
Now when you start ''sxiv'' in thumbnail mode on a folder of pictures, i.e.:<br />
$ sxiv -tsr ~/pictures<br />
<br />
You can now delete selected pictures by hitting {{ic|Ctrl+d}}. This will move your selected pic to {{ic|~/.trash}}. Pressing {{ic|Ctrl+c}} copies the full path and file name of the current picture to the clipboard. Pressing {{ic|Ctrl+w}} will make the set the picture as wallpaper using Nitrogen.<br />
<br />
== Tips and tricks ==<br />
<br />
=== Browse through images in directory after opening a single file ===<br />
<br />
Place [http://git.savannah.gnu.org/cgit/ranger.git/tree/doc/examples/rifle_sxiv.sh this script] in {{ic|/usr/local/bin}} and call it like this:<br />
$ ''scriptname'' a_single_image.jpg<br />
<br />
Alternatively you can also install the script as a package from the AUR: {{aur|sxiv-rifle}} <br />
<br />
{{Warning|This script may not work with some characters, like {{ic|…}}. Correct the internal ''grep'' options to make it work: {{bc|# sed -i 's/grep/grep -a/' /usr/local/bin/''scriptname''}}}}<br />
As indicated in the comments of the script, it may be used to have this behavior when opening images from within [[ranger]].<br />
<br />
=== Showing the image size in the status bar ===<br />
<br />
Place the following executable script in {{ic|~/.sxiv/exec/image-info}} and make sure that you have the {{Pkg|exiv2}} package installed:<br />
<br />
{{hc|~/.sxiv/exec/image-info|<nowiki><br />
#!/bin/sh<br />
<br />
# Example for ~/.sxiv/exec/image-info<br />
# Called by sxiv(1) whenever an image gets loaded,<br />
# with the name of the image file as its first argument.<br />
# The output is displayed in sxiv's status bar.<br />
<br />
s=" | " # field separator<br />
<br />
filename=$(basename "$1")<br />
filesize=$(du -Hh "$1" | cut -f 1)<br />
<br />
geometry=$(identify -format '%wx%h' "$1[0]")<br />
<br />
tags=$(exiv2 -q pr -pi "$1" | awk '$1~"Keywords" { printf("%s,", $4); }')<br />
tags=${tags%,}<br />
<br />
echo "${filesize}${s}${geometry}${tags:+$s}${tags}${s}${filename}"<br />
</nowiki>}}<br />
<br />
=== Creating a desktop entry ===<br />
<br />
Using a desktop environment some users may prefer to have ''sxiv'' listed in the start menu or list of installed programs. This can be done easily by creating the following {{ic|~/.local/share/applications/sxiv.desktop}} file: <br />
<br />
[Desktop Entry]<br />
Name=sxiv<br />
Comment=A Simple X Image Viewer<br />
Exec=sxiv %f<br />
Terminal=false<br />
Type=Application<br />
Icon=sxiv<br />
Categories=GTK;Graphics;2DGraphics;Viewer;<br />
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-pcx;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-sun-raster;image/x-tga;image/x-xbitmap;image/x-xpixmap;image/svg+xml;<br />
<br />
{{Tip|You can modify {{ic|1=Exec=sxiv %f}} in order to use a user friendly [[#Browse_through_images_in_directory_after_opening_a_single_file|script]].}}<br />
As for the icon, you can for example take [https://github-camo.global.ssl.fastly.net/7da9a42099cafc9a8a66b97d2a6d7f7f95d0a79d/687474703a2f2f6d75656e6e6963682e6769746875622e636f6d2f737869762f696d672f696d6167652e706e67 this] image and place it in {{ic|~/.local/share/icons/hicolor/''size''/apps/sxiv.png}}<br />
<br />
== See also ==<br />
<br />
* Arch Linux [https://bbs.archlinux.org/viewtopic.php?id=112643 forum thread].</div>Shmibs