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