Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions js/hardware.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,13 @@ const checkSupport = () => {
const brightnessPath = !!HARDWARE.display.brightness.path && !!HARDWARE.display.brightness.value.max;
const brightnessCommand = !!HARDWARE.display.brightness.command && !!HARDWARE.display.brightness.value.max;

const hasBrightness = sudo && (brightnessPath || brightnessCommand);

return {
batteryLevel: batteryPath,
displayStatus: statusPath && statusCommand,
displayBrightness: sudo && statusPath && statusCommand && (brightnessPath || brightnessCommand),
// Assume displayStatus is true if brightness works but status command doesn't (e.g., cage)
displayStatus: (statusPath && statusCommand) || hasBrightness,
displayBrightness: hasBrightness,
keyboardVisibility: keyboard,
audioVolume: audioDevice,
sudoRights: sudo,
Expand Down Expand Up @@ -576,6 +579,10 @@ const getDisplayStatus = () => {
}
break;
}
// If no status command but brightness is supported, assume display is on
if (HARDWARE.support.displayBrightness) {
return "ON";
}
return null;
};

Expand Down Expand Up @@ -608,6 +615,10 @@ const setDisplayStatus = (status, callback = null) => {
case "xset":
execAsyncCommand("xset", ["dpms", "force", status.toLowerCase()], callback);
break;
default:
// No display status command available, just call callback
if (typeof callback === "function") callback(null, null);
break;
}
};

Expand Down