|
|
|
|
@ -171,68 +171,28 @@ void on_setup_command(GtkWidget *self, main_window *widgets){
|
|
|
|
|
char *target = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->TargetNameEntry));
|
|
|
|
|
if (target&&strcmp(target,"")){
|
|
|
|
|
char *final_command;
|
|
|
|
|
char *terminal_exec = yon_dictionary_get_data(yon_dictionary_get(&main_config.terminals,(char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->runWithTerminalCombo))),terminal_info*)->exec_file;
|
|
|
|
|
char *terminal_hold = yon_dictionary_get_data(main_config.terminals,terminal_info*)->hold;
|
|
|
|
|
char *terminal_exec_arg = yon_dictionary_get_data(main_config.terminals,terminal_info*)->exec_arg;
|
|
|
|
|
int terminal_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck));
|
|
|
|
|
int chosen_terminal = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithTerminalCombo));
|
|
|
|
|
terminal_info *terminal = yon_dictionary_get_data(yon_dictionary_get_nth(main_config.terminals,chosen_terminal),terminal_info*);
|
|
|
|
|
int user_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserCheck));
|
|
|
|
|
char *user = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->runWithUserCombo));
|
|
|
|
|
char *priority = yon_char_append("nice -n ",yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->prioritySpin))));
|
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserCheck))){
|
|
|
|
|
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserPkexecCheck))){
|
|
|
|
|
final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ",!strstr(target,".") ? terminal_hold : ""," ",terminal_exec_arg," ",NULL) : "", "pkexec ", NULL);
|
|
|
|
|
if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))==0){ //root
|
|
|
|
|
final_command = yon_char_unite(final_command, " --user root env HOME=$HOME DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR SESSION_MANAGER=$SESSION_MANAGER GNOME_DESKTOP_SESSION_ID=$GNOME_DESKTOP_SESSION_ID KDE_FULL_SESSION=$KDE_FULL_SESSION ",NULL);
|
|
|
|
|
} else {
|
|
|
|
|
final_command = yon_char_unite(final_command, " --user ",user," env HOME=$HOME DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE ",NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strstr(target,".")){
|
|
|
|
|
final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "xdg-open ",target,NULL);
|
|
|
|
|
} else {
|
|
|
|
|
final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority," ") : "",target,NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSuCheck))){
|
|
|
|
|
final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ",!strstr(target,".") ? terminal_hold : ""," ",terminal_exec_arg," ",NULL) : "", "su ", NULL);
|
|
|
|
|
if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))==0){ //root
|
|
|
|
|
final_command = yon_char_unite(final_command, " --preserve-environment --command \"setsid ",NULL);
|
|
|
|
|
} else {
|
|
|
|
|
final_command = yon_char_unite("xhost +SI:localuser:",user,"; ",final_command, " --login ",user," --command \"setsid env DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE ",NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strstr(target,".")){
|
|
|
|
|
final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "xdg-open ",target,"\"",NULL);
|
|
|
|
|
} else {
|
|
|
|
|
final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority," ") : "",target,"\"",NULL);
|
|
|
|
|
}
|
|
|
|
|
if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))){
|
|
|
|
|
final_command = yon_char_unite(final_command,"; sleep 10 && xhost -SI:localuser:",user,NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSudoCheck))){
|
|
|
|
|
final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ",!strstr(target,".") ? terminal_hold : ""," ",terminal_exec_arg," ",NULL) : "", "sudo ", NULL);
|
|
|
|
|
if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))==0){ //root
|
|
|
|
|
final_command = yon_char_unite(final_command, " --preserve-env setsid ",NULL);
|
|
|
|
|
} else {
|
|
|
|
|
final_command = yon_char_unite("xhost +SI:localuser:",user,"; ",final_command, " --user ",user," setsid env DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE ",NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strstr(target,".")){
|
|
|
|
|
final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "xdg-open '",target,"'",NULL);
|
|
|
|
|
} else {
|
|
|
|
|
final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority," '") : "'",target,"'",NULL);
|
|
|
|
|
}
|
|
|
|
|
if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))){
|
|
|
|
|
final_command = yon_char_unite(final_command,"; sleep 10 && xhost -SI:localuser:",user,NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (strstr(target,".")){
|
|
|
|
|
final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ", !strstr(target,".") ? terminal_hold : "",!strstr(target,".") ? " " : "", terminal_exec_arg, " ",NULL) : "",gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "setsid xdg-open ",target,NULL);
|
|
|
|
|
} else {
|
|
|
|
|
final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ", !strstr(target,".") ? terminal_hold : "",!strstr(target,".") ? " " : "", terminal_exec_arg, " ",NULL) : "",gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "",target,NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int pkexec_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserPkexecCheck));
|
|
|
|
|
int su_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSuCheck));
|
|
|
|
|
int sudo_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSudoCheck));
|
|
|
|
|
int priority_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck));
|
|
|
|
|
char *priority = priority_check ? yon_char_append(" -p ",yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->prioritySpin)))) : "";
|
|
|
|
|
int size;
|
|
|
|
|
char *command = yon_char_unite(get_run_command_command,
|
|
|
|
|
terminal_check ? yon_char_append(" -t ", terminal->name_simple) : "",
|
|
|
|
|
user_check ? yon_char_append(" -u ", user) : "",
|
|
|
|
|
user_check&&pkexec_check ? " -e pkexec" : "",
|
|
|
|
|
user_check&&su_check ? " -e su" : "",
|
|
|
|
|
user_check&&sudo_check ? " -e sudo" : "",
|
|
|
|
|
priority_check ? priority : "",
|
|
|
|
|
yon_char_append(" ",target),
|
|
|
|
|
NULL);
|
|
|
|
|
config_str gotten_command = yon_config_load(command,&size);
|
|
|
|
|
final_command = yon_char_divide_search(*gotten_command,"\n",-1);
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->commandEntry),final_command);
|
|
|
|
|
free(final_command);
|
|
|
|
|
}
|
|
|
|
|
@ -362,18 +322,16 @@ main_window *setup_window(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config_str terminals = yon_config_load(get_terminals_info_command,&size);
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
for (int i=1;i<size;i++){
|
|
|
|
|
int parsed_size;
|
|
|
|
|
terminals[i] = yon_char_divide_search(terminals[i],"\n",-1);
|
|
|
|
|
config_str terminal_parsed = yon_char_parse(terminals[i], &parsed_size,":");
|
|
|
|
|
if (!access(terminal_parsed[1],F_OK)){
|
|
|
|
|
terminal_info *term = g_malloc0(sizeof(terminal_info));
|
|
|
|
|
term->name = terminal_parsed[0];
|
|
|
|
|
term->exec_file = terminal_parsed[1];
|
|
|
|
|
term->hold = terminal_parsed[2];
|
|
|
|
|
term->exec_arg = terminal_parsed[3];
|
|
|
|
|
term->exec = terminal_parsed[0];
|
|
|
|
|
term->name_simple = terminal_parsed[1];
|
|
|
|
|
term->name = terminal_parsed[2];
|
|
|
|
|
if (!access(term->exec,F_OK)) {gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->runWithTerminalCombo),term->name);
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(main_config.terminals,term->name,term);
|
|
|
|
|
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->runWithTerminalCombo),term->name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->runWithTerminalCombo),0);
|
|
|
|
|
|