ElementaryOS Freya - Dropbox Icon - linux

I'm having some troubles with dropbox icon on tray with ElementaryOS Freya
Dropbox is synchronizing, the unique problem is the icon on tray that I can't show anyway.
Procedures done:
1 - Instaled dropbox by .deb downloaded from dropbox site using dpkg -i
2 - Instaled by .tar downloaded from dropbox site using this:
$ cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
$ ~/.dropbox-dist/dropboxd
3 - Instaled by Elementary repository using:
$ sudo apt-get install dropbox
4 - I've deleted the folders ~/.dropbox , ~/.dropbox.dist and executed the daemon again with $ dropbox start -i
5 - I've put the code export DROPBOX_USE_LIBAPPINDICATOR=1 in files: ~/.bashrc, ~/xsessionrc and /etc/profile.
6 - I've instaled the packages: pantheon-files-plugin-dropbox and libappindicator1
Any idea for fix?

A quick fix I go into detail on my blog here, but simply here:
Kill dropbox, and restart it so it shows
dropbox stop && env XDG_CURRENT_DESKTOP=Unity dropbox start
Go to the settings in dropbox after it starts up and select to not start at startup.
Go to system settings -> Applications, from the tab up top select "Startup" and add a command from the + button at the bottom left and there will be an input where you can enter in a command below and press enter to save:
env XDG_CURRENT_DESKTOP=Unity dropbox start
Restart and you should be good to go.

I followed a similar process to the one in this blog comment.
The following script started Dropbox showing the icon on the tray as expected.
#!/bin/sh
sleep 10 && dropbox stop && env XDG_CURRENT_DESKTOP=Unity dropbox start
To make it permanent, simply editing dropbox.desktop like they mention in the blog didn't work for me.
Run the script and go to Dropbox's preferences. Untick "Start Dropbox on system startup". This will get rid of the .desktop file.
Now we create our own in the same place, ~/.config/autostart, we can name it dropbox-fix.desktop:
[Desktop Entry]
Name=Dropbox (fixed)
GenericName=File Synchronizer
Comment=Sync your files across computers and to the web
Exec=/usr/bin/dropbox-fix.sh
Terminal=false
Type=Application
Icon=dropbox
Categories=Network;FileTransfer;
StartupNotify=false
You should change Exec=/usr/bin/dropbox-fix.sh to where you have saved the script and make it executable.

You could try running Dropbox, then click on Options and there should be an option that says show "Icon in tray" or something along those lines. Please let me know if this helps you or if you need more assistance.

Related

How to add "Open with Code" with right-click in Ubuntu or Pop OS?

In windows OS, when we install VS-Code, the option to add "open with code" is offered to us. But I couldn't find it in Ubuntu or Pop-OS!
Thus, I'd like to know, is there any way I can add "open with code" when I right-click within a folder to open the folder in VS-Code?
Although, we can use a terminal for opening the directory in VS-Code using "code ." but I'm looking for the right-click of the mouse.
You can run this command in the terminal
wget -qO- https://raw.githubusercontent.com/cra0zy/code-nautilus/master/install.sh | bash
After that you'll see on right click 'Open in Code'!
Works perfectly in Ubuntu 20.04
You could manually write down MIME types associated with vscode in ~/.local/share/applications/mimeapps.list like this
[Added Associations]
text/html=code.desktop
text/css=code.desktop
text/javascript=code.desktop
Assuming you have a proper Desktop Entry inside /usr/share/applications/
You can also try this Nautilus extension (if you use Nautilus)
https://github.com/harry-cpp/code-nautilus
This will install it if you use bash
wget -qO- https://raw.githubusercontent.com/harry-cpp/code-nautilus/master/install.sh | bash

Flutter command not found

