💾 Archived View for sdf.org › tyjak › 220413-external-monitor-with-laptop.gmi captured on 2023-07-10 at 14:07:17. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-04-28)
-=-=-=-=-=-=-
I installed an external monitor connected to my laptop. Since I'm on archlinux I needed to configure almost two things: screen and keyboards.
I wanted that screen stay poweron when I close the laptop and switch to the correct layout for the external keyboard (pure key pro).
One easy way is to install acpi and setup script in `/etc/acpi/handler.sh`.
One major issue I faced was that randr need `.Xauthority` of the current session user to work and acpi script handle.sh run as root. So I added this adapted script I originally found on internet :
---
function GetXuser() { #Guess the user logged on server $1 w -huf|grep " $1 "|cut -d " " -f 1|head -n 1 } export DISPLAY=:0 export USER=$(GetXuser $DISPLAY) export XAUTHORITY=/home/$(GetXuser $DISPLAY)/.Xauthority
---
Here piece of code I used to set screen and keyboard on lid events:
---
button/lid) case "$3" in close) logger 'LID closed' if [ $(ls /sys/class/drm/*/status | xargs cat | grep -c "^connected") -gt 1 ] then logger 'More than one screen' logger "$DISPLAY - $XAUTHORITY" export WINIT_X11_SCALE_FACTOR=1.33 xrandr --output eDP1 --off --output HDMI1 --auto --mode 1920x1080 --set "Broadcast RGB" "Full" sudo -H -u $USER bash -c "~/share/bin/switch-keyboard-layout.sh" else logger 'One screen' systemctl suspend fi ;; open) logger 'LID opened' if [ $(ls /sys/class/drm/*/status | xargs cat | grep -c "^connected") -gt 1 ] then logger 'More than one screen' xrandr --output HDMI1 --auto --mode 1920x1080 --set "Broadcast RGB" "Full" --primary --output eDP1 --mode 1440x900 --left-of HDMI1 sudo -H -u $USER bash -c "~/share/bin/switch-keyboard-layout.sh" else logger 'One screen' xrandr --output eDP1 --mode 1440x900 sudo -H -u $USER bash -c "~/share/bin/switch-keyboard-layout.sh" #systemctl suspend fi ;;
---
Keyboard part is not tested yet, still a WIP and I will update this entry as soon as I progress !