35 #include <kdeversion.h>
37 #include <QtCore/QLibraryInfo>
38 #include <QtCore/QCoreApplication>
41 #include <config-prefix.h>
51 QString path = QDir::toNativeSeparators( s );
52 printf(
"%s\n", path.toLocal8Bit().constData());
59 proc.start( QString::fromLatin1(
"xdg-user-dir"),
QStringList() << QString::fromLatin1(type) );
60 if (!proc.waitForStarted() || !proc.waitForFinished())
62 return QString::fromLocal8Bit( proc.readAll()).trimmed();
65 int main(
int argc,
char **argv)
67 QCoreApplication app(argc, argv);
68 KAboutData about(
"kde4-config",
"kdelibs4",
ki18n(
"kde4-config"),
"1.0",
69 ki18n(
"A little program to output installation paths"),
71 ki18n(
"(C) 2000 Stephan Kulow"));
75 options.
add(
"expandvars",
ki18n(
"Left for legacy support"));
76 options.
add(
"prefix",
ki18n(
"Compiled in prefix for KDE libraries"));
77 options.
add(
"exec-prefix",
ki18n(
"Compiled in exec_prefix for KDE libraries"));
78 options.
add(
"libsuffix",
ki18n(
"Compiled in library path suffix"));
79 options.
add(
"localprefix",
ki18n(
"Prefix in $HOME used to write files"));
80 options.
add(
"kde-version",
ki18n(
"Compiled in version string for KDE libraries"));
81 options.
add(
"types",
ki18n(
"Available KDE resource types"));
82 options.
add(
"path type",
ki18n(
"Search path for resource type"));
83 options.
add(
"locate filename",
ki18n(
"Find filename inside the resource type given to --path"));
84 options.
add(
"userpath type",
ki18n(
"User path: desktop|autostart|document"));
85 options.
add(
"install type",
ki18n(
"Prefix to install resource files to"));
86 options.
add(
"qt-prefix",
ki18n(
"Installation prefix for Qt"));
87 options.
add(
"qt-binaries",
ki18n(
"Location of installed Qt binaries"));
88 options.
add(
"qt-libraries",
ki18n(
"Location of installed Qt libraries"));
89 options.
add(
"qt-plugins",
ki18n(
"Location of installed Qt plugins"));
99 if (args->
isSet(
"prefix"))
105 if (args->
isSet(
"exec-prefix"))
107 printResult(QFile::decodeName(EXEC_INSTALL_PREFIX));
111 if (args->
isSet(
"libsuffix"))
113 QString tmp(QFile::decodeName(KDELIBSUFF));
114 tmp.remove(QLatin1Char(
'"'));
119 if (args->
isSet(
"localprefix"))
125 if (args->
isSet(
"kde-version"))
131 if (args->
isSet(
"types"))
135 const char *helptexts[] = {
136 "apps",
I18N_NOOP(
"Applications menu (.desktop files)"),
137 "autostart",
I18N_NOOP(
"Autostart directories"),
138 "cache",
I18N_NOOP(
"Cached information (e.g. favicons, web-pages)"),
139 "cgi",
I18N_NOOP(
"CGIs to run from kdehelp"),
140 "config",
I18N_NOOP(
"Configuration files"),
141 "data",
I18N_NOOP(
"Where applications store data"),
143 "exe",
I18N_NOOP(
"Executables in $prefix/bin"),
146 "kcfg",
I18N_NOOP(
"Configuration description files"),
148 "include",
I18N_NOOP(
"Includes/Headers"),
149 "locale",
I18N_NOOP(
"Translation files for KLocale"),
155 "servicetypes",
I18N_NOOP(
"Service types"),
156 "sound",
I18N_NOOP(
"Application sounds"),
159 "xdgdata-apps",
I18N_NOOP(
"XDG Application menu (.desktop files)"),
160 "xdgdata-dirs",
I18N_NOOP(
"XDG Menu descriptions (.directory files)"),
162 "xdgdata-pixmap",
I18N_NOOP(
"Legacy pixmaps"),
163 "xdgdata-mime",
I18N_NOOP(
"XDG Mime Types"),
164 "xdgconf-menu",
I18N_NOOP(
"XDG Menu layout (.menu files)"),
165 "xdgconf-autostart",
I18N_NOOP(
"XDG autostart directory"),
166 "tmp",
I18N_NOOP(
"Temporary files (specific for both current host and current user)"),
167 "socket",
I18N_NOOP(
"UNIX Sockets (specific for both current host and current user)"),
170 Q_FOREACH(
const QString &type, types)
173 while (helptexts[index] && type != QLatin1String(helptexts[index])) {
176 if (helptexts[index]) {
177 printf(
"%s - %s\n", helptexts[index],
i18n(helptexts[index+1]).toLocal8Bit().constData());
179 printf(
"%s",
i18n(
"%1 - unknown type\n", type).toLocal8Bit().constData());
189 if (!fileName.isEmpty())
192 if (!result.isEmpty())
193 printf(
"%s\n", result.toLocal8Bit().constData());
194 return result.isEmpty() ? 1 : 0;
205 if (type == QLatin1String(
"desktop"))
209 path = QDir::homePath() + QLatin1String(
"/Desktop");
210 path = QDir::cleanPath(path);
211 if (!path.endsWith(QLatin1Char(
'/')))
212 path.append(QLatin1Char(
'/'));
215 else if (type == QLatin1String(
"autostart"))
218 QString path = QDir::homePath() + QLatin1String(
"/Autostart/");
220 path = QDir::cleanPath( path );
221 if (!path.endsWith(QLatin1Char(
'/')))
222 path.append(QLatin1Char(QLatin1Char(
'/')));
226 else if (type == QLatin1String(
"document"))
230 path = QDir::homePath() + QLatin1String(
"/Documents");
231 path = QDir::cleanPath( path );
232 if (!path.endsWith(QLatin1Char(
'/')))
233 path.append(QLatin1Char(
'/'));
237 fprintf(stderr,
"%s",
i18n(
"%1 - unknown type of userpath\n", type).toLocal8Bit().data() );
247 if (args->
isSet(
"qt-prefix"))
249 printResult(QLibraryInfo::location(QLibraryInfo::PrefixPath));
252 if (args->
isSet(
"qt-binaries"))
254 printResult(QLibraryInfo::location(QLibraryInfo::BinariesPath));
257 if (args->
isSet(
"qt-libraries"))
259 printResult(QLibraryInfo::location(QLibraryInfo::LibrariesPath));
262 if (args->
isSet(
"qt-plugins"))
264 printResult(QLibraryInfo::location(QLibraryInfo::PluginsPath));