Skip to content

Instantly share code, notes, and snippets.

@schtobia
Created May 29, 2018 09:08
Show Gist options
  • Save schtobia/d44f4a52ddfed0dae4506dd69d931275 to your computer and use it in GitHub Desktop.
Save schtobia/d44f4a52ddfed0dae4506dd69d931275 to your computer and use it in GitHub Desktop.
Open .desktop files under bash
  1. check if dex is installed:

    vimes ~ » [ -x "$(which dex)" ] && echo "Dex is installed." || echo "Dex is not installed."
    Dex is not installed.
    vimes ~ » 
    
  2. so, install dex:

    vimes ~ » sudo apt install dex
    [sudo] Passwort für schtobia: 
    […]
    vimes ~ » 
    
  3. check if dex is working:

    vimes ~ » dex .local/share/applications/<your desktop file in here>
    <should open in a new window>
    
  4. create desktop file for dex:

    vimes ~ » dex -c "$(which dex)" -t ~/.local/share/applications/
    vimes ~ » cat ~/.local/share/applications/dex.desktop
    [Desktop Entry]
    Exec=/usr/bin/dex
    Name=dex
    Comment=DesktopEntry Execution
    Type=Application
    vimes ~ » 
    
  5. check if xdg-mime is set for application/x-desktop:

    vimes ~ » xdg-mime query default application/x-desktop
    vimes ~ » 
    
  6. set xdg-mime for application/x-desktop:

    vimes ~ » xdg-mime default dex.desktop application/x-desktop
    vimes ~ » 
    
  7. make the desktop file executable:

    vimes ~ » chmod +x .local/share/applications/<your desktop file in here>
    vimes ~ » 
    
  8. now, call the desktop file directly:

    vimes ~ » .local/share/applications/<your desktop file in here>
    <should open in a new window>
    
  9. optionally, you can symlink this desktop file in a $PATH enabled directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment