I recently began messing with Desktop Entries in order to run some scripts at Gnome startup.

I've read through some freedesktop documentation, as well as this post on creating a startup script. I currently have a desktop entry working on startup, but it is not behaving in the way I was made to understand it should.

Some system info: this is CentOS7 running on VirtualBox in Windows

This is my desktop entry:

[Desktop Entry]
GenericName=Resolution Fixer
Comment=Changes resolution to 1920x1080
Exec=bash /home/detroitwilly/scripts/fixres.sh

The script being executed uses xrandr to add a new resolution mode and apply it to my virtual display.

Now, the first line in the script has the shebang #!/bin/bash. My understanding is that if the shebang is on the first line of the script, I shouldn't need to specify bash in the Exec= line of the desktop entry. Note that if I remove bash from the Exec= line, the application will not run.

I've also verified that /bin is in my $PATH variable, so I should automatically have access to bash.

Any ideas as to why i need to prepend the path to my script with bash?


  • I am confused, are these comments to the answer, bellow? (if so then it is better to attach them to the answer) or to a deleted comment? – ctrl-alt-delor Jan 10 '19 at 20:06
  • @ctrl-alt-delor the answer below was submitted after the comments above were posted – detroitwilly Jan 10 '19 at 20:31
  • So what are they commenting about, they make no sense without a context. It may be better to remove them. – ctrl-alt-delor Jan 11 '19 at 7:46

There are two portions required to execute a BASH script directly:

  1. the shebang
  2. the executable bit

The shebang should look as follows.

#!/usr/bin/env bash

(Using env is a best practice. It can also be written as the full path, e.g. #!/bin/bash.)

Then set the executable bit as follows.

chmod +x /home/detroitwilly/scripts/fixres.sh
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.