45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
#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 = " I";
|
||
break;
|
||
case 2:
|
||
card_string = " H";
|
||
break;
|
||
case 3:
|
||
card_string = " N";
|
||
break;
|
||
/* case 4: */
|
||
default:
|
||
card_string = " ?";
|
||
break;
|
||
}
|
||
}
|
||
|
||
char *optimus_module_poll() {
|
||
return qtb_strdup(card_string);
|
||
}
|