21 #if defined(_X11) || defined(__APPLE__)
33 #define WIN32_LEAN_AND_MEAN
41 #define ERR_DU LOG_STREAM(err, log_desktop)
42 #define LOG_DU LOG_STREAM(info, log_desktop)
46 bool open_object([[maybe_unused]]
const std::string& path_or_url)
48 LOG_DU <<
"open_object(): requested object: " << path_or_url;
50 #if defined(_X11) || defined(__APPLE__)
53 LOG_DU <<
"open_object(): on X11, will use xdg-open";
54 const char launcher[] =
"xdg-open";
56 LOG_DU <<
"open_object(): on OS X, will use open";
57 const char launcher[] =
"open";
60 const pid_t child = fork();
63 ERR_DU <<
"open_object(): fork() failed";
65 }
else if(child == 0) {
66 execlp(launcher, launcher, path_or_url.c_str(),
nullptr);
70 std::thread
t { [child](){
int status; waitpid(child, &status, 0); } };
77 LOG_DU <<
"open_object(): on Win32, will use ShellExecute()";
79 std::wstring u16path = unicode_cast<std::wstring>(path_or_url);
81 const ptrdiff_t res =
reinterpret_cast<ptrdiff_t
>(ShellExecute(
nullptr, L
"open", u16path.c_str(),
nullptr,
nullptr, SW_SHOW));
83 ERR_DU <<
"open_object(): ShellExecute() failed (" << res <<
")";
91 ERR_DU <<
"open_object(): unsupported platform";
Standard logging facilities (interface).
bool open_object([[maybe_unused]] const std::string &path_or_url)
static lg::log_domain log_desktop("desktop")
Desktop environment interaction functions.