Skip to content

Commit

Permalink
Merge pull request #16
Browse files Browse the repository at this point in the history
fix govnocode
  • Loading branch information
progzone122 authored May 2, 2024
2 parents 3774999 + 333f078 commit 7a6e1f6
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,26 @@ using namespace std;
#define ACTION_HEIGHT 22

const char *homeDir = getenv("HOME");
string session_id;

ActionWidget poweroff, suspend, reboot, logout;

void power_clicked(GtkWidget *widget, gpointer data) {
auto *pw = (ActionWidget::PowerData *)data;
const char *path = pw->path.c_str();
const char *arg1 = pw->arg1.c_str();
const char *arg2 = pw->arg2.c_str();

string session_id = getenv("XDG_SESSION_ID");
if (strcmp(arg2, "suspend") == 0) {
execl(path, arg1, arg2, (char *)nullptr);
} if (strcmp(arg2, "kill-session") == 0) {
execl(path, arg1, "kill-session", session_id.c_str(), (char *)nullptr);
} else {
execl(path, arg1, (char *)nullptr);
const string path = pw->path;
const string arg1 = pw->arg1;
const string arg2 = pw->arg2;
const string session_id = getenv("XDG_SESSION_ID");

if (arg2 == "suspend") {
execl(path.c_str(), arg1.c_str(), arg2.c_str(), (char *)nullptr);
return;
}
if (arg2 == "kill-session") {
execl(path.c_str(), arg1.c_str(), "kill-session", session_id.c_str(), (char *)nullptr);
return;
}

execl(path.c_str(), arg1.c_str(), (char *)nullptr);
}

void gui(int argc, char *argv[]) {
Expand Down Expand Up @@ -105,4 +107,4 @@ int main(int argc, char *argv[]) {
// Start gui
gui(argc, argv);
return 0;
}
}

0 comments on commit 7a6e1f6

Please sign in to comment.