The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 1,520β€…    Votes:  2β€…    βœ… Solution
Tags: bash   files   default-programs   mime-type   yad  
Link: πŸ” See Original Question on Ask Ubuntu ⧉ πŸ”—

URL: https://askubuntu.com/q/912370
Title: List of file types and default Ubuntu applications to open with
ID: /2017/05/06/List-of-file-types-and-default-Ubuntu-applications-to-open-with
Created: May 6, 2017    Edited:  May 7, 2017
Upload: September 15, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


I’m writing a humble file manager and am seeking a list of different file types and what default applications Ubuntu uses to open them with.

So far I’ve only figured out β€œtext” open with gedit, β€œimage” open with eog (eye-of-gnome) and β€œaudio” open with ogg123. I’m not sure if ogg123 is a default application though.

I’d appreciate a little help expanding the list in the code below:

function OpenFileWithMagic () {

local FileType
FileType=$(file -i "$DfName/$2" | grep -oP '(?<=: ).*?(?=/)')
logger "bafman - OpenFileWithMagic - FileType: $FileType DfName: - $DfName parm 1: $1 2: $2 3: $3 4: $4"

case $FileType in

text)
    # TODO: expand list of file types and associated applications to open them with
    if [[ $4 == root ]]; then
        gsu gedit $DfName/$2
    else
        gedit $DfName/$2
    fi ;;
image)
    eog $DfName/$2 ;;
audio)
    ogg123 $DfName/$2 ;;
esac

} ### OpenFileWithMagic ()
export -f OpenFileWithMagic

Notes: export is only required because file is opened when double-clicking from yad dialog box. I also need help figuring out β€œmagic” numbers and how one might interpret them. Perhaps an educating link?


Edit This is not a duplicate of How to open file with default application from command line?e because:

    gvfs-open: /bin/mv: error opening location: No application is registered as handling this file
    /bin/mv: application/x-executable; charset=binary

After filtering out processing for all desired file types within the bash script then the left overs could be passed to xdg-open which is used in the duplicate candidate.


Reply to comments As pointed out by DK Bose major file types can be found in /usr/share/mime/types. Here there are additional types to be considered such as Video (a suitable default Ubuntu video player needs to be sourced), Application (rather than running it, info about the application needs to be displayed) and Message (I have no clue how to display this). Additional mime types needing further research are inode, model, multipart and x-content.

rinzwind pointed out ogg123 is not a default sound file player in Ubuntu. A suitable installed-by-default Ubuntu application to play sound files is canberra-gtk-play as answered October 5, 2016 by wjzndrea in this Q&A: Can line draw characters (or colors) be added to a Bash file list menu?.

⇧ Can't upgrade due to low disk space on /boot How to speed up 1/2 hour to sort 133 new entries in 2,700 entry Bash Array in RAM?  β‡©