You are not logged in.
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
fiAnd 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
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.
Offline
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
The command that gets exec'd in your ~/.xinitrc has to be the last line.
Nothing after it will ever be executed.
Offline
Great, thank you!
Offline