This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
Apparently, none of the Flutter commands are working in the terminal of Android Studio which I believe I am trying to run it at the root of my project.
Output:
bash: flutter: command not found
You need to correctly set up your Flutter path.
From macOS install - Update your path:
Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
Open (or create) $HOME/.bash_profile. You can do that by using terminal text editor by going in terminal and typing nano ~/.bash_profile
macOS v10.15 (Catalina) uses the Z shell by default, so edit $file HOME/.zshrc.
If you are using a different shell, the file path and filename will be different on your machine.
Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s Git repository is:
export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
For example:
export PATH=~/Documents/flutter/bin:$PATH
Press Ctrl + X and when it asks you to save the file, choose Yes
Run source $HOME/.bash_profile to refresh the current window or restart the terminal
Verify that the flutter/bin directory is now in your PATH by running:
echo $PATH
Notice that [PATH_TO_FLUTTER_GIT_DIRECTORY] is where you installed Flutter SDK, not the location of your app
Instead of nano, you can use any text editor to edit file ~/.bash_profile.
For zsh:
Open Terminal
Run: nano ~/.zshrc
Add: export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
Run: source ~/.zshrc
restart terminal
Run: flutter doctor -v
For example : if flutter in your machine has been installed under [your_username]/Developer/flutter
export PATH=Developer/flutter/bin:$PATH
I tried out all the methods in previous answers, but all of them lasted only while the terminal was open. So I went ahead and directly added it to the path file permanently.
sudo nano /etc/paths
Add this to the file:
/Users/yourUserName/Development/flutter/bin
Save the file by pressing Ctrl + X, Y and then Enter. Close the terminal and reopen it again. Tada!
If you are using zsh, you need to follow the steps below on Mac.
Download the latest Flutter version from the official site.
Unzip it and move to the $HOME location of your Mac.
Add to the path via the .zshrc file.
Run nano ~/.zshrc into an iTerm2 terminal.
Export PATH=$HOME/flutter/bin:$PATH
Save and close the ~/.zshrc file.
Restart iTerm2.
Now you will have the Flutter executable available.
Do the following steps:
Download the Flutter SDK
Flutter SDK Archive
Extract it where do you want (for example /home/development/flutter)
Set your PATH. Edit your file with the command gedit ~/.profile. You need to add this line:
export PATH=[location_where_you_extracted_flutter]/flutter/bin:$PATH
I showed you above where I've extracted mine, so my export will look like this:
export PATH=/home/myUser/development/flutter/bin:$PATH
Save the file and close it.
Run source ~/.profile to load the changes
If you now run flutter doctor, it should work!
If you are on macOS
First find the location of your Flutter SDK
Flutter SDK File: Write the below command on your terminal to download the Flutter SDK
git clone https://github.com/flutter/flutter.git
For example: the SDK executable file name is flutter and it is in folder Downloads
Close and open your terminal again.
And enter the following commands in your terminal
cd Downloads # Go to Downloads
cd flutter # Go to folder 'flutter'
pwd # /Users/[USERNAME]/downloads/flutter/
whoami # Your [USERNAME]
export PATH="/Users/[USERNAME]/downloads/flutter/bin":$PATH
macOS v10.14 (Mojave); Wireshark Path problem
In your terminal, run:
touch $HOME/.bash_profile
vi $HOME/.bash_profile
Now use I to insert and paste the following:
export PATH="$PATH:$HOME:/PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin"
Use Esc and type :wq! to save the file and exit.
Refresh:
source $HOME/.bash_profile
And verify it's OK by running:
echo $PATH
For zsh users:
Open terminal run
touch $HOME/.zshrc
Run
sudo nano ~/.zshrc
Type
export PATH=$PATH:/Path to your extracted flutter/Flutter/bin
Press ctrl+x then press y
Press Enter
Close the terminal and open a new terminal and run
flutter doctor
You must have the .bash_profile file and define the flutter path in the .bash_profile file.
First of all, if you do not have or do not know file .bash_profile, please look my answer:
How do I edit $PATH (.bash_profile) on OSX?
You should add the below line (.../flutter_SDK_path/flutter/bin) in your .bash_profile:
export PATH=$PATH:/home/username/Documents/flutter_SDK_path/flutter/bin
After these steps, you can write Flutter code such as, flutter doctor, flutter build ios, flutter clean, etc. in the terminal of a MacBook.
Do this to add the Flutter executable permanently to your path (in Ubuntu):
cd $HOME
gedit .bashrc
Append the line:
export PATH="$PATH:[location_where_you_extracted_flutter]/flutter/bin"
in the text file and save it.
source $HOME/.bashrc
Open new terminal and run the flutter doctor command
On macOS v10.15 (Catalina), the issue is with the Path environment variable.
Open Terminal and check the shell (command: echo $SHELL),
If output is /bin/bash, we need to convert to Z shell (Zsh). Z shell is only the default shell on newly created user accounts, so any existing accounts you have on an upgraded Mac will still use Bash by default unless you change it. Simply run the chsh -s (change shell) command in a Terminal window.
(command: chsh -s /bin/zsh)
Enter your password when prompted. After you close the terminal window and reopen it, you’ll be using Z shell.
Update your Path
2.1. Open the zshrc file (command: vim ~/.zshrc)
2.2. Press 'I' to insert the path as (export PATH=~/Dev/flutter/bin:$PATH). Here ~/Dev/ is the folder where Flutter is installed
2.3. Hit Esc key and then :wq to save and exit the file
Done! try (command: flutter doctor)
Previously I was giving my whole path like this:
export PATH=Users/Tekion/Downloads/flutter/bin:$PATH
It started working after I changed my whole path to
export PATH=$HOME/Downloads/flutter/bin:$PATH
Add Path in this way in .bashrc of android sdk and tools with flutter
export PATH=$PATH:/user/Android/Sdk/platform-tools:/user/Android/Sdk/build-tools/27.0.1:/user/Android/Sdk/tools:/user/Android/Sdk/tools/bin:/user/Documents/fluterdev/flutter/bin:$PATH
Then run this command
source ~/.profile
Then run this command:
On Linux
source ~/.profile
On Mac
source ~/.bash_profile
Or:
open -a TextEdit ~/.bash_profile
Then you can user any of flutter command like to build fluter apk
flutter build apk
The Flutter SDK can be run on Windows as well as macOS.
For Windows
First download the latest SDK from the Flutter download page.
Now to run flutter in the Windows console, you need to update your PATH environment variable.
From the Start search bar, type ‘env’ and select Edit environment variables for your account.
Under User variables, check if there is an entry called Path:
If the entry does exist, append the full path to flutter\bin using ; as a separator from the existing values.
If the entry does not exist, create a new user variable named Path with the full path to flutter\bin as its value.
For Mac
First download the latest SDK from the Flutter download page
Extract the file in the desired location using following commands:
cd ~/development
unzip ~/Downloads/flutter_macos_v1.5.4-hotfix.2-stable.zip
Add the Flutter tool to your path:
export PATH="$PATH:pwd/flutter/bin"
Run flutter doctor
I followed the checked answer, but when I restart the terminal, the Flutter command is not recognized again. My in file bash_profile path is:
export PATH=~/Users/aldo/Projects/Framework/flutter/bin:$PATH with ~
Then I edit it to:
export PATH=/Users/aldo/Projects/Framework/flutter/bin:$PATH without ~
And re run source $HOME/.bash_profile: Now my Flutter command is recognized even if I restart the terminal.
The Flutter installation issue in macOS (specific for macOS v11 (Big Sur)).
Check which shell is your default shell that you have in the terminal.
To check the default shell, type command echo $SHELL.
For my specific issue I have Z shell (zsh) as my default shell.
So I change my Z shell as my default shell to Bash.
To change the default shell, enter the below command.
chsh -s /bin/bash
Enter your password when you are prompted
Now I have the Bash shell as my default.
Then I just follow the standard process for the Flutter setup on Flutter’s official site.
And I have successfully configured Flutter in my macOS.
Extract the file in the desired location, for example:
cd ~/development
unzip ~/Downloads/flutter_macos_1.22.5-stable.zip
Add the flutter tool to your path:
export PATH="$PATH:`pwd`/flutter/bin"
This command sets your PATH variable for the current terminal window only. To permanently add Flutter to your path, see below.
—> Determine the directory where you placed the Flutter SDK.
—> Open (or create) the rc file for your shell. Typing echo $SHELL in your Terminal tells you which shell you’re using. If you’re using Bash, edit $HOME/.bash_profile or $HOME/.bashrc. If you’re using Z shell, edit $HOME/.zshrc. If you’re using a different shell, the file path and filename will be different on your machine.
—> Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s Git repository
export PATH="$PATH:[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin"
—> Run source $HOME/.<rc file> to refresh the current window, or open a new terminal window to automatically source the file.
—> Verify that the flutter/bin directory is now in your PATH by running:
echo $PATH
—> Verify that the flutter command is available by running
—> which flutter
—> Now run below command.
$ which flutter dart
/path-to-flutter-sdk/bin/flutter
/usr/local/bin/dart
—> And you're good to go.
You can easily create a symbolic link as below,
sudo ln -s /opt/flutter/bin/flutter /usr/bin/flutter
I had moved the executable flutter into the /opt/ folder after downloading, so replace it with the path you have for the directory the flutter executable is in.
The flutter command should work even after rebooting your machine.
In my case, I put the line export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH in both file .bash_profile and .bashrc (I put it on the last line).
After that, run source .bash_profile and source .bashrc. Now it's working (even if you use it in a new terminal window)!
Just revert to chsh -s /bin/bash from chsh -s /bin/zsh,
Run one command
chsh -s /bin/bash
You're facing this problem just because you have changed the shell from Bash to Z shell in macOS. If you run this command again it will change the path again.
So just run one command and the problem is solved.
For Ubuntu 14.*:
There isn't any .bash_profile file, but it just the .profile file in folder /home/mangesh.
In my case, I am running this command to add the flutter/bin path,
export PATH="$PATH:/home/mangesh/Documents/flutter_data/flutter/bin/"
To verify the above change, just run,
echo $PATH
Following is my complete output,
$ pwd
/home/mangesh
$ export PATH="$PATH:/home/mangesh/Documents/flutter_data/flutter/bin/"
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/mangesh/Documents/flutter_data/flutter/bin/
On a Mac I followed the steps of the user Tree, but I still received the answer "flutter: command not found".
I then went to the folder flutter/bin and inside this folder Ctrl + click on the flutter executable and in the popup I clicked open. After that the Mac already recognized this as an exception and the Flutter commands already work.
On a Mac, there are two options to solve this issue.
Option 1: Adding the Flutter SDK path permanently (it will work in any terminal session)
Download the Flutter SDK and extract in any location and then you have to add the below line in $HOME/.bash_profile file (hidden folder as default).
export PATH="$PATH:[where the Flutter SDK is downloaded and extracted]/flutter/bin"
For example:
export PATH="$PATH:~/development/tools/flutter/bin"
Option 2: If you are facing any difficulties with Option 1, then this is much simpler, but you have to do this simple step whenever you restart your system/terminal.
Step 1: Go to the path where Flutter SDK downloaded and extracted (for example: cd ~/Development/tools/)
Step 2: Enter this command
export PATH='pwd'/flutter/bin:$PATH
That's it. Type "flutter doctor" to check if this issue gets resolved.
First, download the Flutter here: https://flutter.dev/docs/get-started/install/macos
When you created the folder with Flutter SDK, open it in Terminal using the following command:
cd ~/development
If there is no development folder run this command first:
mkdir /development
After that, you need to run the unzip command. Make sure you specify the correct path to the downloaded Flutter archive file.
Run the command below:
unzip ~/Downloads/flutter_macos_1.17.1-stable.zip
Setting the Flutter tool path
In order to set up the Flutter tool path you should run this command:
export PATH="$PATH:`pwd`/flutter/bin"
Next, you need to know which shell you are using. For this run this command:
echo $SHELL
Depending on the shell run the following command: [Note, the command you will be using depends on the shell you have.]
sudo nano ~/.zshrc
or
sudo nano /.bashrc
After that in the new window, you need to add a path to the flutter tool.
Use the following command:
export PATH=$PATH:~/development/flutter/bin
The next thing you need to do is to check the Flutter dependencies.
For this, run the command:
flutter doctor
This operation will help you to identify if there are any dependencies you need to install.
After the results will be prepared click Agree and wait for the installation of the needed dependencies to complete the setup.
enter image description here
Ubuntu 16.04 (Xenial Xerus):
I added the path correctly for Flutter, Java, Android Studio, and Android SDK in the .bashrc file, but when I run flutter doctor, the terminal returns:
flutter: command not found
Solution:
So, first I had to always run:
sudo su
And then:
source /home/your_name/.bashrc
Then run flutter doctor. It works fine.
So every time, if I want to run flutter doctor, I have to run these two commands above.
The Flutter installation guide says you add this:
export PATH="$PATH:pwd/flutter/bin"
Visual Studio Code doesn't support pwd for some reason. The fix:
export PATH="$PATH:~/flutter/bin"
If you are facing this issue from a Windows 10 machine, this is how I solved it:
First of all, find your Flutter executable path, and then your bin folder under the Flutter path
E.g., "C:\flutter\bin"
Copy it, and press the windows button. Type: environment, and press "Edit the system environment variable"
Press the "Environment variable" button
Double click on the "Path" menu
Add a new path, using the bin address
E.g., ""C:\flutter\bin"
This should work.
For those using a Z shell resource (.zshrc), navigate to your home directory and open .zprofile, copy and paste this: export PATH=[PATH_TO_FLUTTER_DIRECTORY]/flutter/bin:$PATH

