CPUGraph.MenuApplet: execute SystemMonitor on left mousebutton click

This commit is contained in:
Oliver Kraitschy 2020-01-28 22:20:46 +01:00 committed by Andreas Kling
parent 1d2c9dbc3a
commit bb89eaf950
Notes: sideshowbarker 2024-07-19 09:45:22 +09:00

View file

@ -74,6 +74,20 @@ private:
}
}
virtual void mousedown_event(GMouseEvent& event) override
{
if (event.button() != GMouseButton::Left)
return;
pid_t pid = fork();
if (pid < 0) {
perror("fork");
} else if (pid == 0) {
execl("/bin/SystemMonitor", "SystemMonitor", nullptr);
perror("execl");
ASSERT_NOT_REACHED();
}
}
static void get_cpu_usage(unsigned& busy, unsigned& idle)
{
busy = 0;
@ -98,14 +112,14 @@ private:
int main(int argc, char** argv)
{
if (pledge("stdio shared_buffer accept rpath unix cpath fattr", nullptr) < 0) {
if (pledge("stdio shared_buffer accept proc exec rpath unix cpath fattr", nullptr) < 0) {
perror("pledge");
return 1;
}
GApplication app(argc, argv);
if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) {
if (pledge("stdio shared_buffer accept proc exec rpath", nullptr) < 0) {
perror("pledge");
return 1;
}
@ -135,6 +149,11 @@ int main(int argc, char** argv)
return 1;
}
if (unveil("/bin/SystemMonitor", "x") < 0) {
perror("unveil");
return 1;
}
unveil(nullptr, nullptr);
return app.exec();