projects/guix·blob javascript-team · refs

165 lines · 6.1 KiB

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