monitor hdmi changes to keep the backlight off

This commit is contained in:
Shaun Inman 2023-03-02 21:28:17 -05:00
parent e2f7c63892
commit 6a7a06aba5
2 changed files with 8 additions and 1 deletions

View file

@ -32,6 +32,7 @@ static pthread_t ports_pt;
#define JACK_STATE_PATH "/sys/class/switch/h2w/state"
#define HDMI_STATE_PATH "/sys/class/switch/hdmi/state"
#define BACKLIGHT_PATH "/sys/class/backlight/backlight.2/bl_power"
int getInt(char* path) {
int i = 0;
@ -68,6 +69,11 @@ static void* watchPorts(void *arg) {
had_hdmi = has_hdmi;
SetHDMI(has_hdmi);
}
else if (has_hdmi && !getInt(BACKLIGHT_PATH)) {
SetHDMI(has_hdmi);
}
}
return 0;

View file

@ -138,7 +138,7 @@ void SetRawBrightness(int val) { // 0 - 1024
}
// this prevents exiting/launching from turning the screen back on
SetHDMI(GetHDMI()); // TODO: isn't working
// SetHDMI(GetHDMI()); // TODO: isn't working
}
void SetRawVolume(int val) { // 0 - 40
int fd = open(VOLUME_PATH, O_WRONLY);
@ -169,6 +169,7 @@ void SetJack(int value) {
int GetHDMI(void) {
// TODO: tmp, testing hdmi without an hdmi output
// return settings->jack;
// printf("GetHDMI() %i\n", settings->hdmi); fflush(stdout);
return settings->hdmi;
}
void SetHDMI(int value) {