LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-24-2020, 01:11 PM   #1
MPS$mps
LQ Newbie
 
Registered: Nov 2016
Posts: 2

Rep: Reputation: Disabled
Question Editing .desktop files


I'm running Debian Buster (10.2), and wish to cause my Firefox browser
desktop icon's label to AUTOMATICALLY include the version number of Firefox I am using.
The .desktop file currently is:
****************************************************************************
#!/usr/bin/env xdg-open

[Desktop Entry]
Name=Firefox
Comment=Browse the World Wide Web
GenericName=Web Browser
X-GNOME-FullName=Firefox Web Browser
Exec=/opt/firefox/firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/firefox/browser/chrome/icons/default/default48.png
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;
StartupWMClass=Firefox
StartupNotify=true
Name[en_GB]=Firefox /bin/cat /opt/firefox/application.ini:8
****************************************************************************
Where I had expected the "/bin/cat /opt/firefox/application.ini:8" to yield the version number of "72.0.2", therefore giving the label under the Firefox icon as "Firefox 72.0.2".

But instead, the label reads "Firefox /bin/cat /opt/firefox/application.ini:8"

Is there anyone who knows how to get the version number of an application
to AUTOMATICALLY be a part of the application's Desktop icon's label?

Thanks in advance!
 
Old 01-24-2020, 09:09 PM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Code:
Name=Firefox 72.0.2
you could write a little script to sed your desktop file and update the version every time it is updated.

Last edited by BW-userx; 01-24-2020 at 09:18 PM.
 
Old 01-24-2020, 09:11 PM   #3
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
Yeah, but the OP is trying to get something set up so that the name updates with the correct version each time the FF is updated. Just editing NAME won't do that. Good suggestion, though.
 
Old 01-24-2020, 09:43 PM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by vtel57 View Post
Yeah, but the OP is trying to get something set up so that the name updates with the correct version each time the FF is updated. Just editing NAME won't do that. Good suggestion, though.
because it is not a script and I do not think it can be seen as one either, so it cannot be include within the file itself, therefore, a simple one liner placed within a a script then placed within ones home bin with the path set in the .bashrc to that dir then off the cli just call the script name.
Code:
[[ -d $HOME/bin ]] && { PATH=$PATH:$HOME/bin ; }
Code:
$ sed  's/Name.*/Name='"$(firefox -v)"'/' /home/userx/Desktop/delteme.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Mozilla Firefox 72.0.2
Comment=Browse the World Wide Web
GenericName=Mozilla Firefox 72.0.2
X-GNOME-FullName=Mozilla Firefox 72.0.2
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=firefox
Categories=Network;WebBrowser;
as one can see this works. where the set Name in the file itself is Name=Firefox 72.0.2

yes, sometimes we have to make adjustments to how we do things to get the desired effects in what it is one wants to do. so a manual running of a simple script is all that would be needed in this case, and even could be set up to be automated if one want to take on that endeavor.

Last edited by BW-userx; 01-24-2020 at 09:45 PM.
 
1 members found this post helpful.
Old 01-25-2020, 09:43 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by MPS$mps View Post
I'm running Debian Buster (10.2), and wish to cause my Firefox browser
desktop icon's label to AUTOMATICALLY include the version number of Firefox I am using.
The .desktop file currently is:
****************************************************************************
#!/usr/bin/env xdg-open

[Desktop Entry]
Name=Firefox
Comment=Browse the World Wide Web
GenericName=Web Browser
X-GNOME-FullName=Firefox Web Browser
Exec=/opt/firefox/firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/firefox/browser/chrome/icons/default/default48.png
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;
StartupWMClass=Firefox
StartupNotify=true
Name[en_GB]=Firefox /bin/cat /opt/firefox/application.ini:8
****************************************************************************
Where I had expected the "/bin/cat /opt/firefox/application.ini:8" to yield the version number of "72.0.2", therefore giving the label under the Firefox icon as "Firefox 72.0.2".

But instead, the label reads "Firefox /bin/cat /opt/firefox/application.ini:8"

Is there anyone who knows how to get the version number of an application
to AUTOMATICALLY be a part of the application's Desktop icon's label?

Thanks in advance!
Are you saying the file actually contains the string "#!/usr/bin/env xdg-open"??? Strange, never seen that.

Please use CODE tags for code and output from now on.

First things first: you can get the version with 'firefox -v'

You want it automated - triggered how? On upgrade? How did you install? How do you upgrade FF?
 
Old 01-25-2020, 10:08 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
(If I understand well) that is a static entry in the desktop file. If you wish to update it you need to write a script to look for the version info and put it into this file.
 
1 members found this post helpful.
Old 01-25-2020, 10:56 AM   #7
Geist
Member
 
Registered: Jul 2013
Distribution: Slackware 14 / current
Posts: 442

Rep: Reputation: 196Reputation: 196
How about a potentially galaxy brained solution:
Writing a pseudo device (like /dev/null ) that generates the content of the desktop file when read (and of course symlinked to where it would be).

Probably overkill, but...gotta get that *nix knowledge somehow, or something, right?

Note: I actually don't really know what I'm talking about here, but if this is feasible, then why not do it for fun?
 
Old 01-26-2020, 02:47 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
If FF is installed via package management then it's not so difficult to trigger a sed to the .desktop file after every upgrade.
 
Old 01-31-2020, 03:18 PM   #9
MPS$mps
LQ Newbie
 
Registered: Nov 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
Editing .desktop files

To BW-userx: vtel57's reply nailed my intention, but using your method (if I understand it- your description is not entirely clear) is only slightly easier than manually editing the firefox.desktop file. Anyway, amen to your rules 1-5!

To ondoho: Yes, the firefox.desktop file REALLY does lead off with the string "#!/usr/bin/env xdg-open". Maybe it's just a Debian thing? IDK. And I want the new version number triggered on upgrade. BTW, am I using the code tag properly here?:

Code:
#!/usr/bin/env xdg-open

[Desktop Entry]
Name=Firefox
Comment=Browse the World Wide Web
GenericName=Web Browser
X-GNOME-FullName=Firefox Web Browser
Exec=/opt/firefox/firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/firefox/browser/chrome/icons/default/default48.png
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;
StartupWMClass=Firefox
StartupNotify=true
Name[en_GB]=Firefox /bin/cat /opt/firefox/application.ini:8
And lastly, it would appear that the proper use of sed is what I need, but right now, my sed-fu is zero. See my response to Geist, below.

To pan64: I can be dense, but not THAT dense!

To Geist: Yeah. It's like, everything's a RESEARCH PROJECT!

NOW: Can someone instruct me on how to respond to future repliers INDIVIDUALLY? I've searched LQ's faq and tutorial to no avail (or perhaps it's Noah Wylie).
 
Old 01-31-2020, 04:31 PM   #10
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
it is a simple sed command find and replace. Using bash varitable handling.
Code:
sed  's/Name.*/Name='"$(firefox -v)"'/' /home/userx/Desktop/delteme.desktop
break it down now...

basic set up
Code:
sed /find/replace/
find the word 'NAME' in file
Code:
sed 's/Name.*" <-- gets name and anything after that using .*
replace. get the version of current installed firefox (in PATH).
Code:
$ echo $(firefox -v)
Mozilla Firefox 68.1.0esr
what sed does automatically is get the value within the $( ) of
hence issuing that command and file to sed will change every instance of NAME with the output of 'firefox -v'
so
NAME=Firefox now equals NAME=Mozilla Firefox 68.1.0esr

more constraints can be put on it, and editing the "Mozilla Firefox 68.1.0esr" to make it maybe 'Firefox 68.1.0esr' too can be done in a script or command line. by cutting the output first then using the results for sed command. but that is a earning curve.

before
Code:
$ cat mozilla-firefox.desktop
[Desktop Entry]
Exec=firefox %u
Icon=firefox
Type=Application
Categories=Network;WebBrowser;
Name=Firefox
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
X-KDE-StartupNotify=true
after
Code:
$ sed 's/Name.*/Name='"$(firefox -v)"'/' mozilla-firefox.desktop
[Desktop Entry]
Exec=firefox %u
Icon=firefox
Type=Application
Categories=Network;WebBrowser;
Name=Mozilla Firefox 68.1.0esr
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
X-KDE-StartupNotify=true
list stated before in here, you can add that to a after update hook to run it then automatically.

Last edited by BW-userx; 01-31-2020 at 04:42 PM.
 
Old 01-31-2020, 09:26 PM   #11
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
> NOW: Can someone instruct me on how to respond to future repliers INDIVIDUALLY?

You can manually multi-quote everyone you care to reply to in a single posting by manually coding the quotes with UBBCode:

[quote ]poster's text[/quote ] --> no space before the closing brackets*

You can also add the poster's username to the quote like this:

[quote=vtel57 ]vtel57's text[/quote ] --> again remove space before closing brackets*

*I added the space so that the board's software would not parse the code, so you could see it.

Quote:
Poster 1's text here.
Then add your reply.

Quote:
Poster 2's text here.
Your reply.

Quote:
Poster 3's text here.
And so on.

Or you can quote and reply to each poster in a separate reply; not too efficient, though.

If I've totally missed what you're trying to ask above, just holler louder. I'm old.

And if anyone else here knows a better way to multi-quote, please chime in.

Later...

~Eric
 
Old 02-03-2020, 01:19 AM   #12
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Now you learned how to use sed, the next step would be this:
https://www.cyberciti.biz/faq/debian...grade-command/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing Indicator 'internet' plugn menu on XFCE desktop wej1971 Linux - Newbie 2 11-22-2011 03:10 PM
ubuntu-desktop vs. kubuntu-desktop vs. xubuntu-desktop vs. lubuntu-desktop vs. unity Kenny_Strawn Ubuntu 18 05-13-2011 09:20 AM
LXer: The Fedora Desktop User Guide needs some editing LXer Syndicated Linux News 0 03-19-2007 11:31 PM
Editing configurations manually for Remote Desktop greeklegend Ubuntu 1 10-19-2006 07:23 AM
editing desktop menu rh9.0 reddog Red Hat 1 02-23-2006 11:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration