How to properly format this command: Exec=a=$(service httpd restart 2>&1) && notify-send "$a" [closed]

StackOverflow https://stackoverflow.com/questions/18121286

Question

I am trying to figure a way to fix this code so that Exec= line can work properly.

[Desktop Entry]
Name=a
GenericName=a
Exec=a=$(service httpd restart 2>&1) && notify-send "$a"
Terminal=false
Type=Application
StartupNotify=true
MimeType=text/plain;
Icon=/root/Desktop/111.svg

this is basically a panel shortcut i created by copying another app's shortcut.

i tested this and it worked great with..

Exec=notify-send 'a'

in other words it does execute a command.

but i am trying to stuff 2 commands in this line .. as seen above.

Was it helpful?

Solution

You need to start a wrapper shell, like this:

Exec=bash -c "notifiy-send \"$(command)\""

Note: Don't miss the double quotes around $(command)

What makes in your case:

Exec=bash -c "notifiy-send \"$(service http restart)\""

Or if the user need to authenticate use gksu:

Exec=bash -c "notifiy-send \"$(gksu service http restart)\""
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top