Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 7a6e1f6

Browse files
authored
Merge pull request #16
fix govnocode
2 parents 3774999 + 333f078 commit 7a6e1f6

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

main.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,26 @@ using namespace std;
1919
#define ACTION_HEIGHT 22
2020

2121
const char *homeDir = getenv("HOME");
22-
string session_id;
2322

2423
ActionWidget poweroff, suspend, reboot, logout;
2524

2625
void power_clicked(GtkWidget *widget, gpointer data) {
2726
auto *pw = (ActionWidget::PowerData *)data;
28-
const char *path = pw->path.c_str();
29-
const char *arg1 = pw->arg1.c_str();
30-
const char *arg2 = pw->arg2.c_str();
31-
32-
string session_id = getenv("XDG_SESSION_ID");
33-
if (strcmp(arg2, "suspend") == 0) {
34-
execl(path, arg1, arg2, (char *)nullptr);
35-
} if (strcmp(arg2, "kill-session") == 0) {
36-
execl(path, arg1, "kill-session", session_id.c_str(), (char *)nullptr);
37-
} else {
38-
execl(path, arg1, (char *)nullptr);
27+
const string path = pw->path;
28+
const string arg1 = pw->arg1;
29+
const string arg2 = pw->arg2;
30+
const string session_id = getenv("XDG_SESSION_ID");
31+
32+
if (arg2 == "suspend") {
33+
execl(path.c_str(), arg1.c_str(), arg2.c_str(), (char *)nullptr);
34+
return;
3935
}
36+
if (arg2 == "kill-session") {
37+
execl(path.c_str(), arg1.c_str(), "kill-session", session_id.c_str(), (char *)nullptr);
38+
return;
39+
}
40+
41+
execl(path.c_str(), arg1.c_str(), (char *)nullptr);
4042
}
4143

4244
void gui(int argc, char *argv[]) {
@@ -105,4 +107,4 @@ int main(int argc, char *argv[]) {
105107
// Start gui
106108
gui(argc, argv);
107109
return 0;
108-
}
110+
}

0 commit comments

Comments
 (0)