-
Notifications
You must be signed in to change notification settings - Fork 36
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
swayosd --brightness lower doesn't lower brightness #12
Comments
Have you added the udev rules that are in the readme? |
Yes, and they seem to have worked: $ ls -lah /sys/class/backlight/intel_backlight/brightness
.rw-rw-r-- root video 4.0 KB Tue May 9 19:34:29 2023 /sys/class/backlight/intel_backlight/brightness
$ groups
wireshark seat libvirt docker video kvm sudo russell |
I've played around with the brightness code a little bit and this patch seems to work (minus some bounds checks): diff --git a/src/utils.rs b/src/utils.rs
index c8e2198..7dbd7c0 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -8,7 +8,7 @@ use std::{
sync::Mutex,
};
-use blight::{change_bl, err::BlibError, Change, Device, Direction};
+use blight::{err::BlibError, Delay, Device, Direction};
use pulse::volume::Volume;
use pulsectl::controllers::{types::DeviceInfo, DeviceControl, SinkController, SourceController};
@@ -265,25 +265,20 @@ pub fn change_brightness(
.unwrap_or(String::new())
.parse::<u8>()
.unwrap_or(BRIGHTNESS_CHANGE_DELTA) as u16;
- let direction = match change_type {
- BrightnessChangeType::Raise => Direction::Inc,
- BrightnessChangeType::Lower => {
- let device = Device::new(None)?;
- let change = device.calculate_change(brightness_delta, Direction::Dec) as f64;
- let max = device.max() as f64;
- // Limits the lowest brightness to 5%
- if change / max < (brightness_delta as f64) * 0.01 {
- return Ok(Some(device));
- }
- Direction::Dec
- }
+ let mut device = Device::new(None)?;
+ let change = match change_type {
+ BrightnessChangeType::Raise => device.calculate_change(brightness_delta, Direction::Inc),
+ BrightnessChangeType::Lower => device.calculate_change(brightness_delta, Direction::Dec),
};
- match change_bl(brightness_delta, Change::Regular, direction, None) {
+ match device.sweep_write(change, Delay::default()) {
Err(e) => {
eprintln!("Brightness Error: {}", e);
Err(e)
}
- _ => Ok(Some(Device::new(None)?)),
+ _ => {
+ device.reload();
+ Ok(Some(device))
+ }
}
}
A few things that stood out that are kind of weird about the existing code is the recreation of the Anyways, thanks for creating this project it's really nice! |
Sorry for the massive delay, this got lost in my emails... Can you open a PR with these changes? Makes it easier for me to keep track of stuff :) |
Having the same issue on NixOS. Volume control works great, but |
Same issue here on nixos on an intel based machine. Changing it manually with an echo command or brightnessctl works correctly though. Would it be possible to add some debug logs in the program? |
I'll try to get this issue fixed within a couple of days. If I forget, please don't be afraid to ping me :) |
@augustebaum @aacebedo have you installed the udev rules properly? If so, please provide the output of: |
The udev rules were correctly set. I installed the latest version and it seems to work. Will check if it continues to work. |
@ErikReider Hmm did you forget? :3 |
For anyone having this problem on nixos adding the user to video group and manually setting the group and permissions of /sys/class/backlight/*/brightness fixed it for me. users.users.${username} = {
isNormalUser = true;
description = name;
extraGroups = [ "networkmanager" "wheel" "video"];
}; |
I find that NixOS will change file permission everytime we run system.activationScripts = {
# swayosd cannot set brightness issue on NixOS
# see https://github.com/ErikReider/SwayOSD/issues/12#issuecomment-1950581102
fix-brightness-file-permission.text = ''
chgrp video /sys/class/backlight/intel_backlight/brightness
chmod g+w /sys/class/backlight/intel_backlight/brightness
'';
}; |
I discovered setting the udev rules provided by swayosd with adding this to my services.udev.packages = [ pkgs.swayosd ]; I think this fixes the issue of reverting permissions after rebuild :) |
If I am reading the documentation correctly, it seems like swayosd is supposed to be able to change the brightness of my display. However, when I run
swayosd --brightness lower|raise
doesn't make any effect.brillo -A 10
orbrillo -U 10
both work fine, so it doesn't seem to be a permissions issue.Additionally, no OSD is displayed whatsoever, but other OSD's displayed by swayosd work great (volume, caps lock)
Version: swayosd-git from AUR
r18.8ef76c1-1
Compositor: Hyprland (wlroots)
OS: Fully updated Arch Linux as of May 2 11:56 PM MST
swayosd strace
brillo strace
The text was updated successfully, but these errors were encountered: