Skip to content

Commit

Permalink
Disallow setting brightness to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanMiguelBG committed Jan 10, 2022
1 parent bc94c6c commit 79ba0b1
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ lazy_static! {

static ref BRIGHTNESS_STEP: u32 = {
if !OGAGE_PROPERTIES.is_empty() {
match AUTO_DIM_PROPERTIES.get("brightness_step") {
match OGAGE_PROPERTIES.get("brightness_step") {
Some(x) => return x.parse::<u32>().unwrap(),
_ => ()
};
Expand All @@ -404,7 +404,7 @@ lazy_static! {

static ref VOLUME_STEP: u32 = {
if !OGAGE_PROPERTIES.is_empty() {
match AUTO_DIM_PROPERTIES.get("volume_step") {
match OGAGE_PROPERTIES.get("volume_step") {
Some(x) => return x.parse::<u32>().unwrap(),
_ => ()
};
Expand Down Expand Up @@ -575,15 +575,29 @@ fn inc_brightness() {
}

fn dec_brightness() {
set_brightness(get_brightness() - *BRIGHTNESS_STEP);
let mut brightness = get_brightness();
if brightness <= *BRIGHTNESS_STEP {
brightness = 1;
}
else {
brightness = brightness - *BRIGHTNESS_STEP;
}
set_brightness( brightness );
}

fn inc_volume() {
set_volume(get_volume() + *VOLUME_STEP);
}

fn dec_volume() {
set_volume(get_volume() - *VOLUME_STEP);
let mut volume = get_volume();
if volume < *VOLUME_STEP {
volume = 0;
}
else {
volume = volume - *VOLUME_STEP;
}
set_volume(volume);
}

fn mute_volume() {
Expand Down

0 comments on commit 79ba0b1

Please sign in to comment.