From d20393e077b8d97b18f4a224ddcb20caf6dac23b Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 10 Sep 2025 15:57:26 +0200 Subject: ... --- overlays/swayosd/exponential.patch | 57 -------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 overlays/swayosd/exponential.patch (limited to 'overlays/swayosd/exponential.patch') diff --git a/overlays/swayosd/exponential.patch b/overlays/swayosd/exponential.patch deleted file mode 100644 index eb90d739..00000000 --- a/overlays/swayosd/exponential.patch +++ /dev/null @@ -1,57 +0,0 @@ -diff --git a/src/brightness_backend/brightnessctl.rs b/src/brightness_backend/brightnessctl.rs -index ccb0e11..740fdb6 100644 ---- a/src/brightness_backend/brightnessctl.rs -+++ b/src/brightness_backend/brightnessctl.rs -@@ -107,10 +107,21 @@ impl VirtualDevice { - } - } - -- fn set_percent(&mut self, mut val: u32) -> anyhow::Result<()> { -- val = val.clamp(0, 100); -- self.current = self.max.map(|max| val * max / 100); -- let _: String = self.run(("set", &*format!("{val}%")))?; -+ fn val_to_percent(&mut self, val: u32) -> u32 { -+ return ((val as f64 / self.get_max() as f64).powf(0.25) * 100_f64).round() as u32; -+ } -+ fn percent_to_val(&mut self, perc: u32) -> u32 { -+ return ((perc as f64 / 100_f64).powf(4_f64) * self.get_max() as f64).round() as u32; -+ } -+ -+ fn set_percent(&mut self, val: u32) -> anyhow::Result<()> { -+ let new = self.percent_to_val(val); -+ self.set_val(new) -+ } -+ fn set_val(&mut self, val: u32) -> anyhow::Result<()> { -+ let curr = val.clamp(0, self.get_max()); -+ self.current = Some(curr); -+ let _: String = self.run(("set", &*format!("{curr}")))?; - Ok(()) - } - } -@@ -134,20 +145,18 @@ impl BrightnessBackend for BrightnessCtl { - - fn lower(&mut self, by: u32) -> anyhow::Result<()> { - let curr = self.get_current(); -- let max = self.get_max(); -- -- let curr = curr * 100 / max; -+ let mut new = self.device.val_to_percent(curr).saturating_sub(by); -+ new = self.device.percent_to_val(new).min(curr.saturating_sub(1)); - -- self.device.set_percent(curr.saturating_sub(by)) -+ self.device.set_val(new) - } - - fn raise(&mut self, by: u32) -> anyhow::Result<()> { - let curr = self.get_current(); -- let max = self.get_max(); -- -- let curr = curr * 100 / max; -+ let mut new = self.device.val_to_percent(curr) + by; -+ new = self.device.percent_to_val(new).max(curr + 1); - -- self.device.set_percent(curr + by) -+ self.device.set_val(new) - } - - fn set(&mut self, val: u32) -> anyhow::Result<()> { -- cgit v1.2.3