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

Get all events from dbus #269

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

chmduquesne
Copy link
Contributor

Hi there,

autorandr_dbus_monitor is a script to automatically trigger autorandr based on events collected via dbus-monitor. If you have dbus (which is a dependency of systemd), then you have dbus-monitor.

This script will trigger autorandr:

  • every time an external display is plugged/unplugged
  • every time the lid is open/closed
  • every time the system suspends/wakes up

I believe this could replace a lot of code.

Cheers,
Christophe-Marie

@phillipberndt
Copy link
Owner

Neat! Indeed, this should simplify things.

I'm good with installing this by default, but if we do we probably should stop installing the other triggers by default?! And would it make sense to detect whether dbus-monitor is installed? (Though I agree it should be everywhere)

@chmduquesne
Copy link
Contributor Author

I'm good with installing this by default, but if we do we probably should stop installing the other triggers by default?!

Right, I can deactivate them in the Makefile

And would it make sense to detect whether dbus-monitor is installed? (Though I agree it should be everywhere)

We could add a check in autorandr_dbus_monitor and exit if dbus-monitor can't be found. However, I think it is more the job of the packager to make autorandr depend on dbus.

Quick search on that:

  • On debian/ubuntu, the package which provides dbus-monitor is dbus (see dpkg --search /usr/bin/dbus-monitor)
  • Same on archlinux.
  • On redhat/fedora, it would be provided by dbus-tools

@chmduquesne
Copy link
Contributor Author

Ok, after toying around, I understand that the Makefile is not the right place to do that. I guess what we want is to change the default targets in contrib/packaging? In that case I would let you do that, I am not super familiar with that kind of code and I don't want to break something.


suspend_event="type='signal',interface='org.freedesktop.login1.Manager',member='PrepareForSleep'"
lid_event="type='signal',path=/org/freedesktop/UPower,member=PropertiesChanged"
display_event="type='signal',path=/org/freedesktop/ColorManager"
Copy link

@bew bew Dec 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this ColorManager dbus signal comes from colord, which may not be configured/running for barebone WM-only setups.
See: https://github.com/hughsie/colord/blob/master/src/org.freedesktop.ColorManager.xml

Reading https://www.freedesktop.org/software/colord/intro.html, it says that colord can send events for multiple subsystems, including xrandr (which is for monitor changes).
This means that with that trigger as is, you'd run autorandr when you plug a webcam or a printer, and I don't think you want that ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only way I found to detect newly plugged monitors via dbus. If this triggers when a printer is plugged, I don't think it is a big deal: better trigger too often than not often enough.

Anyway, I have been using this script for 3 years with under i3-wm and it works flawlessly for me.

@Nikratio
Copy link

Is this message expected?

dbus-monitor: unable to enable new-style monitoring: org.freedesktop.DBus.Error.AccessDenied: "Rejected send message, 1 matched rules; type="method_call", sender=":1.451" (uid=1000 pid=1194668 comm="dbus-monitor --system --profile type='signal',path") interface="org.freedesktop.DBus.Monitoring" member="BecomeMonitor" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)". Falling back to eavesdropping.

@chmduquesne
Copy link
Contributor Author

chmduquesne commented Jul 18, 2023 via email

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

Successfully merging this pull request may close these issues.

4 participants