Article 562HM How to execute a command when GUI is loaded?

How to execute a command when GUI is loaded?

by
ddenial
from LinuxQuestions.org on (#562HM)
Hello All

How do you run a command/script after the Linux is booted and GUI is loaded?

I have this script that should run once after every boot when GUI is loaded
Code:$ cat asz.sh
#!/bin/bash
SCREEN=$(xrandr | grep primary | awk '{print $1}')
xrandr --output $SCREEN --autoI tried in crontab with @reboot, but doesn't work as the GUI has not yet loaded and the 'Virtual-?' number is not yet assigned.

I put in /etc/bash.bashrc, but nothing happens. But it will execute as soon as I open terminal window. I don't want this to happen.

So where do I put the script which makes it executed after the GUI is loaded?

The distro is Kali Linux XFCE in KVM as a virtual guest.

Thankslatest?d=yIl2AUoC8zA latest?i=atp4sm7rg5s:WM0hfAv7pqE:F7zBnMy latest?i=atp4sm7rg5s:WM0hfAv7pqE:V_sGLiP latest?d=qj6IDK7rITs latest?i=atp4sm7rg5s:WM0hfAv7pqE:gIN9vFwatp4sm7rg5s
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments