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 Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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);
}