# Need some help creating a .desktop file for a shell script

**URL:** <https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565>\
**Category:** Newbie\
**Created:** [April 29, 2022, 9:11am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565 "2022-04-29T09:11:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Celty](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/celty/32/34777_2.png) [@Celty](https://forum.endeavouros.com/u/Celty)\
**Post date:** [April 29, 2022, 9:11am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/1 "2022-04-29T09:11:48Z")

</div>

I need some help creating a functional .desktop file for a bash script.

The content of the script is

```auto
bash -c "{ leagueoflegends run /opt/wine-lol/bin/wine $HOME/.local/share/leagueoflegends/launchhelper/lhinjector.exe; } & leagueoflegends start"

```

I have tried

```auto
[Desktop Entry]
Type=Application
Name=League of Legends
Comment=League of Legends helper script
Path=/home/uname/.local/share/leagueoflegends/launchhelper/
Exec=lol
Icon=leagueoflegends
Terminal=false
Categories=Game;Wine;
StartupWMClass=leagueclientux.exe

```

```auto
[Desktop Entry]
Type=Application
Name=League of Legends
Comment=League of Legends helper script
Exec=bash -c "{ leagueoflegends run /opt/wine-lol/bin/wine $HOME/.local/share/leagueoflegends/launchhelper/lhinjector.exe; } & leagueoflegends start"
Icon=leagueoflegends
Terminal=false
Actions=kill;winecfg;
Categories=Game;Wine;
StartupWMClass=leagueclientux.exe

```

I have also tried

- replacing the exec line with `kitty -e bash -c [...]`
- replacing the exec line with `sh -c [...]`

None of these work. Running the script itself works. Running the content of the script works. The .desktop file does not work.

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2022, 9:52am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/2 "2022-04-29T09:52:12Z")

</div>

Try using full paths. `/usr/bin/bash` and the full path to `leagueoflegends`

---

<div class="post-metadata">

