Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.Desktop problems
#1
Regarding RUNNING a .py through a desktop icon. .Desktop is the Linux version of an .exe . I wasn't able to find a solution to this (tried stackexchange and FreeDesktop.org). So hopefully other users benefit from this. I couldn't find a similar issue so maybe this is helpful.

I have a working .py and want to put it on the desktop w/ its own icon and be able to run it by clicking the icon. I set up the .desktop file

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=SomeApp
Comment=SimiApp
Exec=/usr/share/applications/simi0op.py
Icon=/usr/share/icons/hicolor/48x48/apps/gw48.png
Terminal=true
Exec/Icon all are placed **correctly** Meaning simi0op.py is in the directory Exec points to. Same thing for my icon file, gw48.png.

[inline]
me@me-ubuntu:~$ cd /
me@me-ubuntu:/$ sudo -i
[sudo] password for me:
root@me-ubuntu:~# mv /home/me/Documents/py/cs/test0.desktop /usr/share/applications/
root@me-ubuntu:~# cp /usr/share/applications/test0.desktop /home/me/Desktop
root@me-ubuntu:~# exit
logout
[/inline]

There is a generic icon on the desktop now w/ tiny lock on it. Double clicking the icon prompts 'untrusted to launch'.

I ran ls -lsh on my desktop
[inline]
4.0K -rwxrwxr-x 1 me me 182 Jan 25 15:17 test1.desktop
[/inline]


closest thing I found regard 'untrusted to launch' in Ubuntu 17.10 is here:launchpad untrusted to launch bug in 17.10
However this bug has been fixed

So, the problem:
1) File will not run 'there was an error launching the application'. PLEASE HELP

Where did I go wrong? I can ls into the directories and the files **ARE** there....very frustrated....
Reply
#2
This sounds like an Ubuntu problem. Have you tried Ask Ubuntu?
Reply
#3
@league55 yes. askubuntu and ubuntuforums too (python-forums is more of a last gasp...I can't possibly the only one using python to build things...)

But it is SOO frustrating. Are this few ppl building actual apps with python??? lol
Reply
#4
Did you make it executable?
sudo chmod +x /home/me/Desktop/test0.desktop
you can also do it the old GUI method by running in your terminal
gnome-desktop-item-edit --create-new ~/Desktop
Recommended Tutorials:
Reply
#5
[inline]
me@me-ubuntu:~/Desktop$ file test1.desktop
test1.desktop: ASCII text
me@me-ubuntu:~/Desktop$ sudo chmod +x /home/me/Desktop/test1.desktop
[sudo] password for me:
me@me-ubuntu:~/Desktop$ file test1.desktop
test1.desktop: ASCII text
me@me-ubuntu:~/Desktop$
me@me-ubuntu:~/Desktop$ ls -lsh *.desktop
4.0K -rwxr-xr-x 1 root root 180 Jan 25 16:15 test1.desktop
[/inline]

still an ascii file. I already sudo usermod -a -G sudo me and it is still root owned.
Wall Wall Wall Wall Wall I truly _HATE_ being new!!!
Reply
#6
to change ownership to user "me"
chown me test1.desktop
to change group ownership
chgrp group_name test1.desktop
to do both:
chown me:group_name test1.desktop

(Jan-25-2018, 10:12 PM)mepyyeti Wrote: me@me-ubuntu:~/Desktop$ sudo chmod +x /home/me/Desktop/test1.deskto
wasnt it file0?
Quote: root@me-ubuntu:~# cp /usr/share/applications/test0.desktop /home/me/Desktop
make sure you are doing the right file or just do them all
cd ~/Desktop
sudo chmod +x *.desktop
Recommended Tutorials:
Reply
#7
Didn't you forget the shebang line in your script?
#!/usr/bin/env python3
Reply
#8
@Gribouillis
You mean on the .desktop file? I added it there and corrected it on the 2 .py files (the sha-bang was missing the very '/'). So the script works now.

Thank you so much Dance Dance Dance Dance Dance

So why is the sha-bang necessary on the .desktop file then? The thought crossed my mind, but my Exec file is .py so I'm not clear why the sha-bang is necessary. I simply want to understand now.

(The experience was extremely humbling actually and omg so frustrating. I was terrified on askubuntu b/c it's a stackexchange site. And Ubuntu forums is very segregated so very little activity. It should not have taken 3 days to figure out...and the sha-bang wasn't mentioned on YT, FreeDesktop.org, or developer.gnome or on askubuntu where people saw .desktop file...very frustrating)

On a better aside...it's probably the least elegant script but in my eyes this baby is gorgeous!!! Linus Torvalds, Vitalik Buterin, GvR, and Matz got nothin on me! LOL LOL LOL just kiddin'


@metulburr
Thx for the new terminal keywords. As brutal an experience this has been, I definitely got _GOOD_ at navigating as root in the terminal...ppl make it sound like being root is the most dangerous thing in the universe, but it isn't.
Reply
#9
(Jan-26-2018, 12:30 AM)mepyyeti Wrote: [Administrators] make it sound like [users] being root is the most dangerous thing in the universe...

Corrected your typos. Big Grin
Reply
#10
(Jan-26-2018, 12:30 AM)mepyyeti Wrote: So why is the sha-bang necessary on the .desktop
Linux normally doesn't infer from the .py extension that the file must be executed with the python interpreter. It can be configured to do it by using the following command
Output:
sudo update-binfmts --install Python /usr/bin/python --extension py
One probably needs to install the binfmt-support package (for ubuntu or debian) to do this.

I would not recommend doing so, because there are currently two default python interpreters on most linux systems, namely python 2 and python 3, and both use the .py extension. Another reason is that one may potentially have more than two installs of python on the same machine, so the shebang line has the needed finer granularity.

Did you change anything to the .desktop file? In this case can you post it here, as an example of a .desktop file that works?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020