You are not logged in.

#1 2018-09-02 19:10:49

bbaserdem
Member
Registered: 2017-07-27
Posts: 43

How to send signal from udev to a daemon? (monitor hotplug without DE)

I'm trying to figure out how to do the following;

* Udev detects monitor plugin, sends a signal
* A systemd/user daemon picks up the signal
* Daemon runs a command to adjust monitors

I do not like the wiki solution, which involves hard coding the username and path for the scripts in udev rules; which i don't like for various reasons. (I use different WM on different ttys, which makes the method unportable. What not, each Xorg instance should be able to understand that monitors changed and adapt by themselves)

So far, I have the script part done. I'm sure the systemd process is simple, but I haven't written anything more complicated than a simple service. I do not understand sockets and stuff, so if this is the way to go with these kind of stuff; I would love to learn things.

Can anyone help me out with the first part specifically?

Offline

#2 2018-09-02 20:12:43

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,841

Re: How to send signal from udev to a daemon? (monitor hotplug without DE)

Online

#3 2018-09-03 21:51:51

bbaserdem
Member
Registered: 2017-07-27
Posts: 43

Re: How to send signal from udev to a daemon? (monitor hotplug without DE)

Doesn't this script only import XAUTHORITY, USER and DISPLAY variables? I would like to set it up so that the daemon to change screen resolution runs as a user process; and I want to get udev to send a signal to a process agnostically. (Say user1 is on tty1 running DISPLAY=:0 and user2 is on tty2 running DISPLAY=:1 ; they both have their own seperate daemons, they read the signal and they both run their own respective scripts that arranges xrandr)

I think I can use inotify to look for changes in `/sys/class/drm/card0/card*-*/enabled` but would that be a waste of resources? Or run `udevadm monitor`.

Last edited by bbaserdem (2018-09-03 21:52:41)

Offline

#4 2018-09-03 22:12:24

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: How to send signal from udev to a daemon? (monitor hotplug without DE)

This reads as if you want to implement a dbus service which would have a method called by udev which would trigger a dbus signal that a process in each user session would be monitoring that would do something.

Offline

#5 2018-09-04 02:54:08

bbaserdem
Member
Registered: 2017-07-27
Posts: 43

Re: How to send signal from udev to a daemon? (monitor hotplug without DE)

loqs wrote:

This reads as if you want to implement a dbus service which would have a method called by udev which would trigger a dbus signal that a process in each user session would be monitoring that would do something.

I think that would be the way to implement it. I'll read up on it.

Offline

Board footer

Powered by FluxBB