Google Drive folder with Bash Windows

I have installed WSL (Windows Subsystem for Linux) and it works perfectly. I like opening bash with CMD or PowerShell typing "bash" because it keeps the same folder.
For example:
PS C:\Users> bash
root#X /mnt/c/Users #
I also use Google Drive (backup and sync).
The folder is in C:/Users/X/Google Drive.
The problem is that when I use "my trick" in that folder it doesn't work. It leads me to bash ~ instead of the real location.
Firstly I thought that It was caused by the spaces from "Google \Drive" but no. All folder work fine (even with spaces)
To sum up, I can't start in that folder or under it. However I can cd there, but you know... not convenient.
Sorry my english in advance, and thank you for your answers :)
I'm a little confused about your question but will do my best to be helpful. It seems that you are attempting to run bash in a Windows environment? I know little of Windows, but work and play in Unix daily.
Once you're using your terminal like a unix terminal, Bash WILL struggle with Google Drive. I use GD as well, and the whitespace is the bane of my existance. However, for simple command-line navigation, something like "cd ~/Google\ Drive" will change your directory to the GD dir. This can be applied to other scenarios as well.. variably.
If you are trying to go to the location in the code you posted, in bash, this would be the appropriate syntax:
cd /mnt/c/Users
This may not apply to Windows, but on a Unix machine, you can get to your personal user directory in appbreviated fashion using "~":
cd ~/
Hope this helps.
work-around: https://github.com/Microsoft/WSL/issues/2999#issuecomment-455835951
Here is a way to mount GFS in WSL based on https://superuser.com/questions/1353169/getting-sshfs-working-on-wsl-or-finding-an-alternative The trick is to use https://www.nsoftware.com/sftp/netdrive/ to ssh to GFS from Windows and relay it as a filesystem that can be mounted under WSL.
Install OpenSSH Server under Win10
Win10 Settings -> Apps -> Manage optional features -> Add feature -> OpenSSH Server
restart if necessary
open Services -> OpenSSH -> Properties -> Startup Type -> Automatic (delayed)
Install and run SFTPNetDrive, right click on icon in hidden icons -> Main window (or maybe already open) -> Profile -> new profile ( server: localhost, user: * pwd:* Drive Letter: F (or another) Advanced -> ( Protocol -> uncheck compression; Specified folder: G:\ ) )
in Bash (wsl): sudo mkdir /mnt/f; sudo mount -t drvfs F: /mnt/f
I'm not sure how stable it is, but I was able to open files in WSL.

