Browse Source

Taskbar: Open 'Assistant' with Super+Space

Spencer Dixon 4 years ago
parent
commit
cbe67ed665
1 changed files with 23 additions and 1 deletions
  1. 23 1
      Userland/Services/Taskbar/TaskbarWindow.cpp

+ 23 - 1
Userland/Services/Taskbar/TaskbarWindow.cpp

@@ -329,7 +329,29 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
         break;
         break;
     }
     }
     case GUI::Event::WM_SuperSpaceKeyPressed: {
     case GUI::Event::WM_SuperSpaceKeyPressed: {
-        dbgln("super and space was pressed down");
+        auto af_path = String::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, "Assistant.af");
+        auto af = Desktop::AppFile::open(af_path);
+        if (!af->is_valid()) {
+            warnln("invalid app file when trying to open Assistant");
+            return;
+        }
+        auto app_executable = af->executable();
+
+        pid_t pid = fork();
+        if (pid < 0) {
+            perror("fork");
+        } else if (pid == 0) {
+            if (chdir(Core::StandardPaths::home_directory().characters()) < 0) {
+                perror("chdir");
+                exit(1);
+            }
+            execl(app_executable.characters(), app_executable.characters(), nullptr);
+            perror("execl");
+            VERIFY_NOT_REACHED();
+        } else {
+            if (disown(pid) < 0)
+                perror("disown");
+        }
         break;
         break;
     }
     }
     default:
     default: