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

headphones_indicator=true doesn't work #2121

Open
miffi opened this issue Dec 27, 2024 · 1 comment
Open

headphones_indicator=true doesn't work #2121

miffi opened this issue Dec 27, 2024 · 1 comment

Comments

@miffi
Copy link

miffi commented Dec 27, 2024

Version:

$ i3status-rs --version
i3status-rs 0.33.2 (commit be37f6719 2024-11-09)

I have the same problem as in #2047. I checked NEWS.md and it says

  • Sound: correctly show headphones icon when headphones_indicator = true and headphones are connected.

so I assume that pr is in 0.33.2. The version update didn't seem to fix it.

I'm using pipewire if that helps.

Reproduction config

[icons]
icons = "awesome5" # or whatever icon font

[[block]]
block = "sound"
headphones_indicator = true

Output (I changed the volume up and down a bit and also disconnected and reconnected my headphones):

$ RUST_LOG=sound=debug ~/.local/share/cargo/bin/i3status-rs
{"version": 1, "click_events": true}
[
[2024-12-27T17:15:13Z DEBUG sound] form_factor = None active_port = None
[],
[],
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":" 0% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
[2024-12-27T17:15:13Z DEBUG sound] form_factor = None active_port = None
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":" 0% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
[2024-12-27T17:15:13Z DEBUG sound] form_factor = Some("internal") active_port = Some("analog-output-headphones")
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"25% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
[2024-12-27T17:15:27Z DEBUG sound] form_factor = Some("internal") active_port = Some("analog-output-headphones")
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"25% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
[2024-12-27T17:15:27Z DEBUG sound] form_factor = Some("internal") active_port = Some("analog-output-headphones")
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"25% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
[2024-12-27T17:15:30Z DEBUG sound] form_factor = Some("internal") active_port = Some("analog-output-speaker")
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"60% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
[2024-12-27T17:15:30Z DEBUG sound] form_factor = Some("internal") active_port = Some("analog-output-speaker")
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"60% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
[2024-12-27T17:15:32Z DEBUG sound] form_factor = Some("internal") active_port = Some("analog-output-speaker")
[2024-12-27T17:15:32Z DEBUG sound] form_factor = Some("internal") active_port = Some("analog-output-speaker")
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"60% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"60% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
[2024-12-27T17:15:33Z DEBUG sound] form_factor = Some("internal") active_port = Some("analog-output-headphones")
[2024-12-27T17:15:33Z DEBUG sound] form_factor = Some("internal") active_port = Some("analog-output-headphones")
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"25% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
[{"full_text":"|","color":"#A9A9A9FF","background":"#000000FF","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"  ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"},{"full_text":"25% ","color":"#93A1A1FF","background":"#000000FF","name":"0","instance":"0:","separator":false,"separator_block_width":0,"markup":"pango"}],
@bim9262
Copy link
Collaborator

bim9262 commented Dec 31, 2024

@MaxVerevkin any reason not to check to see if the active_port does contain "headphones" even if form_factor is set to a non headphone value?

diff --git a/src/blocks/sound.rs b/src/blocks/sound.rs
index e7d9bbe82..22c3303ad 100644
--- a/src/blocks/sound.rs
+++ b/src/blocks/sound.rs
@@ -156,13 +156,8 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
                 // form_factor's possible values are listed at:
                 // https://docs.rs/libpulse-binding/2.25.0/libpulse_binding/proplist/properties/constant.DEVICE_FORM_FACTOR.html
                 Some("headset") | Some("headphone") | Some("hands-free") | Some("portable") => true,
-                // Per discussion at
-                // https://github.com/greshake/i3status-rust/pull/1363#issuecomment-1046095869,
-                // some sinks may not have the form_factor property, so we should fall back to the
-                // active_port if that property is not present.
-                None => active_port.is_some_and(|p| p.to_lowercase().contains("headphones")),
-                // form_factor is present and is some non-headphone value
-                _ => false,
+                // We should fall back to checking to see if the active_port contains "headphones".
+                _ => active_port.is_some_and(|p| p.to_lowercase().contains("headphones")),
             };
             if headphones {
                 return "headphones";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants