Switching off laptop screen in dual monitor setup on boot

so i installed i3wm varient of garuda linux, and i usually use a monitor as my primary screen connected to my laptop using an hdmi cable. by default garuda displays both screens. with my login tab on laptop (left screen ) and monitor just shows wallpaper (right screen)

i know xrandr is used in i3. and there is an app given too called lxrandr Monitor configuration tool using which i can disable laptop screen and use my monitor as my main screen. but i have to do that after every boot even if i use the application and save the settings after applying it, it just wont work.

so as a work around i made a script with the following content


#!/bin/sh
xrandr --output eDP-1 --off --output DP-1 --off --output HDMI-1 --off --output HDMI-2 --primary --mode 1920x1080 --pos 0x0 --rotate normal

here
eDP-1 is my laptop screen and HDMI-2 is my monitor.
and i added the following line to my .config file in /home/user/.config/i3/


exec_always --no-startup-id $HOME/.config/i3/scripts/screen.sh

and now when i login my laptop screen is disabled and i can use my monitor. so it works but on the logic screen i still can't disable the laptop screen.
i tried addig the same lines in the script to my .xinitrc file. but it doesn't seeems to work.

am i doing something wrong? i just want to make this following command


#!/bin/sh
xrandr --output eDP-1 --off --output DP-1 --off --output HDMI-1 --off --output HDMI-2 --primary --mode 1920x1080 --pos 0x0 --rotate normal

execute before my display manager(greeter/login screen) loads up. where should i put this command.

Read tutorial.

3 Likes