**Author:** ![Celty](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/celty/32/34777_2.png) [@Celty](https://forum.endeavouros.com/u/Celty)\
**Post date:** [April 29, 2022, 10:08am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/3 "2022-04-29T10:08:57Z")

</div>

> [@dalto](#):
>
> Try using full paths. `/usr/bin/bash` and the full path to `leagueoflegends`

No luck I’m afraid.

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2022, 10:11am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/4 "2022-04-29T10:11:16Z")

</div>

It might be easier to just create an actual script file and call the script file from the `Exec` in the desktop.

Make sure the script is set to be executable.

---

<div class="post-metadata">

**Author:** ![Celty](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/celty/32/34777_2.png) [@Celty](https://forum.endeavouros.com/u/Celty)\
**Post date:** [April 29, 2022, 10:27am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/6 "2022-04-29T10:27:06Z")

</div>

> [@dalto](#):
>
> It might be easier to just create an actual script file and call the script file from the `Exec` in the desktop.
> 
> Make sure the script is set to be executable.

This was my original approach (if I understood you correctly), e.g:

```auto
[Desktop Entry]
Type=Application
Name=League of Legends
Comment=League of Legends helper script
Exec=/home/uname/.local/bin/scriptname
Icon=leagueoflegends
Terminal=false

```

I don’t know whether I’m meant to put bash in front of it when calling it in the exec line but neither seem to work.

---

<div class="post-metadata">

**Author:** ![freebird54](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/freebird54/32/83106_2.png) [@freebird54](https://forum.endeavouros.com/u/freebird54)\
**Post date:** [April 29, 2022, 10:35am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/7 "2022-04-29T10:35:46Z")

</div>

Just a silly thought - were you expecting uname to be replaced with your username? Even using _ **Exec=~/.local/bin/scriptname** _ would be better, but simpler is to just use your name directly. And, to reiterate - are you sure the script is executable? I didn’t need to be for the bash -c construction, but otherwise…

If this is too obvious for words, just keep in mind it is the sort of thing _ **I** _ have done in the past 😁

---

<div class="post-metadata">

**Author:** ![Celty](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/celty/32/34777_2.png) [@Celty](https://forum.endeavouros.com/u/Celty)\
**Post date:** [April 29, 2022, 10:41am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/8 "2022-04-29T10:41:31Z")

</div>

> [@freebird54](#):
>
> Just a silly thought - were you expecting uname to be replaced with your username? Even using _ **Exec=~/.local/bin/scriptname** _ would be better, but simpler is to just use your name directly. And, to reiterate - are you sure the script is executable? I didn’t need to be for the bash -c construction, but otherwise…
> 
> If this is too obvious for words, just keep in mind it is the sort of thing _ **I** _ have done in the past 😁

No I edited the path for the forum post. It does have execute permission and it works in a terminal.

```auto
-rwxr-xr-x 1 uname uname 145 Apr 29 04:37 /home/uname/.local/bin/lol

```

---

<div class="post-metadata">

**Author:** ![freebird54](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/freebird54/32/83106_2.png) [@freebird54](https://forum.endeavouros.com/u/freebird54)\
**Post date:** [April 29, 2022, 11:00am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/9 "2022-04-29T11:00:54Z")

</div>

I was pretty sure it wasn’t needed! Can’t think why it isn’t working though - I have several such things going, and never have any trouble getting them to run. Full paths are all you need…

Good luck!

---

<div class="post-metadata">

**Author:** ![Celty](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/celty/32/34777_2.png) [@Celty](https://forum.endeavouros.com/u/Celty)\
**Post date:** [April 29, 2022, 12:57pm UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/10 "2022-04-29T12:57:54Z")

</div>

Thanks.

I’m wondering what the difference is between the methods that work and those that don’t.

- calling the script in sxhkd works
- calling the script in Hyprwm config works
- calling the script in a terminal emulator works
- calling the script via rofi spawned from a terminal emulator works

- calling the script in a desktop file fails
- calling the script in Awesomewm config fails
- calling the script from rofi running via Awesomewm fails

---

<div class="post-metadata">

**Author:** ![petsam](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/petsam/32/41308_2.png) [@petsam](https://forum.endeavouros.com/u/petsam)\
**Post date:** [April 29, 2022, 8:16pm UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/11 "2022-04-29T20:16:49Z")

</div>

> [@Celty](#):
>
> `Terminal=false`

Have you tried with `Terminal=true` ?  
Read the [specs](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.1.html) and maybe you find what it needs.

---

<div class="post-metadata">

**Author:** ![ishaan2479](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/i/41988e/32.png) [@ishaan2479](https://forum.endeavouros.com/u/ishaan2479)\
**Post date:** [April 29, 2022, 8:46pm UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/12 "2022-04-29T20:46:47Z")

</div>

> [@Celty](#):
>
> calling the script in a terminal emulator works

This is the important bit. If it works in the terminal, it should also work with the desktop file. Most common mistake sometimes is that desktop files aren’t updated/refreshed even after editing them. You should go with the script and desktop file method

> [@Celty](#):
>
> ```auto
> Exec=/home/uname/.local/bin/scriptname
> 
> ```

…and reboot/install dex and then run dex path\_to\_file.

[https://forum.winehq.org/viewtopic.php?t=33865](https://forum.winehq.org/viewtopic.php?t=33865)

---

<div class="post-metadata">

**Author:** ![petsam](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/petsam/32/41308_2.png) [@petsam](https://forum.endeavouros.com/u/petsam)\
**Post date:** [April 30, 2022, 1:48am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/13 "2022-04-30T01:48:49Z")

</div>

> [@ishaan2479](#):
>
> then run dex path\_to\_file.

FWIW, dex can also **create** `.desktop` files 😉 . Read `dex --help`

---

<div class="post-metadata">

**Author:** ![Celty](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/celty/32/34777_2.png) [@Celty](https://forum.endeavouros.com/u/Celty)\
**Post date:** [April 30, 2022, 6:44am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/14 "2022-04-30T06:44:41Z")

</div>

Same deal here unfortunately. Running dex path\_to\_file in a terminal emulator works. Running dex path\_to\_file from rofi or a window manager does nothing.

---

<div class="post-metadata">

**Author:** ![manuel](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/manuel/32/396_2.png) [@manuel](https://forum.endeavouros.com/u/manuel)\
**Post date:** [April 30, 2022, 10:10am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/15 "2022-04-30T10:10:51Z")

</div>

You could write your script to `/usr/local/bin/script-name`.  
A good idea is to add this line as first in the script:

```auto
#!/bin/bash

```

Make sure you make it executable:

```auto
chmod +x /usr/local/bin/script-name

```

Then the `Exec=` line does not need bash prefix but only the script path:

```auto
Exec=/usr/local/bin/script-name

```

EDIT: are you sure your starting command is OK? I’ve not played that, but the line looks a bit strange to me. I may be wrong too…

---

<div class="post-metadata">

**Author:** ![wordler](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/wordler/32/14412_2.png) [@wordler](https://forum.endeavouros.com/u/wordler)\
**Post date:** [April 30, 2022, 10:36am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/16 "2022-04-30T10:36:47Z")

</div>

Should the “Exec” line read “exec /usr/local/bin/script-name” ? as @manuel says the syntax looks a bit strange.

---

<div class="post-metadata">

**Author:** ![manuel](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/manuel/32/396_2.png) [@manuel](https://forum.endeavouros.com/u/manuel)\
**Post date:** [April 30, 2022, 10:45am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/17 "2022-04-30T10:45:19Z")

</div>

A desktop file, e.g. `/usr/share/applications/xed.desktop` has its syntax, where the command is written with line

```auto
Exec=xed %U

```

The thing after `Exec=` can be basically any command, with some small but obvious restrictions.

Is this what you meant?

---

<div class="post-metadata">

**Author:** ![wordler](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/wordler/32/14412_2.png) [@wordler](https://forum.endeavouros.com/u/wordler)\
**Post date:** [April 30, 2022, 11:14am UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/18 "2022-04-30T11:14:43Z")

</div>

Yes but I was questioning the syntax, including uppercase & lowercase letters. If /usr/local/ and all that stuff doesn’t work then it’s a mess. Wine is a pain in the ass!

---

<div class="post-metadata">

**Author:** ![manuel](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/manuel/32/396_2.png) [@manuel](https://forum.endeavouros.com/u/manuel)\
**Post date:** [April 30, 2022, 12:15pm UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/19 "2022-04-30T12:15:52Z")

</div>

Sorry, I don’t understand what you are asking.  
Could be the language barrier as I don’t speak English natively.

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 30, 2022, 12:53pm UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/20 "2022-04-30T12:53:19Z")

</div>

> [@Celty](#):
>
> Same deal here unfortunately. Running dex path\_to\_file in a terminal emulator works. Running dex path\_to\_file from rofi or a window manager does nothing.

That most likely means what you are doing relies on something that doesn’t exist in your environment but does exist in a terminal environment. That is why “calling the script via rofi spawned from a terminal emulator works” and “calling the script from rofi running via Awesomewm fails”

---

<div class="post-metadata">

**Author:** ![wordler](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/wordler/32/14412_2.png) [@wordler](https://forum.endeavouros.com/u/wordler)\
**Post date:** [April 30, 2022, 1:17pm UTC](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565/21 "2022-04-30T13:17:35Z")

</div>

Sorry, just thought command could be wrong.

[Next page](https://forum.endeavouros.com/t/need-some-help-creating-a-desktop-file-for-a-shell-script/26565.md?page=2)
