p-e-w / argos

Create GNOME Shell extensions in seconds

Home Page:https://extensions.gnome.org/extension/1176/argos/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Command chaining/calling sudo in bash attribute

calexandru2018 opened this issue · comments

I am running Manjaro 18. The Argos script runs well won simple files/programs, but it gets a bit querky when sudo is needed or a script needs additional arguments.

I am configuring to run "sudo /opt/lampp/lampp start" but this get truncated at "sudo", if I type in the bash value to be "/opt/lampp/lampp start" then the value gets truncated at "/opt/lampp/lampp" so, no command is run. It seems that the script truncates all whitespaces, even if they are in quotes and/or double quotes.

I had an similar problem and solved it using this

echo "My button | bash='pkexec sh -c \"command-a && command-b\"' terminal=false"
  • The pkexec runs an sudo prompt (in an dialog).
  • The sh -c "..." runs an shell command. I use this to run multiple commands with only one sudo.
  • I used the \" to escape the quotes inside the bash param
  • terminal=false makes the command not spawn an terminal
commented

So i think i may have a decent template for these kind of complex task where you actually want to build a bash function and run it. I have documented it in the wiki here.

TLDR: If no argument is supplied, the script echo the menu. The bash values actually just call the argos script itself with a function name. When run with a function name + argument, the script skip echoing out the menu but simply call the function with its argument.