https://github.com/demonstrandum/mimetype-xml
Custom mimetypes from TOML to XML
https://github.com/demonstrandum/mimetype-xml
config custom gnome icon-pack icons linux mime mime-types mimetype toml xml
Last synced: about 1 month ago
JSON representation
Custom mimetypes from TOML to XML
- Host: GitHub
- URL: https://github.com/demonstrandum/mimetype-xml
- Owner: Demonstrandum
- License: gpl-2.0
- Created: 2017-09-03T19:41:57.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-23T17:45:12.000Z (almost 9 years ago)
- Last Synced: 2025-03-21T04:47:10.140Z (over 1 year ago)
- Topics: config, custom, gnome, icon-pack, icons, linux, mime, mime-types, mimetype, toml, xml
- Language: Ruby
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MimetypeXML
> Custom mimetype from TOML to XML
## Install
- You need Ruby and Gems (gems comes with ruby)
Install this gem with
```shell
gem install mimetype-xml
# You might want to run this with sudo,
# or add the Gem userdir to the beginning of your $PATH variable
# like so in your bashrc: `PATH=$(ruby -e 'print Gem.user_dir')/bin:$PATH`
# This depends on your platform.
```
## Usage
Create the TOML config (`./custom-mime.toml`):
```toml
## CUSTOM MIMETYPES TOML CONFIG FILE ##
# Optional variables ard marked with `(opt.)` in a
# comment at the end of the line
# Add mimetype for elixir files
[x-application-elixir]
type = "application/x-elixir"
pattern = ["*.ex", "*.exs"] # Always in an array
# (even if only one pattern, e.g. ["*.ext"])
comment = "Elixir File" # Default language
comment_lang = [ ["no", "Elixir Fil"], ["la", "Ordo Elixir"] ] # etc. (opt.)
icon = "mimetypes/application-x-elixir.svg"
size = 48 # I don't really know
xml_file = "elixir-file-mimetype.xml" # (opt.), not useful...
# Another for crystal files
[x-application-crystal]
type = "application/x-crystal"
pattern = ["*.cr"]
comment = "Crystal File"
icon = "mimetypes/application-x-crystal.svg"
size = 48
# That simple to add new mimetypes, just make the icon in the
# path specified in the `icon` variable.
# e.g. 'mimetypes/appliaction-x-myfile.svg'
```
Then generate the xml files and install it through a ruby script (`./generate-mimetypes.rb`):
```ruby
require 'mimetype_xml'
require 'toml' # `toml` comes with this gem (`mimetype_xml`)
xml = MimetypeXML::Generate.toml_file(
:file => './custom-mime.toml', # The location of the TOML config
:xml_dir => '/usr/share/mime/packages/', # Make sure the dir is writable for the user, run `sudo chmod 777 /usr/share/mime/packages/`
:icon_pack => '~/.icons/YOUR_ICON_PACK' # Replace this with the install dir of your iconpack
)
files = xml.write_files
files.install
```
Then run the script from your shell:
```shell
ruby ./generate-mimetypes.rb
```
---
The binary file doesn't do anything at the moment.