Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: How to know the binary name of an application to run it from the Terminal??

  1. #11
    Join Date
    Dec 2007
    Beans
    12,521

    Re: How to know the binary name of an application to run it from the Terminal??

    Quote Originally Posted by schragge View Post
    @vasa1
    I've edited my post, please take another look.
    PS. I don't have LibreOffice installed, so cannot test it.
    It's nearly perfect. Could you also incorporate the name of the .desktop file?

    BTW, now this is how the LibreOffice ones look like:
    Code:
    Exec=libreoffice3.6 --base %U
    Name=LibreOffice 3.6 Base
    Name=New Database
    Exec=libreoffice --base %U
    
    Exec=libreoffice3.6 %U
    Name=LibreOffice 3.6 Legacy StarOffice 5 Binary Format Importer
    
    Exec=libreoffice3.6 --calc %U
    Name=LibreOffice 3.6 Calc
    Name=New Spreadsheet
    Exec=libreoffice --calc %U
    
    Exec=libreoffice3.6 --draw %U
    Name=LibreOffice 3.6 Draw
    Name=New Drawing
    Exec=libreoffice --draw %U
    
    Exec=libreoffice3.6 --impress %U
    Name=LibreOffice 3.6 Impress
    Name=New Presentation
    Exec=libreoffice --impress %U
    
    Exec=libreoffice3.6 --writer %U
    Name=LibreOffice 3.6 Small Device Format Importer
    
    Exec=libreoffice3.6 --math %U
    Name=LibreOffice 3.6 Math
    Name=New Formula
    Exec=libreoffice --math %U
    
    Exec=libreoffice3.6-printeradmin
    Name=LibreOffice 3.6 Printer Administration
    
    Exec=libreoffice3.6 %U
    Name=LibreOffice 3.6 
    
    Exec=libreoffice3.6 --writer %U
    Name=LibreOffice 3.6 Writer
    Name=New Document
    Exec=libreoffice --writer %U
    
    Exec=libreoffice3.6 %U
    Name=LibreOffice 3.6 XSLT based filters

  2. #12
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: How to know the binary name of an application to run it from the Terminal??

    @vasa1
    From what I can see all Exec= lines from the same .desktop file are identical. I could output only the last of them after all Name= lines, like this:
    Code:
    sed -ns '/^Name=/p;/^Exec=/h;${g;s/$/\n/p}' /usr/share/applications/*.desktop
    To get filenames you probably should use awk instead of sed as it has FILENAME variable. The latest GNU sed version 4.2.2 includes new command F just for this, but it's not yet in Debian. In awk, it's something like
    Code:
    awk '
     /^Name=/;
     /^Exec=/  {x=$0}
     NR!=1&&FNR==1 {printf "%s\nIn: %s\n\n",x,FILENAME}
     END {printf "%s\nIn: %s\n\n",x,FILENAME}
    ' /usr/share/applications/*.desktop
    or, if written in one line
    Code:
    awk -vfmt='%s\nIn: %s\n\n' '/^Name=/;/^Exec/{x=$0}NR!=1&&FNR==1{printf fmt,x,FILENAME}END{printf fmt,x,FILENAME}' /usr/share/applications/*.desktop
    Last edited by schragge; April 1st, 2013 at 12:53 PM.

  3. #13
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How to know the binary name of an application to run it from the Terminal??

    LO has 2 sections in .desktop files: standard [Desktop Entry] and [X-new Shortcut Group]. I'd ignore the latter completely.
    Similar thing with transmission (+2 sections), totem (+5) and probably many others.

    in let's say awk i'd switch matching on when [[]Desktop Entry[]] and off when any other [[].*[]]


    edit: something like this should work
    Code:
    for f in /usr/share/applications/*.desktop; do sed -rn '/^\[Desktop Entry\]/,/^\[.*\]/{/^(Name|Exec)=/p}' "$f" | sort -r; echo; done
    Last edited by Vaphell; March 12th, 2013 at 07:21 PM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  4. #14
    Join Date
    Oct 2009
    Location
    Elgin, IL USA
    Beans
    3,363
    Distro
    Ubuntu 16.10 Yakkety Yak

    Re: How to know the binary name of an application to run it from the Terminal??

    One other command that I don't think anyone mentioned here yet is apropos. That lists man pages related to a search term which would likely commands and man pages explaining how to use them (command line arguments, etc.). Although, sometimes that can result in a long list and if you want to browse through it, you may want to pipe it to less:
    Code:
    apropos file | less
    i5 650 3.2 GHz upgraded to i7 870, 16 GB 1333 RAM, nvidia GTX 1060, 32" 1080p & assorted older computers

  5. #15
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: How to know the binary name of an application to run it from the Terminal??

    Quote Originally Posted by Vaphell View Post
    in let's say awk i'd switch matching on when [[]Desktop Entry[]] and off when any other [[].*[]]
    Then probably something like this would be enough
    Code:
    awk '
     FNR==1{pf=0;printf "\nFile: %s\n", FILENAME}
     /^\[Desktop Entry\]$/{pf=1;next}
     /^\[/{pf=0}
     pf>0&&/^(Name|Exec)=/{sub(/=/,": ");print}
    ' /usr/share/applications/*.desktop
    Or, with GNU sed 4.2.2 (hopefully to be included in Ubuntu after raring):
    Code:
    sed -ns '1F;/^\[Desktop Entry\]/,/^\[/{/^Name=/p;/^Exec=/h};${z;x;G;p}' /usr/share/applications/*.desktop
    Update.
    I also converted the output format to dctrl (Debian control file). This allows for interesting effects when e.g. piping the result into dctrl-tools. Consider something like
    Code:
    sed -nrs '/^\[Desktop Entry\]/,/^\[/{s/^(Name|Exec)=/\1: /p};${z;p}' /usr/share/applications/*.desktop|sort-dctrl -kName|tbl-dctrl -cName:30 -cExec:43
    Last edited by schragge; April 1st, 2013 at 02:00 PM.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •