Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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?
(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.
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?
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).
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.