This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
quick-text-bar/modules/optimus.c

45 lines
1.2 KiB
C
Raw Normal View History

2022-08-28 14:27:03 -07:00
#include "optimus.h"
#include "../util.h"
#include <stdlib.h>
static const char *card_string;
void optimus_module_init() {
int status = system("card_status=\"`optimus-manager --status 2>/dev/null | "
"grep -Po '(?<=Current GPU mode : )[a-z]'`\"\n"
"case \"$card_status\" in\n"
" 'i')\n"
" exit 1\n"
" ;;\n"
" 'h')\n"
" exit 2\n"
" ;;\n"
" 'n')\n"
" exit 3\n"
" ;;\n"
" *)\n"
" exit 4\n"
" ;;\n"
"esac\n");
switch (WEXITSTATUS(status)) {
case 1:
card_string = "";
break;
case 2:
card_string = "";
break;
case 3:
card_string = "";
break;
/* case 4: */
default:
card_string = "";
break;
}
}
char *optimus_module_poll() {
return qtb_strdup(card_string);
}