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! |
Code:
Name=Firefox 72.0.2 |
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.
|
Quote:
Code:
[[ -d $HOME/bin ]] && { PATH=$PATH:$HOME/bin ; } Code:
$ sed 's/Name.*/Name='"$(firefox -v)"'/' /home/userx/Desktop/delteme.desktop 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. |
Quote:
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? |
If FF is installed via package management then it's not so difficult to trigger a sed to the .desktop file after every upgrade.
|
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 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 basic set up Code:
sed /find/replace/ Code:
sed 's/Name.*" <-- gets name and anything after that using .* Code:
$ echo $(firefox -v) 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 Code:
$ sed 's/Name.*/Name='"$(firefox -v)"'/' mozilla-firefox.desktop |
> 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:
Quote:
Quote:
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 |
Now you learned how to use sed, the next step would be this:
https://www.cyberciti.biz/faq/debian...grade-command/ |
All times are GMT -5. The time now is 10:36 AM. |