0

I am using Debian 12. Gnome 43. zsh is my default shell (sudo chsh --shell /usr/bin/zsh ismail).

In my .zshrc, I have set the path variable like:

export PATH="$HOME/.dotfiles/.cargo/bin:$PATH"

The alacritty binary is located in:

% which alacritty
/home/ismail/.dotfiles/.cargo/bin/alacritty

The following desktop file works:

[Desktop Entry]
Type=Application
Exec="/home/ismail/.dotfiles/.cargo/bin/alacritty"
Icon=Alacritty
Terminal=false
Categories=System;TerminalEmulator;

The following desktop file does not work:

[Desktop Entry]
Type=Application
Exec=alacritty
Icon=Alacritty
Terminal=false
Categories=System;TerminalEmulator;

I have no idea why this is not working.

I want to point out one thing.

$ which foliate
/usr/bin/foliate

If I set Exec=foliate, then it works. So, I guess it has something to do with the path. The system that runs .desktop files is not probably seeing the path variable set in .zshrc.

What can I do at this point.

Update 1:

If I use the following desktop file:

[Desktop Entry]
Type=Application
Exec=gnome-terminal -e "zsh -c 'echo $PATH;$SHELL'"
Icon=Alacritty
Terminal=false
Categories=System;TerminalEmulator;

Name=Alacritty
GenericName=Terminal
Comment=A fast, cross-platform, OpenGL terminal emulator
StartupWMClass=Alacritty
Actions=New;

Then the path variables are:

/home/ismail/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

% echo $SHELL        
/usr/bin/zsh

% echo $PATH 
/home/ismail/.dotfiles/.cargo/bin:/home/ismail/.local/bin:/home/ismail/bin:/home/ismail/.dotfiles/.resources/git-scripts:/home/ismail/.dotfiles/.resources/zsh-scripts:/home/ismail/.dotfiles/.resources/python-scripts:/home/ismail/.dotfiles/.resources/bash-scripts:/home/ismail/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

So the desktop file is not seeing the first part or the path variable which i set later in .zshrc (/home/ismail/.dotfiles/.cargo/bin:/home/ismail/.local/bin:/home/ismail/bin:/home/ismail/.dotfiles/.resources/git-scripts:/home/ismail/.dotfiles/.resources/zsh-scripts:/home/ismail/.dotfiles/.resources/python-scripts:/home/ismail/.dotfiles/.resources/bash-scripts:).

Where do I need to set the $PATH variable so that .desktop file can see when i am using zsh as my default shell.

2 Answers 2

2

Your desktop environment does not care about your shell settings.

You have to mirror this setting in the way your DE expects (which differs from DE to DE).

5
  • I am looking at specifications.freedesktop.org/desktop-entry-spec/… for TryExec it says "If the path is not an absolute path, the file is looked up in the $PATH environment variable." Jun 25, 2023 at 8:13
  • 1
    @AhmadIsmail Sure. But how is that related to my statement? Which DE do you use? Jun 25, 2023 at 8:18
  • I am using gnome 43. Jun 25, 2023 at 8:19
  • I have updated the question with more details. Jun 25, 2023 at 21:04
  • You are right, "If no full path is provided the executable is looked up in the $PATH environment variable used by the desktop environment." However, I have tried .zshenv, .zshrc, .profile,. .gnomerc , nothing is working. Jun 25, 2023 at 21:32
0

The following solved my problem:

When bash is the default shell, have to use .profile to set environment variables.

When zsh is the default shell, have to use .zshenv to set environment variables.

we must logout then login to get the path variables.

You must log in to answer this question.

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