import { useEffect } from "react"; import { SettingsPageHeader } from "@components/SettingsPageheader"; import { SettingsItem } from "@routes/devices.$id.settings"; import { BacklightSettings, useSettingsStore } from "@/hooks/stores"; import { useJsonRpc } from "@/hooks/useJsonRpc"; import { SelectMenuBasic } from "@components/SelectMenuBasic"; import { UsbDeviceSetting } from "@components/UsbDeviceSetting"; import notifications from "../notifications"; import { UsbInfoSetting } from "../components/UsbInfoSetting"; import { FeatureFlag } from "../components/FeatureFlag"; export default function SettingsHardwareRoute() { const [send] = useJsonRpc(); const settings = useSettingsStore(); const setDisplayRotation = useSettingsStore(state => state.setDisplayRotation); const handleDisplayRotationChange = (rotation: string) => { setDisplayRotation(rotation); handleDisplayRotationSave(); }; const handleDisplayRotationSave = () => { send("setDisplayRotation", { params: { rotation: settings.displayRotation } }, resp => { if ("error" in resp) { notifications.error( `Failed to set display orientation: ${resp.error.data || "Unknown error"}`, ); return; } notifications.success("Display orientation updated successfully"); }); }; const setBacklightSettings = useSettingsStore(state => state.setBacklightSettings); const handleBacklightSettingsChange = (settings: BacklightSettings) => { // If the user has set the display to dim after it turns off, set the dim_after // value to never. if (settings.dim_after > settings.off_after && settings.off_after != 0) { settings.dim_after = 0; } setBacklightSettings(settings); handleBacklightSettingsSave(); }; const handleBacklightSettingsSave = () => { send("setBacklightSettings", { params: settings.backlightSettings }, resp => { if ("error" in resp) { notifications.error( `Failed to set backlight settings: ${resp.error.data || "Unknown error"}`, ); return; } notifications.success("Backlight settings updated successfully"); }); }; useEffect(() => { send("getBacklightSettings", {}, resp => { if ("error" in resp) { return notifications.error( `Failed to get backlight settings: ${resp.error.data || "Unknown error"}`, ); } const result = resp.result as BacklightSettings; setBacklightSettings(result); }); }, [send, setBacklightSettings]); return (
The display will wake up when the connection state changes, or when touched.