[UPDATE]: I have tried both proposed solutions but they were both not working. First I have tried the solution of Fiximan. I have created the monitor-check.service in /etc/systemd/system and tried to execute the /bin/bash /home/user/monitor-check.service and it successfully changed the laptop resolution to 3440x1440. Then I have tried to execute: sudo systemctl start monitor-check.sh and this is the status message:
monitor-check.service - Service to check for external monitors during boot.
Loaded: loaded (/etc/systemd/system/monitor-check.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-07-09 19:27:17 CEST; 5s ago
Process: 4177 ExecStart=/bin/bash /home/user/Documents/scripts/display_setup.sh (code=exited, status=1/FAILURE)
Main PID: 4177 (code=exited, status=1/FAILURE)
Jul 09 19:27:17 acer systemd[1]: Started Service to check for external monitors during boot..
Jul 09 19:27:17 acer bash[4177]: Can't open display
Jul 09 19:27:17 acer bash[4177]: Can't open display
Jul 09 19:27:17 acer systemd[1]: monitor-check.service: Main process exited, code=exited, status=1/FAILURE
Jul 09 19:27:17 acer systemd[1]: monitor-check.service: Failed with result 'exit-code'.
I have tried to add the environment variable to the Xauthority by adding:
Environment=XAUTHORITY=/run/user/1000/gdm/Xauthority to the Service section but it didn't help.
I have also tried the proposed solution by Praveen but it didn't work either. In fact, I have added my script to /etc/profile.d directory but it didn't execute the script so my resolution was still the old one.
In conclusion, the only two solutions which worked was to add the script to the ~/.profile or to add it manually to the Startup Applications but both solutions change the resolution and switches off the internal laptop display after logon to the system.