Skip to content

Commit

Permalink
When brightness/volume are in their minor value, the first increment …
Browse files Browse the repository at this point in the history
…always is the step value
  • Loading branch information
JuanMiguelBG committed Jan 12, 2022
1 parent 79ba0b1 commit fb4b5b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ogage"
version = "0.8.4"
version = "0.8.5"
authors = ["valadaa48 <valadaa48@gmx.com>"]
edition = "2018"

Expand Down
20 changes: 17 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,14 @@ fn set_volume(volume: u32) {
}

fn inc_brightness() {
set_brightness(get_brightness() + *BRIGHTNESS_STEP);
let mut brightness = get_brightness();
if brightness < *BRIGHTNESS_STEP {
brightness = *BRIGHTNESS_STEP;
}
else {
brightness = brightness + *BRIGHTNESS_STEP;
}
set_brightness(brightness);
}

fn dec_brightness() {
Expand All @@ -582,11 +589,18 @@ fn dec_brightness() {
else {
brightness = brightness - *BRIGHTNESS_STEP;
}
set_brightness( brightness );
set_brightness(brightness);
}

fn inc_volume() {
set_volume(get_volume() + *VOLUME_STEP);
let mut volume = get_volume();
if volume < *VOLUME_STEP {
volume = *VOLUME_STEP;
}
else {
volume = volume + *VOLUME_STEP;
}
set_volume(volume);
}

fn dec_volume() {
Expand Down

0 comments on commit fb4b5b8

Please sign in to comment.