projects/aports·blob master · refs

164 lines · 6.2 KiB

1Patch-Source: https://github.com/archlinux/svntogit-community/blob/b29afbc8531197c1de1abd515f7687cdd891cc48/trunk/py3.patch
2From acfbbc4ea40932f183617bb7006700140fe5f61e Mon Sep 17 00:00:00 2001
3From: Troy Curtis Jr <[email protected]>
4Date: Wed, 13 Sep 2017 21:59:48 -0500
5Subject: [PATCH] Add python3 support to openbox-xdg-autostart.
6
7Updated syntax in openbox-xdg-autostart to support both python2 and
8python3.
9
10Added a configure substitution to set the choosen python at build time.
11
12https://bugzilla.icculus.org/show_bug.cgi?id=6444
13---
14 .gitignore | 1 +
15 configure.ac | 3 +
16 ...xdg-autostart => openbox-xdg-autostart.in} | 70 +++++++++----------
17 3 files changed, 38 insertions(+), 36 deletions(-)
18 rename data/autostart/{openbox-xdg-autostart => openbox-xdg-autostart.in} (77%)
19
20diff --git a/configure.ac b/configure.ac
21index ca1602670..9a31e9845 100644
22--- a/configure.ac
23+++ b/configure.ac
24@@ -103,6 +103,8 @@ AC_CHECK_HEADERS(ctype.h dirent.h errno.h fcntl.h grp.h locale.h pwd.h)
25 AC_CHECK_HEADERS(signal.h string.h stdio.h stdlib.h unistd.h sys/stat.h)
26 AC_CHECK_HEADERS(sys/select.h sys/socket.h sys/time.h sys/types.h sys/wait.h)
27
28+AM_PATH_PYTHON([2],,)
29+
30 AC_PATH_PROG([SED], [sed], [no])
31 if test "$SED" = "no"; then
32 AC_MSG_ERROR([The program "sed" is not available. This program is required to build Openbox.])
33@@ -259,6 +261,7 @@ AC_CONFIG_FILES([
34 obrender/version.h
35 obt/version.h
36 version.h
37+ data/autostart/openbox-xdg-autostart
38 ])
39 AC_CONFIG_COMMANDS([doc],
40 [test -d doc || mkdir doc])
41diff --git a/data/autostart/openbox-xdg-autostart b/data/autostart/openbox-xdg-autostart.in
42similarity index 77%
43rename from data/autostart/openbox-xdg-autostart
44rename to data/autostart/openbox-xdg-autostart.in
45index 04a17a199..3c365b112 100755
46--- a/data/autostart/openbox-xdg-autostart
47+++ b/data/autostart/openbox-xdg-autostart.in
48@@ -1,4 +1,4 @@
49-#!/usr/bin/env python
50+#!@PYTHON@
51
52 # openbox-xdg-autostart runs things based on the XDG autostart specification
53 # Copyright (C) 2008 Dana Jansens
54@@ -28,9 +28,7 @@ try:
55 from xdg.DesktopEntry import DesktopEntry
56 from xdg.Exceptions import ParsingError
57 except ImportError:
58- print
59- print >>sys.stderr, "ERROR:", ME, "requires PyXDG to be installed"
60- print
61+ sys.stderr.write("\nERROR: %s requires PyXDG to be installed\n" % ME)
62 sys.exit(1)
63
64 def main(argv=sys.argv):
65@@ -51,7 +49,7 @@ def main(argv=sys.argv):
66 try:
67 autofile = AutostartFile(path)
68 except ParsingError:
69- print "Invalid .desktop file: " + path
70+ print("Invalid .desktop file: " + path)
71 else:
72 if not autofile in files:
73 files.append(autofile)
74@@ -99,9 +97,9 @@ class AutostartFile:
75
76 def _alert(self, str, info=False):
77 if info:
78- print "\t ", str
79+ print("\t ", str)
80 else:
81- print "\t*", str
82+ print("\t*", str)
83
84 def _showInEnvironment(self, envs, verbose=False):
85 default = not self.de.getOnlyShowIn()
86@@ -146,14 +144,14 @@ class AutostartFile:
87
88 def display(self, envs):
89 if self._shouldRun(envs):
90- print "[*] " + self.de.getName()
91+ print("[*] " + self.de.getName())
92 else:
93- print "[ ] " + self.de.getName()
94+ print("[ ] " + self.de.getName())
95 self._alert("File: " + self.path, info=True)
96 if self.de.getExec():
97 self._alert("Executes: " + self.de.getExec(), info=True)
98 self._shouldRun(envs, True)
99- print
100+ print()
101
102 def run(self, envs):
103 here = os.getcwd()
104@@ -165,34 +163,34 @@ class AutostartFile:
105 os.chdir(here)
106
107 def show_help():
108- print "Usage:", ME, "[OPTION]... [ENVIRONMENT]..."
109- print
110- print "This tool will run xdg autostart .desktop files"
111- print
112- print "OPTIONS"
113- print " --list Show a list of the files which would be run"
114- print " Files which would be run are marked with an asterix"
115- print " symbol [*]. For files which would not be run,"
116- print " information is given for why they are excluded"
117- print " --help Show this help and exit"
118- print " --version Show version and copyright information"
119- print
120- print "ENVIRONMENT specifies a list of environments for which to run autostart"
121- print "applications. If none are specified, only applications which do not "
122- print "limit themselves to certain environments will be run."
123- print
124- print "ENVIRONMENT can be one or more of:"
125- print " GNOME Gnome Desktop"
126- print " KDE KDE Desktop"
127- print " ROX ROX Desktop"
128- print " XFCE XFCE Desktop"
129- print " Old Legacy systems"
130- print
131+ print("Usage:", ME, "[OPTION]... [ENVIRONMENT]...")
132+ print()
133+ print("This tool will run xdg autostart .desktop files")
134+ print()
135+ print("OPTIONS")
136+ print(" --list Show a list of the files which would be run")
137+ print(" Files which would be run are marked with an asterix")
138+ print(" symbol [*]. For files which would not be run,")
139+ print(" information is given for why they are excluded")
140+ print(" --help Show this help and exit")
141+ print(" --version Show version and copyright information")
142+ print()
143+ print("ENVIRONMENT specifies a list of environments for which to run autostart")
144+ print("applications. If none are specified, only applications which do not ")
145+ print("limit themselves to certain environments will be run.")
146+ print()
147+ print("ENVIRONMENT can be one or more of:")
148+ print(" GNOME Gnome Desktop")
149+ print(" KDE KDE Desktop")
150+ print(" ROX ROX Desktop")
151+ print(" XFCE XFCE Desktop")
152+ print(" Old Legacy systems")
153+ print()
154
155 def show_version():
156- print ME, VERSION
157- print "Copyright (c) 2008 Dana Jansens"
158- print
159+ print(ME, VERSION)
160+ print("Copyright (c) 2008 Dana Jansens")
161+ print()
162
163 if __name__ == "__main__":
164 sys.exit(main())