My slstatus configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 6 години
1234567891011121314151617181920212223242526
  1. /* See LICENSE file for copyright and license details. */
  2. #include <errno.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <sys/sysctl.h>
  6. #include "../../util.h"
  7. const char *
  8. cpu_freq(void)
  9. {
  10. int freq, mib[2];
  11. size_t size;
  12. mib[0] = CTL_HW;
  13. mib[1] = HW_CPUSPEED;
  14. size = sizeof(freq);
  15. if (sysctl(mib, 2, &freq, &size, NULL, 0) == -1) {
  16. fprintf(stderr, "sysctl 'HW_CPUSPEED': %s\n", strerror(errno));
  17. return NULL;
  18. }
  19. return bprintf("%d", freq);
  20. }