Setting up a “base station” for Leveno ideapad, with 24in monitor. Wanted a way to have i3 default to using only the HDMI-out when it is connected to that monitor, instead of having to open arandr each time, as well as fixing the Wallpaper each time.
The Leveno does connect to HDMI if present at Boot, but defaults to “duplicate screens”
Added this to my ~/.i3/config:
exec --no-startup-id /home/[user]/.screenlayout/setdisplay.sh
This needs to run before the line that runs nitrogen – restore, at least on my system, changing monitor configuration results in odd wallpaper effects, requiring nitrogen --restore. My ~/.config/nitrogen/bg-saved.cfg contains the correct image for both screens. Apparently there are no ill effects to nitrogen’s effort to restore 2 screens when one is NOT connected.
setdisplay.sh: #!/usr/bin/bash # # Set preferred monitor config # Designed for a Laptop with only one HDMI Port # hdmi_ex=`xrandr --current | grep 'HDMI1 connected' | wc -l` [ $hdmi_ex -eq 1 ] && $HOME/.screenlayout/LG24-Only.sh
To detect if the HDMI monitor is plugged in, if not, does nothing.
LG24-Only.sh is simply the xrandr script generated by arandr.
Works on startup as intended. Next I plan to add a utility to switch to other options, such as BOTH internal and external screens, or just to internal. I do not switch monitor set ups on the fly enough to bother with writing something to detect monitor changes and respond automatically (as far as I researched, one would need to add a script of service for that, not sure I need that level of magic…)
I am not new to programming but am new to bash, and welcome any input about my code or tactics… (I know this would have to have a good bit more in it to be portable…)