0

I've created a script to restart the network manager using

#!/bin/bash   

sudo service network-manager restart

I've named the file network-restart.sh and ran

chmod +x network-manager.sh

to set the file to executable

I've also created a desktop file name Network-Manager.desktop and saved in it ~/.local/share/applications

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Network Restart
Comment=Network Restart
Exec=/home/elementary/Documents/Scripts/network-restart.sh
Icon=/usr/share/icons/elementaryPlus/emblems/16/emblem-insync-
syncing.svg
Categories=Utility
Terminal=false

The icon shows up in the Slingshot menu but does not appear to be executing the network manager restart command.

Any ideas?

Thanks!

2 Answers 2

1

You have used sudo and the script keep waiting for a password. You must use gksu to open a dialog and enter your password.

1
  • that worked, thank you. I noticed too that is I don't run the command as su it prompts me for the password, but unlike the gksu it brings up the native elementary prompt where the gksu brings up the generic GTK one.
    – pretz
    Mar 12, 2017 at 13:10
1

well there is also another way you could do this ... but I am not sure that it is "proper" ... need to think about that

  1. create your bash script
  2. make it executable by ANYONE
  3. sudo chown root:root {you script name}

at this point ... you should be able to run your script without a password prompt

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.