Search code examples
linuxi3xrandr

how to auto run script after applying arandr setting?


i have this script that automatically change my display setting at home

#!/bin/sh
xrandr \
--output eDP1 --primary --mode 1920x1080 --rotate normal --pos 1836x0 \
--output DP1 --off \
--output DP2 --scale 1.35x1.35 --mode 1360x768 --pos 0x22 --rotate normal \
--output HDMI1 --off \
--output HDMI2 --off \
--output VIRTUAL1 --off \
&& nitrogen --restore && ~/.config/polybar/launch >/dev/null 2>&1

it works great because i don't have to worry about its resolution. but when i'm connecting to a new display i have to worry about its resolution and i have to use arandr. the problem is when i'm done with arandr i have to manually execute this line nitrogen --restore && ~/.config/polybar/launch >/dev/null 2>&1 to fix my wallpaper and polybar. so can i make some kind of udev rule that automatically run that line when i'm applying display setting from arandr?


Solution

  • well, apparently arandr have Layout>Properties that have this

    #!/bin/sh
    %(xrandr)s
    

    but you can't edit it and it'll be the next feature https://github.com/chrysn/arandr