how to use exiftool with cygwin basic startup

ok here is the situation. I'm a complete newbie at all this and have no idea what is going on. Currently I have a race website with thousands of photos and each time I basically upload via FTP to a temporary folder and use Cygwin with exiftool (I think) to tag each image and then use Cygwin to move them to where I want on my website. During the process I make a filename.sh file and then do a chmod 755 and then tell it to run and I can tag several thousand photos individually with my filename.sh file data. All that is good. Most of the time. haaha.
My question is I want to keep the images on my desktop and tag them using the same steps and then FTP them to my site. So I think what I'm trying to figure out is how to get exiftool to work on my desktop computer the way it works on my website.
I tried to do all the right things, but when I run the filename.sh file it says:
exiftool command not found
What do I need to do? Any help would be greatly appreciated. Thanks!
install perl
then cpan Image::ExifTool
done.
The exiftool command is available through Cygwin Ports, an extra package repository for Cygwin.
To install:
Follow the Cygwin Ports installation guide (summarized here)
Download the regular Cygwin installer from https://www.cygwin.com/
In a cygwin terminal, run cygstart -- /path/to/setup-x86.exe -K http://cygwinports.org/ports.gpg. The Cygwin installer should open.
On the Choose Installation Type page, select "Install from Internet".
On the Choose Download Site(s) page, select a regular cygwin distro mirror, then enter ftp://ftp.cygwinports.org/pub/cygwinports in the User URL field and press Add. Select both, then click Next.
At the Select Packages screen
Set the View dropdown to "Full"
Search for perl-Image-exiftool
Click it to install it
Continue to click Next until the installation completes
https://sourceware.org/cygwinports/
https://sourceforge.net/projects/cygwin-ports/

