You are not logged in.

#1 2022-09-04 10:56:38

patresko
Member
Registered: 2018-10-19
Posts: 24

[SOLVED] How to run x-on-resize in the background?

I want my active monitor to change automatically when I plug/unplug the external monitor.

For toggling between monitors I use this script (found on wiki):

#!/bin/sh
intern=eDP1
extern=DP1-3

if xrandr | grep "$extern disconnected"; then
    xrandr --output "$extern" --off --output "$intern" --auto
else
    xrandr --output "$intern" --off --output "$extern" --auto
fi

And for listening to a change of screen configuration, I use x-on-resize.

This setup works as expected, but I want to run the x-on-resize on the background (and have it start on start-up).

Should I write a systemd daemon, or include the x-on-resize program in my .xinitrc?

Or something else altogether?

Last edited by patresko (2022-09-04 12:40:39)

Offline

#2 2022-09-04 11:53:12

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

Re: [SOLVED] How to run x-on-resize in the background?

This very much depends on how you start the session, but if xinitrc is invoked, I'd personally not jump through the hoops of a systemd user service and just run x-on-resize from the xinitrc.

Online

#3 2022-09-04 12:40:23

patresko
Member
Registered: 2018-10-19
Posts: 24

Re: [SOLVED] How to run x-on-resize in the background?

For some reason it didn't work when I ran it from xinitrc:

# Start i3
exec i3
# Start x-on-resize
x-on-resize -c /path/to/script/toggle_monitor.sh 

but it works from i3 config:

 exec --no-startup-id picom
exec --no-startup-id x-on-resize -c  /path/to/script/toggle_monitor.sh 

Therefore I think this solves the issue.

Any clue tho, why the xinitrc version doesn't work?

Last edited by patresko (2022-09-04 12:41:43)

Offline

#4 2022-09-04 12:45:44

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] How to run x-on-resize in the background?

The command that gets exec'd in your ~/.xinitrc has to be the last line.
Nothing after it will ever be executed.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#5 2022-09-04 12:51:05

patresko
Member
Registered: 2018-10-19
Posts: 24

Re: [SOLVED] How to run x-on-resize in the background?

Great, thank you!

Offline

Board footer

Powered by FluxBB