My script is something like this:
#!/bin/bash
sudo teamviewer --daemon enable
teamviewer
sudo teamviewer --daemon disable
It works fine on its own, and it requests my password with a terminal window. So, now I want to make a launcher for it. I have this in my .desktop
file:
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Categories=Network;
Name=TeamViewer 12
Comment=Remote control and meeting solution.
Exec=gksu /path/here/Start.sh
Icon=teamviewer
That way it requests my password with a pop-up instead of a terminal window, but doing this runs the whole script with sudo, which is a problem, because TeamViewer refuses to start with sudo. How can I solve this?
sudo
if the script is already being run viagksu
(and it will have to be in order for the password to be requested once graphically). – terdon Jun 07 '17 at 19:09"Error: Could not create /root/.local/share/teamviewer12/logfiles"
"mkdir: cannot create directory '/root': Permission Denied"
"Error: InitDirs failed. (2)"
Accidentally pressed enter before finishing the reply
– POPCORNS Jun 07 '17 at 19:15sudo -u root teamviewer
is the same assudo teamviewer
, which you claimed does not work (and which sounds like a horrible security problem to me). – Byte Commander Jun 07 '17 at 19:25sudo -E
so that your environment variables are kept. Which of thesudo
calls need that will depend on which of the commands is trying to write to/root
. – terdon Jun 07 '17 at 22:29