Running Pycharm as root from launcher

How is it possible to run Pycharm from the launcher with root privileges?
I can do that from the terminal window, with sudo ./pycharm.sh, but I'd like to do the same directly from the launcher.
I have encountered another way to solve this issue so I thought to share it (this answer is more like an alternative for the other answers).
It is worth to mention that this solution "attacks" the problem by running only a certain Python script (within the PyCharm IDE) in root mode , and not the entire PyCharm application.
1) Disable requiring password for running Python:
Recommend using the visudo program to edit the file to ensure syntax is correct. Otherwise you may be locked out of using sudo.
visudo /etc/sudoers.d/python
What we need to do is add an entry in that file as follows:
user host = (root) NOPASSWD: full_path_to_python , for example:
guya ubuntu = (root) NOPASSWD: /usr/bin/python
NOTES:
user can be detected by the command: whoami
host can be detected by the command: hostname
2) Create a "sudo script": The purpose of this script is to give python privilege to run as root user.
Create a script called python-sudo.sh , and add the following into it:
#!/bin/bash
sudo /usr/bin/python "$#"
Note, again, that the path is the path to your Python as the previous phase.
Don't forget to give execution permissions to this script using the command: chmod, i.e.-
chmod +x python-sudo.sh
3) Use the python-sudo.sh script as your PyCharm interpreter:
Within PyCharm go to: File --> Settings --> Project interpreter
At the right top hand side click the "setting" icon, and click "Add local".
In the browser option choose the python-sudo.sh script we have created previously. This will give PyCharm the privilege to run a python script as root.
4) Debug the test: All there is left to do is actually debug the specific Python script in the PyCharm IDE. This can be done easily via Right-click on the script to debug --> hit "Debug sample_script_to_debug.py"
Try: gksudo ./path/to/pycharm/executable
More about gksudo
If you're on ubuntu and don't have gksudo install it using:
apt-get install gksu
Here is an example launcher configuration (under: ~/.local/share/applications/jetbrains-pycharm-ce.desktop):
[Desktop Entry]
Version=1.0
Type=Application
Name=PyCharm Community Edition
Icon=/home/YOUR_USER/pycharm/bin/pycharm.png
Exec=gksudo -k -u root "/home/YOUR_USER/pycharm/bin/pycharm.sh" %f
Comment=Develop with pleasure!
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm-ce
ce indicates community edition, yours may differ.
As of this post (June 28 2018) I am running Pycharm-2018.1.4 on Ubuntu 18.04 Bionic Beaver. The solution that worked for me was to simply edit the sudoers.d file and add the following to the last line:
user host = (root) NOPASSWD: full_path_to_python
for example:
guya surface-pro = (root) NOPASSWD /usr/bin/python3.6
I had the need to run a script from PyCharm as root like the OP, but the accepted answer didn't work for me because 1.) I had installed PyCharm via flatpak and 2.) The gksu command isn't available on newer versions of Ubuntu and Mint.
I couldn't find a way to make things work consistently with the flatpak install so I uninstalled the PyCharm flatpak and then reinstalled PyCharm the "normal" way. The accepted answer relies on the gksu command which is not available on my OS (Mint 19.2). Thankfully pkexec is a suitable alternative and was already available on my system. I then updated my launcher file (~/.local/share/applications/PyCharm.desktop) as follows. The important bit is the Exec line:
[Desktop Entry]
Name=PyCharm
Exec=pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /opt/pycharm-community-2019.2.2/bin/pycharm.sh
Comment=PyCharm
Terminal=false
Icon=/opt/pycharm-community-2019.2.2/bin/pycharm.png
Type=Application
The pkexec command will cause a popup to appear prompting you for your password each time you launch PyCharm via the .desktop file.
Here's a sample git repo that is a proof-of-concept for how to do this. Should be as simple as following the instructions in the README.md. My team needed to do this for one of our products and we used that as the workflow.
Hope this helps! https://github.com/samayer12/sudome
This answer builds upon the description here that was first pointed out by Ed Jones.
I have Pycharm-community 2020.
I edited the
/var/lib/snapd/desktop/applications/pycharm-community_pycharm-community.desktop
file with nano
just modified the Desktop Entry as follow:
[Desktop Entry]
X-SnapInstanceName=pycharm-community
Version=1.0
Type=Application
Name=root PyCharm Community Edition
Icon=/snap/pycharm-community/222/bin/pycharm.png
Exec=sudo env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/pycharm-community_pycharm-community.desktop /snap/bin/pycharm-community %f
Comment=root Python IDE for Professional Developers
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm-ce
StartupNotify=true
that is: added the sudo command in front of the EXEC item, put "root" in front of couple of fields (see above) and saved with a different name:
/var/lib/snapd/desktop/applications/root_pycharm-community_pycharm-community.desktop
now I have two icons in the launcher, one that is the standard and the other one with "root" as leading word in the description and runs as root.
Note:
the original desktop launcher (which is still there):
[Desktop Entry]
X-SnapInstanceName=pycharm-community
Version=1.0
Type=Application
Name=PyCharm Community Edition
Icon=/snap/pycharm-community/222/bin/pycharm.png
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/pycharm-community_pycharm-community.desktop /snap/bin/pycharm-community %f
Comment=Python IDE for Professional Developers
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm-ce
StartupNotify=true

Resources