You are not logged in.
Hi guys,
I've just installed Arch a couple of days ago alongside i3wm and I'm enjoying it a lot. One thing though that I can't really set up after countless hours is an automatic monitor configuration when I connect my HDMI port. I would really like to know what is wrong with my setup before I move to a different solution.
So pretty much the setup is pretty straightforward. I've created a udev rule:
KERNEL=="card0", SUBSYSTEM=="drm", ACTION=="change" RUN+="su bozanicjosip -c usr/local/bin/hotplug-monitor"The script that I'm running is
export DISPLAY=:0
export XAUTHORITY=/home/bozanicjosip/.Xauthority
hdmi_status="$(cat /sys/class/drm/card0-HDMI-A-2/status)"
/usr/bin/notify-send --urgency low -t 5000 "Graphics Update" "HDMI plugged in"
function connect(){
/usr/bin/xrandr --output HDMI2 --auto --right-of eDP1
/usr/bin/notify-send --urgency low -t 5000 "Graphics Update" "HDMI plugged in"
}
function disconnect(){
/usr/bin/xrandr --output HDMI2 --off
}
function default(){
/usr/bin/xrandr --auto
}
if [ "${hdmi_status}" = connected ]; then
connect
elif [ "${hdmi_status}" = disconnected ]; then
disconnect
else default
fiSo basically when I run the script it works, but when it's triggered through udev rule It works only when the monitor is disconnected and not when it's connected. Also the notification doesn't work. One indication where the problem could be is also that the same thing happens when I run it with sudo.
I was logging the script at one point and what I noticed is that the status was connected, but when I would call the xrandr from the script my HDMI2 port would say disconnected. Any ideas what I'm doing wrong here?
Thanks
Offline