Managing File Associations in Linux Mint Cinnamon Desktop

Categories:
4 minute read
File associations determine which applications open different types of files in your Linux Mint system. Understanding and managing these associations effectively can significantly improve your workflow and user experience. This comprehensive guide will walk you through everything you need to know about handling file associations in Cinnamon Desktop.
Understanding File Associations
What Are File Associations?
File associations in Linux are connections between:
- File types (identified by extensions or MIME types)
- Default applications that open these files
- Alternative applications that can handle these files
- Icons and thumbnails associated with file types
How Linux Identifies File Types
Linux uses several methods to identify file types:
- MIME (Multipurpose Internet Mail Extensions) types
- File extensions
- File content analysis (using
file
command) - Desktop environment metadata
Managing File Associations Through the GUI
Using Cinnamon’s Preferred Applications
Access Preferred Applications:
- Open System Settings
- Navigate to Preferred Applications
- Select the “Files” tab
Default Categories:
- Text Editor
- File Manager
- Web Browser
- Terminal Emulator
- Music Player
- Video Player
- Image Viewer
Nemo File Manager Associations
Configure associations through Nemo:
- Right-click any file
- Select “Properties”
- Click “Open With” tab
- Choose default application
- Select “Set as default” to make permanent
Creating Custom Association Rules
- Access MIME type editor:
sudo apt install xdg-utils
xdg-mime default application.desktop mime-type
- Create desktop entry:
nano ~/.local/share/applications/custom-association.desktop
[Desktop Entry]
Type=Application
Name=Custom Application
Exec=/path/to/application %f
MimeType=application/x-custom-type;
Terminal=false
Categories=Utility;
Command-Line Management
Viewing Current Associations
Check existing associations:
# View MIME type of a file
file --mime-type document.pdf
# Check current association
xdg-mime query default application/pdf
# List all associations
gio mime application/pdf
Setting New Associations
Modify associations via command line:
# Set default PDF viewer
xdg-mime default org.gnome.evince.desktop application/pdf
# Set default text editor
xdg-mime default org.gnome.gedit.desktop text/plain
# Set default image viewer
xdg-mime default org.gnome.eog.desktop image/jpeg
Managing MIME Database
Update and maintain MIME database:
# Update MIME database
sudo update-mime-database /usr/share/mime
# Install new MIME type
sudo xdg-mime install custom-mimetype.xml
# Remove MIME type
sudo xdg-mime uninstall custom-mimetype.xml
Advanced Configuration
Creating Custom MIME Types
- Create MIME type definition:
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-custom">
<comment>Custom File Type</comment>
<glob pattern="*.custom"/>
<magic priority="50">
<match type="string" offset="0" value="CUSTOM"/>
</magic>
</mime-type>
</mime-info>
- Install new MIME type:
sudo xdg-mime install custom-mime.xml
Setting Up File Type Recognition
Create file type detection rules:
# Create magic file
nano ~/.magic
# Add recognition rules
0 string CUSTOM Custom file format
!:mime application/x-custom
# Compile magic file
file -C -m ~/.magic
Configuring Application Priorities
Modify application priority for file types:
- Edit mimeapps.list:
nano ~/.config/mimeapps.list
- Add priority settings:
[Default Applications]
application/pdf=org.gnome.evince.desktop
text/plain=org.gnome.gedit.desktop
[Added Associations]
application/pdf=org.gnome.evince.desktop;adobe-reader.desktop;
text/plain=org.gnome.gedit.desktop;sublime_text.desktop;
System-wide vs. User-specific Settings
System-wide Configuration
Modify global settings:
# Edit global MIME database
sudo nano /usr/share/applications/defaults.list
# Update system-wide associations
sudo nano /usr/share/applications/mimeinfo.cache
User-specific Configuration
Configure personal settings:
# Create user MIME folder
mkdir -p ~/.local/share/mime/packages
# Create user associations
nano ~/.local/share/applications/mimeapps.list
Troubleshooting Common Issues
Fixing Broken Associations
- Reset to defaults:
# Remove user associations
rm ~/.local/share/applications/mimeapps.list
# Update MIME database
update-mime-database ~/.local/share/mime
- Rebuild desktop database:
update-desktop-database ~/.local/share/applications
Handling Multiple Applications
When multiple applications claim the same file type:
- Check current handlers:
gio mime application/pdf
- Set preferred application:
xdg-mime default preferred-app.desktop application/pdf
Best Practices
Organization Strategies
Document Associations:
- Keep a list of custom associations
- Document any special configurations
- Maintain backup of settings
Regular Maintenance:
- Review associations periodically
- Remove obsolete associations
- Update application defaults
Security Considerations
Verify Applications:
- Check application sources
- Review permissions
- Validate desktop entries
Handle Unknown Types:
- Configure default behavior
- Set up warning dialogs
- Implement safety checks
Integration with Desktop Environment
Custom Actions in Nemo
Create custom “Open With” actions:
- Create action file:
nano ~/.local/share/nemo/actions/custom-open.nemo_action
- Configure action:
[Nemo Action]
Name=Open with Custom App
Comment=Open file with custom application
Exec=custom-app %F
Icon-Name=custom-app
Selection=s
Extensions=custom;
Keyboard Shortcuts
Set up shortcuts for common operations:
- Open Settings → Keyboard
- Add custom shortcuts:
- Open with default application
- Change file association
- Reset to default association
Conclusion
Effective management of file associations in Linux Mint’s Cinnamon Desktop environment requires understanding both the graphical and command-line tools available. By properly configuring and maintaining your file associations, you can create a more efficient and user-friendly computing environment.
Remember to regularly review your associations, keep documentation of custom configurations, and maintain backups of important settings. With these practices in place, you’ll have a robust system for handling different file types that enhances your productivity and user experience.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.