My slstatus configuration
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

24 lines
439 B

  1. /* See LICENSE file for copyright and license details. */
  2. #include <inttypes.h>
  3. #include <stdio.h>
  4. #include <time.h>
  5. #include "../util.h"
  6. const char *
  7. uptime(void)
  8. {
  9. uintmax_t h, m;
  10. struct timespec uptime;
  11. if (clock_gettime(CLOCK_BOOTTIME, &uptime) < 0) {
  12. warn("clock_gettime 'CLOCK_BOOTTIME'");
  13. return NULL;
  14. }
  15. h = uptime.tv_sec / 3600;
  16. m = uptime.tv_sec % 3600 / 60;
  17. return bprintf("%" PRIuMAX "h %" PRIuMAX "m", h, m);
  18. }