mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:27:43 +00:00
CPUGraph.MenuApplet: execute SystemMonitor on left mousebutton click
This commit is contained in:
parent
1d2c9dbc3a
commit
bb89eaf950
1 changed files with 21 additions and 2 deletions
|
@ -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)
|
static void get_cpu_usage(unsigned& busy, unsigned& idle)
|
||||||
{
|
{
|
||||||
busy = 0;
|
busy = 0;
|
||||||
|
@ -98,14 +112,14 @@ private:
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
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");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GApplication app(argc, argv);
|
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");
|
perror("pledge");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -135,6 +149,11 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (unveil("/bin/SystemMonitor", "x") < 0) {
|
||||||
|
perror("unveil");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
unveil(nullptr, nullptr);
|
unveil(nullptr, nullptr);
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue