File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,11 @@ use input::event::{
1010} ;
1111use crate :: TIMEOUT_MS ;
1212
13+ const BRIGHTNESS_DIM_TIMEOUT : i32 = TIMEOUT_MS * 1 ; // should be a multiple of TIMEOUT_MS
14+ const BRIGHTNESS_OFF_TIMEOUT : i32 = TIMEOUT_MS * 2 ; // should be a multiple of TIMEOUT_MS
15+ const DEFAULT_BRIGHTNESS : u32 = 128 ;
16+ const DIMMED_BRIGHTNESS : u32 = 1 ;
17+
1318fn read_attr ( path : & Path , attr : & str ) -> u32 {
1419 fs:: read_to_string ( path. join ( attr) )
1520 . expect ( & format ! ( "Failed to read {attr}" ) )
@@ -74,10 +79,10 @@ impl BacklightManager {
7479 let since_last_active = ( Instant :: now ( ) - self . last_active ) . as_millis ( ) as u64 ;
7580 let new_bl = if self . lid_state == SwitchState :: On {
7681 0
77- } else if since_last_active < TIMEOUT_MS as u64 {
78- 128
79- } else if since_last_active < TIMEOUT_MS as u64 * 2 {
80- 1
82+ } else if since_last_active < BRIGHTNESS_DIM_TIMEOUT as u64 {
83+ DEFAULT_BRIGHTNESS
84+ } else if since_last_active < BRIGHTNESS_OFF_TIMEOUT as u64 {
85+ DIMMED_BRIGHTNESS
8186 } else {
8287 0
8388 } ;
You can’t perform that action at this time.
0 commit comments