21 #if defined(_X11) || defined(__APPLE__) 25 #include <sys/types.h> 34 #define WIN32_LEAN_AND_MEAN 42 #define ERR_DU LOG_STREAM(err, log_desktop) 43 #define LOG_DU LOG_STREAM(info, log_desktop) 47 bool open_object([[maybe_unused]]
const std::string& path_or_url)
49 LOG_DU <<
"open_object(): requested object: " << path_or_url;
51 #if defined(_X11) || defined(__APPLE__) 54 LOG_DU <<
"open_object(): on X11, will use xdg-open";
55 const char launcher[] =
"xdg-open";
57 LOG_DU <<
"open_object(): on OS X, will use open";
58 const char launcher[] =
"open";
61 const pid_t child = fork();
64 ERR_DU <<
"open_object(): fork() failed";
66 }
else if(child == 0) {
67 execlp(launcher, launcher, path_or_url.c_str(),
nullptr);
71 std::thread
t { [child](){
int status; waitpid(child, &status, 0); } };
78 LOG_DU <<
"open_object(): on Win32, will use ShellExecute()";
80 std::wstring u16path =
unicode_cast<std::wstring>(path_or_url);
82 const ptrdiff_t res =
reinterpret_cast<ptrdiff_t
>(ShellExecute(
nullptr, L
"open", u16path.c_str(),
nullptr,
nullptr, SW_SHOW));
84 ERR_DU <<
"open_object(): ShellExecute() failed (" << res <<
")";
92 ERR_DU <<
"open_object(): unsupported platform";
ucs4_convert_impl::enableif< TD, typename TS::value_type >::type unicode_cast(const TS &source)
Desktop environment interaction functions.
bool open_object([[maybe_unused]] const std::string &path_or_url)
Standard logging facilities (interface).
static lg::log_domain log_desktop("desktop")