parent
23f1b5e6cb
commit
d9938427c7
|
@ -5,6 +5,7 @@ ctan http://www.ctan.org/search?phrase=%s
|
|||
gm https://maps.google.com/maps?q=%s
|
||||
gt http://translate.google.com/#en/fr/%s
|
||||
imdb http://www.imdb.com/find?q=%s&s=all
|
||||
leo http://dict.leo.org/frde/index_de.html#/search=%s
|
||||
torrent http://torrentz.eu/search?f=%s
|
||||
w http://en.wikipedia.org/wiki/Special:Search?search=%s
|
||||
wb http://en.wikibooks.org/wiki/Special:Search?search=%s
|
||||
|
@ -14,4 +15,3 @@ wk http://en.wiktionary.org/wiki/Special:Search?search=%s
|
|||
wkf http://fr.wiktionary.org/wiki/Special:Search?search=%s
|
||||
wr http://www.wordreference.com/enfr/%s
|
||||
yt http://www.youtube.com/results?search_query=%s
|
||||
|
||||
|
|
|
@ -132,6 +132,8 @@ mime ^video, terminal, !X, has mplayer = mplayer -- "$@"
|
|||
#-------------------------------------------
|
||||
# Image Viewing:
|
||||
#-------------------------------------------
|
||||
mime ^image, has sxiv, X, flag f = rifle_sxiv.py -fs -- "$@"
|
||||
ext png|bmp|gif|jpe?g, X, flag f = feh -FZx *.bmp *.jpg *.png *.gif *.jpeg --start-at "$(basename "$1")"
|
||||
mime ^image, has eog, X, flag f = eog -- "$@"
|
||||
mime ^image, has sxiv, X, flag f = sxiv -- "$@"
|
||||
mime ^image, has feh, X, flag f = feh -- "$@"
|
||||
|
|
|
@ -44,7 +44,7 @@ highlight() { command highlight "$@"; test $? = 0 -o $? = 141; }
|
|||
|
||||
case "$extension" in
|
||||
# Archive extensions:
|
||||
7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
|
||||
a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
|
||||
rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
|
||||
try als "$path" && { dump | trim; exit 0; }
|
||||
try acat "$path" && { dump | trim; exit 3; }
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/env python
|
||||
# Compatible with ranger 1.6.*
|
||||
#
|
||||
# If only one file is selected, this script searches image files in a directory,
|
||||
# opens them all with sxiv and sets the first argument to the first image
|
||||
# displayed by sxiv.
|
||||
#
|
||||
# If a selection is on, this script will start sxiv over the selection only.
|
||||
#
|
||||
# This is supposed to be used in rifle.conf as a workaround for the fact that
|
||||
# sxiv takes no file name arguments for the first image, just the number. Copy
|
||||
# this file somewhere into your $PATH and add this at the top of rifle.conf:
|
||||
#
|
||||
# mime ^image, has sxiv, X, flag f = path/to/this/script -- "$@"
|
||||
#
|
||||
# This wrapper supports parameter, so if you want to start fullscreen and to fit
|
||||
# all image to window, use
|
||||
#
|
||||
# mime ^image, has sxiv, X, flag f = path/to/this/script -fs -- "$@"
|
||||
|
||||
# TODO: support for mimetypes.
|
||||
# result = [a for a in filelist if v=mimetypes.guess_type(a)[0] and type(v) is str and v.find('image') != -1 ]
|
||||
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import mimetypes
|
||||
import re
|
||||
|
||||
def usage():
|
||||
print("Usage: " + re.sub(r".*/", "", sys.argv[0]) + " PICTURES")
|
||||
|
||||
|
||||
def sxiv_singlefile(inputfile):
|
||||
# Turn to an absolute path
|
||||
if inputfile[0] != '/':
|
||||
inputfile = os.path.abspath(inputfile)
|
||||
|
||||
inputdir = re.sub(r"/[^/]+$", "/", inputfile)
|
||||
filelist = os.listdir(inputdir)
|
||||
filename = inputfile
|
||||
|
||||
## Note: os.path.join seems to be slow.
|
||||
result = [ inputdir + a for a in filelist if re.search('.(bmp|gif|jpe?g|png)$', a, re.IGNORECASE) != None ]
|
||||
list.sort(result)
|
||||
|
||||
## We get the index of the first argument to know where sxiv should start the display.
|
||||
try:
|
||||
count = result.index(inputfile) + 1
|
||||
except ValueError:
|
||||
count = 1
|
||||
|
||||
result = ["-n" + str(count), "--"] + result
|
||||
if parameters:
|
||||
result = parameters + result
|
||||
result = ["sxiv"] + result
|
||||
|
||||
subprocess.call(result)
|
||||
|
||||
def sxiv_multifile(arglist):
|
||||
result = [ os.path.abspath(a) for a in arglist ]
|
||||
list.sort(result)
|
||||
|
||||
result = ["--"] + result
|
||||
if parameters:
|
||||
result = parameters + result
|
||||
result = ["sxiv"] + result
|
||||
|
||||
print(result)
|
||||
subprocess.call(result)
|
||||
|
||||
|
||||
|
||||
## MAIN
|
||||
if len(sys.argv) == 1:
|
||||
usage_exit()
|
||||
|
||||
arglist = sys.argv
|
||||
arglist.pop(0)
|
||||
|
||||
## Put all sxiv parameters in a string.
|
||||
parameters = []
|
||||
while len(arglist) != 0 and arglist[0] != "--" and arglist[0][0] == "-":
|
||||
parameters = parameters + [arglist[0]]
|
||||
arglist.pop(0)
|
||||
|
||||
if len(arglist) == 0:
|
||||
usage()
|
||||
sys.exit(0)
|
||||
|
||||
if arglist[0] == "--":
|
||||
arglist.pop(0)
|
||||
|
||||
if len(arglist) == 0:
|
||||
usage()
|
||||
elif len(arglist) == 1:
|
||||
sxiv_singlefile(arglist[0])
|
||||
elif len(arglist) >= 2:
|
||||
sxiv_multifile(arglist)
|
||||
|
||||
sys.exit(0)
|
||||
|
Loading…
Reference in New Issue