My dmenu build
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 13 roky
před 13 roky
před 13 roky
před 13 roky
před 13 roky
před 13 roky
před 13 roky
před 13 roky
před 13 roky
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* See LICENSE file for copyright and license details. */
  2. #include <dirent.h>
  3. #include <errno.h>
  4. #include <limits.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <unistd.h>
  8. #include <sys/stat.h>
  9. static void lsx(const char *dir);
  10. static int status = EXIT_SUCCESS;
  11. int
  12. main(int argc, char *argv[]) {
  13. int i;
  14. if(argc < 2)
  15. lsx(".");
  16. else for(i = 1; i < argc; i++)
  17. lsx(argv[i]);
  18. return status;
  19. }
  20. void
  21. lsx(const char *dir) {
  22. char buf[PATH_MAX];
  23. struct dirent *d;
  24. struct stat st;
  25. DIR *dp;
  26. for(dp = opendir(dir); dp && (d = readdir(dp)); errno = 0)
  27. if(snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name) < (int)sizeof buf
  28. && access(buf, X_OK) == 0 && stat(buf, &st) == 0 && S_ISREG(st.st_mode))
  29. puts(d->d_name);
  30. if(errno != 0) {
  31. status = EXIT_FAILURE;
  32. perror(dir);
  33. }
  34. if(dp)
  35. closedir(dp);
  36. }