Hello. I want to write an Udev rule to change my laptops’s EasyEffects profile whenever I connect a speaker set or headphones to the 3.5mm jack. The concept is relatively simple: when I connect something to the jack, I want it to fire a script that will set this Dconf setting:

gsettings set com.github.wwmm.easyeffects last-loaded-output-preset 'None'

And when I unplug the speakers/headphones, it’ll set this:

gsettings set com.github.wwmm.easyeffects last-loaded-output-preset 'Laptop'

(“None” and “Laptop” are EasyEffects profiles).

Unfortunately, I haven’t been able to find useful info, since almost all of the results I found online refer to Bluetooth or USB devices. I checked within /sys/class/sound/ and /dev/ for a file where I could query the status of the jack (something like “connected”/“disconnected”) but I can’t find something relevant. I have a similar rule that changes GNOME’s font scaling when I plug my HDMI display, and it does that by running this script:

function monitorConnected () {
  statuses=$(cat /sys/class/drm/card1-HDMI-A-{1,2,3,4}/status 2>/dev/null)    
  for status in ${statuses[@]}                                                
  do                                                                          
        [[ ${status} == "connected" ]] && return 0                              
  done                                                                        
  return 1                                                                    
  }

So I thought that I could do something similar for the 3.5mm jack. Or maybe there’s another method? Any hints? My OS is Fedora 41 and I’m using Pipewire, btw.

4 points

Doesn’t easyeffects preset autoloading already offer that? I have auto-mute off since I leave the headphones plugged in all the time, but switching output manually triggers my preset change.

permalink
report
reply
1 point

For some reason it didn’t work for me. I added my desired profiles to the EasyEffects “Presets Autoloading” window, but when I plug/unplug my headphones it doesn’t load the desired profile. I’ll try to check in another computer if it works there. Maybe I have some misconfiguration. Thanks! :)

permalink
report
parent
reply
1 point

It is a bit odd to set up since the selector only shows the device and not the output. You might have to plug the headphones in before you choose and set the preset for headphone output. This is what mine looks like.

permalink
report
parent
reply
5 points

I remember doing this with dbus but I can’t find that set-up anymore. This stackoverflow answer looks a bit more elegant: https://unix.stackexchange.com/a/128007/37570

A little script could run your command when matching the jack/headphone events from acpi_listen.

permalink
report
reply
1 point

Cool, I need to check this. Thanks!

permalink
report
parent
reply

Linux Questions

!linuxquestions@lemmy.zip

Create post

Linux questions Rules (in addition of the Lemmy.zip rules)

  • stay on topic
  • be nice (no name calling)
  • do not post long blocks of text such as logs
  • do not delete your posts
  • only post questions (no information posts)

Tips for giving and receiving help

  • be as clear and specific
  • say thank you if a solution works
  • verify your solutions before posting them as facts.

Any rule violations will result in disciplinary actions

Community stats

  • 62

    Monthly active users

  • 76

    Posts

  • 211

    Comments

Community moderators