Use glib's find in path
This commit is contained in:
parent
af902ee8b0
commit
4769e35ef6
1 changed files with 12 additions and 3 deletions
|
|
@ -198,12 +198,21 @@ static std::vector<char *> createForkEnviron()
|
||||||
return newEnv;
|
return newEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr char zenityPath[] = "/usr/bin/zenity";
|
static const std::string zenityPath = [] {
|
||||||
|
auto glibPath = g_find_program_in_path("zenity");
|
||||||
|
if (glibPath) {
|
||||||
|
std::string s { glibPath };
|
||||||
|
g_free(glibPath);
|
||||||
|
return s;
|
||||||
|
} else {
|
||||||
|
return std::string("/usr/bin/zenity");
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
bool askQuestion(const char *text)
|
bool askQuestion(const char *text)
|
||||||
{
|
{
|
||||||
char *argv[] = {
|
char *argv[] = {
|
||||||
const_cast<char *>(zenityPath),
|
const_cast<char *>(zenityPath.c_str()),
|
||||||
const_cast<char *>("--question"),
|
const_cast<char *>("--question"),
|
||||||
const_cast<char *>("--text"),
|
const_cast<char *>("--text"),
|
||||||
const_cast<char *>(text),
|
const_cast<char *>(text),
|
||||||
|
|
@ -236,7 +245,7 @@ bool askQuestion(const char *text)
|
||||||
|
|
||||||
bool isZenityAvailable()
|
bool isZenityAvailable()
|
||||||
{
|
{
|
||||||
return access(zenityPath, X_OK) == 0;
|
return access(zenityPath.c_str(), X_OK) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getOperatingSystemName()
|
std::string getOperatingSystemName()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue