Thomas Frohwein wrote (2023-11-05 15:37 CET):
> On Wed, Nov 01, 2023 at 09:01:48AM +0100, Stefan Hagen wrote:
> > Omar Polo wrote (2023-10-30 19:46 CET):
> > > On 2023/10/30 14:28:35 +0100, Stefan Hagen <sh+openbsd-ports@codevoid.de> wrote:
> > > > Stefan Hagen wrote (2023-10-30 13:56 CET):
> > > > > I was looking for a solution to invoke autorandr when a monitor
> > > > > gets attached/detached. Unfortunately this emits no event that our
> > > > > hotplugd(8) can catch.
> > > > >
> > > > > Today I stumbled over srandrd, and it's solving this issue in a nice and
> > > > > clean way.
> > > > >
> > > > > $ cat pkg/DESCR
> > > > > -----
> > > > > srandrd is a tool that executes a command on xrandr output change
> > > > > events, i.e. if a monitor is plugged or unplugged. By default srandrd
> > > > > forks to background and exits if the xserver exits.
> > > > > -----
> > > > >
> > > > > You can drop "srandrd some_script.sh" into .xsession and it will run this
> > > > > script when X output changes happen.
> > > > >
> > > > > Inside the script, you have variables available to filter and react to
> > > > > specific events. How that works is described in srandrd(1).
>
> This has an example script, but it's probably very interesting to
> think of using x11/autorandr in there...
That's what I do. There's not much of a script needed.
Simply a wrapper around "autorandr -c" because "srandrd autorandr -c"
wouldn't execute it with the parameter.
> > > > > Comment/OK for import?
> > > >
> > > > I noticed the CFLAGS weren't quite right. I adjusted the patch to
> > > > remove -Os and add the OpenBSD CFLAGS (-O2 -pipe).
> > > >
> > > > Update attached.
> > >
> > > Can't test it right now, but the port looks fine and seems useful.
> > > OK op@ to import
> > >
> > > nits:
> > >
> > > - please remove the stray empty lines at the bottom of DESCR
> > > - maybe I'd drop the "By default srandr forks to the background [...]"
> > > from the DESCR, doesn't seem the place to document such behaviour.
> > > Thankfully, this port ships a manual describing the tool.
> > > - to save a few lines, you could consider using the shiny new DIST_TUPLE
> > > (just a suggestion)
> >
> > Thanks. I removed the nits and added DIST_TUPLE. I haven't used it
> > before, so thanks for suggesting.
> >
> > I'll import after one more OK.
>
> The LICENSE calls itself MIT/X Consortium License in the LICENSE file:
>
> - # IT/X Consortium License
> + # MIT/X Consortium License
Uh, nice catch. Copy pasta...
> > SUBST_VARS = ${WRKSRC}/Makefile
>
> This line doesn't make sense. Look at the result:
>
> $ make show=SUBST_VARS
> /usr/ports/pobj/srandrd-0.6.3/srandrd-0.6.3/Makefile ARCH BASE_PKGPATH FLAVOR_EXT FULLPKGNAME HOMEPAGE LOCALBASE LOCALSTATEDIR MACHINE_ARCH MAINTAINER PREFIX RCDIR SYSCONFDIR TRUEPREFIX X11BASE PKGSTEM
>
> SUBST_VARS is the list of variables that will be substituted. You may
> have meant to do what SUBST_CMD does, but as it isn't in your Makefile,
> you probably don't even need that. I recommend reading SUBST_* in
> bsd.port.mk(5).
>
> Regarding the patch, I would lean towards just adding CFLAGS/LDFLAGS in
> there and then adding the likes of '-I${X11BASE}/include' and
> '-L${X11BASE}/lib' to the port Makefile with e.g.
>
> CFLAGS += -I${X11BASE}/include
> LDFLAGS += -L${X11BASE}/lib
I mixed this up. This should have been:
post-patch:
${SUBST_CMD} ${WRKSRC}/Makefile
To replace X11BASE in the Makefile.
But I like your solution better and took it over. New version attached.
> This makes it easier to amend in the future if the need arises.
>
> Lastly, as this is a demon, should this come with an rc file and a
> dedicated user, so that it can be run on system startup? With X11
> applications, this makes it a bit weirder to launch before .xsession.
> Not sure if that's worth a consideration, but I'm thinking of it
> because of some contortions that I've done with sensorsd(8) and
> something like in the sensorsd script:
>
> su -l thfr -c "env DISPLAY=:0 $command"
srandrd needs to be started while X is running. If it can't connect to
X, it will just print an error and quit. So a traditional daemon won't
work.
I got it to work from xenodm/Xsetup_0. But when the switch to the
user happens, the login session is closed and srandrd will quit.
So you still need to add it to .xsession as well.
If you find a better solution, I'm all ears.
If you want to switch from sensorsd, you could use the "srandrd list"
output as check. This doesn't daemonize. But I wouldn't want to wait
for the next sensorsd check when I plug a screen in. The srandrd daemon
switches immediately.
Thanks for the feedback!
- Stefan
No comments:
Post a Comment