steph
steph

Reputation: 333

How to read a .desktop file to get icon file path?

I have a .desktop file and I want to read the icon png image file path in javascript so I can display it in my html file. How would I go about doing this?

This is what my .desktop file looks like:

[Desktop Entry]
Version=1.0
Name=BackMeUp
Comment=Back up your data with one click
Exec=/home/alex/Documents/backup.sh
Icon=/home/alex/Pictures/backup.png
Terminal=false
Type=Application
Categories=Utility;Application;

Any help would be greatly appreciated!

Upvotes: 0

Views: 336

Answers (1)

Johnson Lee
Johnson Lee

Reputation: 179

If the javascript you saying is only the javascript in browser, it's impossible except you upload the file to a server and analyze it.

1.browser javascript and server

First of all you should have a form that you can upload your .desktop file, and then you upload to a server(you can use node.js to build a server).

After the server received it, you can read its content as text and find the line of Icon and then response to browser

2. serverside javascript: node.js

if you can use node.js for reading this file, it's much easier.

just install node.js and build a .js file and use fs.readFileSync to read the .desktop file and analyze it line by line.

Upvotes: 2

Related Questions