summary refs log tree commit diff
path: root/pkgs/applications/graphics/vimiv/fixes.patch
blob: 09c06e43058a30b0ada43f593919c76316e985ae (plain) (blame)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Patch submitted upstream at https://github.com/karlch/vimiv/pull/32

diff --git a/tests/main_test.py b/tests/main_test.py
index a1870e7..2edc86d 100644
--- a/tests/main_test.py
+++ b/tests/main_test.py
@@ -15,7 +15,7 @@ class MainTest(TestCase):
 
     def test_main_until_quit(self):
         """Run through vimiv main once."""
-        v_main.main(True)
+        v_main.main([], True)
 
 
 if __name__ == '__main__':
diff --git a/vimiv/helpers.py b/vimiv/helpers.py
index 22f0115..bfaf016 100644
--- a/vimiv/helpers.py
+++ b/vimiv/helpers.py
@@ -3,7 +3,6 @@
 """Wrappers around standard library functions used in vimiv."""
 
 import os
-from subprocess import Popen, PIPE
 from gi import require_version
 require_version('Gtk', '3.0')
 from gi.repository import Gtk
@@ -20,17 +19,17 @@ scrolltypes["K"] = (Gtk.ScrollType.START, False)
 scrolltypes["L"] = (Gtk.ScrollType.END, True)
 
 # A list of all external commands
-external_commands = []
-try:
-    p = Popen('echo $PATH | tr \':\' \'\n\' | xargs -n 1 ls -1',
-              stdout=PIPE, stderr=PIPE, shell=True)
-    out, err = p.communicate()
-    out = out.decode('utf-8').split()
-    for cmd in sorted(list(set(out))):
-        external_commands.append("!" + cmd)
-except:
-    external_commands = []
-external_commands = tuple(external_commands)
+pathenv = os.environ.get('PATH')
+if pathenv is not None:
+    executables = set()
+    for path in pathenv.split(':'):
+        try:
+            executables |= set(["!" + e for e in os.listdir(path)])
+        except OSError:
+            continue
+    external_commands = tuple(sorted(list(executables)))
+else:
+    external_commands = ()
 
 
 def listdir_wrapper(path, show_hidden=False):
diff --git a/vimiv/imageactions.py b/vimiv/imageactions.py
index d92eb73..b9bc986 100644
--- a/vimiv/imageactions.py
+++ b/vimiv/imageactions.py
@@ -157,8 +157,8 @@ class Thumbnails:
             # Correct name
             thumb_ext = ".thumbnail_%dx%d" % (self.thumbsize[0],
                                               self.thumbsize[1])
-            outfile_ext = infile.split(".")[0] + thumb_ext + ".png"
-            outfile_base = os.path.basename(outfile_ext)
+            infile_base = os.path.basename(infile)
+            outfile_base = infile_base.split(".")[0] + thumb_ext + ".png"
             outfile = os.path.join(self.directory, outfile_base)
             # Only if they aren't cached already
             if outfile_base not in self.thumbnails:
diff --git a/vimiv/main.py b/vimiv/main.py
index a0e38cf..39f7407 100644
--- a/vimiv/main.py
+++ b/vimiv/main.py
@@ -27,7 +27,7 @@ from vimiv.mark import Mark
 from vimiv.information import Information
 
 
-def main(running_tests=False):
+def main(arguments, running_tests=False):
     """Starting point for vimiv.
 
     Args:
@@ -36,7 +36,7 @@ def main(running_tests=False):
     parser = get_args()
     parse_dirs()
     settings = parse_config()
-    settings = parse_args(parser, settings)
+    settings = parse_args(parser, settings, arguments)
 
     args = settings["GENERAL"]["paths"]
 
diff --git a/vimiv/parser.py b/vimiv/parser.py
index 874a538..9d5afce 100644
--- a/vimiv/parser.py
+++ b/vimiv/parser.py
@@ -56,7 +56,7 @@ def get_args():
     return parser
 
 
-def parse_args(parser, settings, arguments=None):
+def parse_args(parser, settings, arguments):
     """Parse the arguments and return the modified settings.
 
     Args:
@@ -66,10 +66,7 @@ def parse_args(parser, settings, arguments=None):
 
     Return: Modified settings after parsing the arguments.
     """
-    if arguments:
-        args = parser.parse_args(arguments)
-    else:
-        args = parser.parse_args()
+    args = parser.parse_args(arguments)
     if args.show_version:
         information = Information()
         print(information.get_version())
diff --git a/vimiv/vimiv b/vimiv/vimiv
index 5497e08..57f34f1 100755
--- a/vimiv/vimiv
+++ b/vimiv/vimiv
@@ -5,4 +5,4 @@ import sys
 import vimiv
 
 if __name__ == '__main__':
-    sys.exit(vimiv.main.main())
+    sys.exit(vimiv.main.main(sys.argv))