Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug related to blight and add a feature for brightness #67

Merged
merged 4 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ bindsym XF86MonBrightnessUp exec swayosd-client --brightness raise
# Brightness lower
bindsym XF86MonBrightnessDown exec swayosd-client --brightness lower

# Brightness raise with custom value
bindsym XF86MonBrightnessUp exec swayosd-client --brightness 10
# Brightness lower with custom value
# Brightness raise with custom value('+' sign needed)
bindsym XF86MonBrightnessUp exec swayosd-client --brightness +10
# Brightness lower with custom value('-' sign needed)
bindsym XF86MonBrightnessDown exec swayosd-client --brightness -10
```

Expand Down
1 change: 1 addition & 0 deletions src/brightness_backend/blight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ impl BrightnessBackendConstructor for Blight {

impl BrightnessBackend for Blight {
fn get_current(&mut self) -> u32 {
self.device.reload();
self.device.current()
}

Expand Down
14 changes: 13 additions & 1 deletion src/global_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,21 @@ pub(crate) fn handle_application_args(
}
"brightness" => {
let value = child.value().str().unwrap_or("");

let coef: i32 = match value.get(..1) {
Some("+") => 1,
Some("-") => -1,
_ => 0,
};

match (value, value.parse::<i8>()) {
// Parse custom step values
(_, Ok(num)) => (ArgTypes::BrightnessSet, Some(num.abs().to_string())),
(_, Ok(num)) => match coef {
1 => (ArgTypes::BrightnessRaise, Some(num.to_string())),
-1 => (ArgTypes::BrightnessLower, Some(num.abs().to_string())),
_ => (ArgTypes::BrightnessSet, Some(num.to_string())),
},

("raise", _) => (ArgTypes::BrightnessRaise, None),
("lower", _) => (ArgTypes::BrightnessLower, None),
(e, _) => {
Expand Down