blob: 9dcb4b035c08c9f5325ab95e01e6223fe2a8937d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#!/bin/sh
# File: irfanview-common
# Locations: /usr/bin
# Author: bgstack15@gmail.com
# Startdate: 2016-01-29
# Title: Common Elements for Wrapper script for passing files to Irfanview
# Purpose: Converts file paths to a wine format and also handles compressed files
# History: 2016-01-29 Initial quick script written. It used a bunch of sed commands to transform paths to a wine format.
# 2019-02-26 remove /etc/default/irfanview file
# 2019-06-01 fix invocation for single item with space in name. Cannot call multiple objcts with spaces in filename.
# 2019-06-16 remove DEVTTY in favor of just showing on current tty
# 2019-06-16 replace winepath call with wine $WINEPATH_BIN
# 2019-06-16 split into package-arch-specific and common scripts
# 2020-05-20 handle multiple filenames correctly now, including removing \r from winepath output
# 2020-07-14 use echo binary instead of shell builtin
# Usage:
# called from irfanview (which is symlink to irfanview32 or ifanview64)
# Do not use this by itself.
# Reference:
# Ideas for zip expansion and winepath https://github.com/Zykr/IrfanViewLinux/blob/master/irfanview
# Improve:
if ! test "${IV_VALID_CALL:-nothing}" = "do_not_set_this_manually" ;
then
printf "%s\n" "Do not call this script by itself! Use \"irfanview\". Aborted."
false
else
IV_VERSION="2020-07-14a"
echobin="$( which echo )"
# Define functions
expandword() {
# call: expandword "${word}"
# if file, add it
# if directory, expand it
# if tarball, extract it and operate on the directory like normal
local _word="$( ${echobin} "${@}" | sed -e 'sF\/\/F\/Fg;' )"
if test -d "${_word}";
then
# loop through all files in the directory
for _newword in "${_word}"/*;
do
expandword "${_newword}";
done
elif test -f "${_word}";
then
# file exists so check if tarball
case "${_word}" in
*.tgz|*.tar.gz)
# extract it and expand the temporary directory
_tmpdir="$( mktemp -d )"; alltempdirs="${alltempdirs} ${_tmpdir}"
${echobin} "tmpdir ${_tmpdir}"
tar -zx -C "${_tmpdir}" -f "${_word}"
expandword "${_tmpdir}"
;;
*.zip)
_tmpdir="$( mktemp -d )"; alltempdirs="${alltempdirs} ${_tmpdir}"
${echobin} "tmpdir ${_tmpdir}"
${echobin} "7za e -w${_tmpdir} ${_word}"
( cd "${_tmpdir}" ; 7za e "${_word}" ; )
expandword "${_tmpdir}"
;;
*)
# assume it is readable and add it to list of files to open
${echobin} "File:1 ${_word}"
thisfile="$( getwinepath "${_word}" )"
${echobin} "File:2 ${thisfile}"
irfanfiles="${irfanfiles} '${thisfile}'"
;;
esac
fi
}
getwinepath() {
# call: getwinepath "$foo"
wine winepath.exe -w "${@}"
}
# Define variables
alltempdirs=""
# prepare files
irfanargs=
irfanfiles=
for word in "${@}";
do
expandword "${word}"
done
irfanfiles="$( ${echobin} "${irfanfiles## }" | sed -r -e 's/\r//g;' )"
# run wine
cd $WINEPREFIX
${echobin} wine "${IV_EXEC_PATH}" ${irfanargs} ${irfanfiles}
eval wine \"${IV_EXEC_PATH}\" "${irfanargs}" "${irfanfiles}" &
wait %1
for thistempdir in ${alltempdirs};
do
rm -rf "${thistempdir}"
done
fi
|