I'm trying to create a .desktop file that runs a shell script that's in the same folder as the .desktop file. So far I got the following to work:
Exec=bash -xc 'cd "$(dirname %k)" && bash ./patch.sh && bash -c "read -n1"'
There's just two issues with that command.
The first issue is that desktop-file-validate
returns a bunch of errors:
start.desktop: error: value "bash -xc 'cd "$(dirname %k)" && bash ./patch.sh && bash -c "read -n1"'" for key "Exec" in group "Desktop Entry" contains a reserved character ''' outside of a quote
start.desktop: error: value "bash -xc 'cd "$(dirname %k)" && bash ./patch.sh && bash -c "read -n1"'" for key "Exec" in group "Desktop Entry" contains a non-escaped character '$' in a quote, but it should be escaped with two backslashes ("\\$")
start.desktop: error: value "bash -xc 'cd "$(dirname %k)" && bash ./patch.sh && bash -c "read -n1"'" for key "Exec" in group "Desktop Entry" contains a reserved character '&' outside of a quote
start.desktop: error: value "bash -xc 'cd "$(dirname %k)" && bash ./patch.sh && bash -c "read -n1"'" for key "Exec" in group "Desktop Entry" contains a reserved character '&' outside of a quote
start.desktop: error: value "bash -xc 'cd "$(dirname %k)" && bash ./patch.sh && bash -c "read -n1"'" for key "Exec" in group "Desktop Entry" contains a reserved character '&' outside of a quote
start.desktop: error: value "bash -xc 'cd "$(dirname %k)" && bash ./patch.sh && bash -c "read -n1"'" for key "Exec" in group "Desktop Entry" contains a reserved character '&' outside of a quote
start.desktop: error: value "bash -xc 'cd "$(dirname %k)" && bash ./patch.sh && bash -c "read -n1"'" for key "Exec" in group "Desktop Entry" contains a reserved character ''' outside of a quote
and I don't understand any of these. There's single quotes around the entire "bash" parameter, and inside of that, everything's using double quotes. The desktop file works, and the bash command itself (when run outside of the desktop file) also works, so why does this validation tool complain about missing quotations? Why would I need to escape a damn &&
in a script?
The second issue is that the desktop file doesn't work if the path to it contains a space. I believe that that might be related to all the errors the validator gives me.
But I have absolutely no idea how to properly escape all that so that the errors go away. It just doesn't make sense to escape an &&
that's inside single quotes already, does it?