2

I want to run a program at a certain condition.

So I have created a .desktop file and put it in /etc/xdg/autostart.

the contents of the desktop file are:

[Desktop Entry]
Type=Application
Name=System Tray
Exec=/opt/testApp
OnlyShowIn=GNOME;Unity;
NoDisplay=true
AutostartCondition=GSettings com.test testVal
X-GNOME-AutoRestart=true

And I have made a custom key with gsettings for a condition and compiled the schemas.

I confirmed whether the schema works, and it does.

gsettings set com.test testVal true
gsettings get com.test testVal

I typed the command above, and got "true".

However the Application I registered as Autostart doesn't run.

My questions are:

  1. Do I have to restart or logoff for a test?
  2. Is there a way to test autostart without reboot or logoff?
3

1 Answer 1

1

Can I answer 5 years later?

I was looking for a way to achieve the same and stumbled upon your question.
Here is how I did it:

  1. Open Startup Applications
  2. Select the App you want to conditionally open and click on edit
  3. Add your condition to the command field

In my case, I wanted some apps to only automatically start on weekdays, so my command field went from this:

/usr/bin/teams %U

to this:

if [[ $(date +%u) -lt 6 ]]; then /usr/bin/teams %U; fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .