session.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2018 K. Lange
  5. *
  6. * session - UI session manager
  7. *
  8. * Runs a background and panel for a single user and waits
  9. * for them to exit.
  10. */
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. #include <unistd.h>
  14. #include <signal.h>
  15. #include <errno.h>
  16. #include <sys/wait.h>
  17. int main(int argc, char * argv[]) {
  18. char path[1024];
  19. char * home = getenv("HOME");
  20. if (home) {
  21. sprintf(path, "%s/.yutanirc", home);
  22. char * args[] = {path, NULL};
  23. execvp(args[0], args);
  24. }
  25. /* Fallback */
  26. int _background_pid = fork();
  27. if (!_background_pid) {
  28. sprintf(path, "%s/Desktop", home);
  29. chdir(path);
  30. char * args[] = {"/bin/file-browser", "--wallpaper", NULL};
  31. execvp(args[0], args);
  32. }
  33. int _panel_pid = fork();
  34. if (!_panel_pid) {
  35. char * args[] = {"/bin/panel", "--really", NULL};
  36. execvp(args[0], args);
  37. }
  38. wait(NULL);
  39. int pid;
  40. do {
  41. pid = waitpid(-1, NULL, 0);
  42. } while ((pid > 0) || (pid == -1 && errno == EINTR));
  43. return 0;
  44. }