1`xdgctl` is a TUI for managing XDG default applications. View and set defaults for file categories without using `xdg-mime` directly.
  2
  3Built with C using [GLib/GIO](https://docs.gtk.org/gio/) and [termbox2](https://github.com/termbox/termbox2).
  4
  5https://github.com/user-attachments/assets/076c9934-f373-486d-9595-eec480e3a429
  6
  7## Features
  8
  9- Browse by category (Browsers, Text Editors, etc.)
 10- Current default marked with `*`
 11
 12## Navigation & Controls
 13
 14| Key                 | Action                                                        |
 15|---------------------|---------------------------------------------------------------|
 16| **Arrow Up/Down**   | Navigate through categories or applications                   |
 17| **Arrow Right/Tab** | Switch from category list to application list                 |
 18| **Arrow Left**      | Switch back to category list                                  |
 19| **Enter**           | Set selected application as default for current category      |
 20| **Esc / q**         | Quit the application                                          |
 21
 22## Prerequisites
 23
 24To build `xdgctl`, you need the following development libraries:
 25
 26- `glib-2.0`
 27- `gio-2.0`
 28- `gio-unix-2.0`
 29- `clang` or `gcc`
 30
 31```bash
 32# On Void Linux
 33sudo xbps-install glibc-devel pkg-config
 34```
 35
 36## Installation
 37
 38### From source
 39
 40```bash
 41git clone https://github.com/mitjafelicijan/xdgctl.git
 42cd xdgctl
 43
 44# Build
 45make
 46sudo make install
 47
 48# Using prefix
 49sudo make PREFIX=/usr/local install
 50make PREFIX=~/.local install
 51```
 52
 53If you manually add new applications to your `~/.local/share/applications` directory, you might need to run `update-desktop-database` again.
 54
 55### Arch Linux package
 56
 57[![xdgctl on AUR](https://img.shields.io/aur/version/xdgctl?label=xdgctl)](https://aur.archlinux.org/packages/xdgctl/)
 58[![xdgctl-git on AUR](https://img.shields.io/aur/version/xdgctl-git?label=xdgctl-git)](https://aur.archlinux.org/packages/xdgctl-git/)
 59
 60xdgctl is available on the [AUR](https://wiki.archlinux.org/index.php/Arch_User_Repository):
 61
 62- [xdgctl](https://aur.archlinux.org/packages/xdgctl/) (release package)
 63- [xdgctl-git](https://aur.archlinux.org/packages/xdgctl-git/) (git package)
 64
 65You can install it using your [AUR helper](https://wiki.archlinux.org/index.php/AUR_helpers) of choice.
 66
 67Example:
 68
 69```console
 70yay -Sy xdgctl
 71```
 72
 73## More about XDG
 74
 75### Application directories
 76
 77```bash
 78ls /usr/share/applications
 79ls ~/.local/share/applications
 80```
 81
 82### Querying defaults
 83
 84```bash
 85xdg-mime query default text/plain
 86xdg-mime query default text/html
 87xdg-mime query default x-scheme-handler/http
 88xdg-mime query default x-scheme-handler/https
 89xdg-mime query default inode/directory
 90```
 91
 92### Setting defaults manually
 93
 94```bash
 95xdg-mime default brave.desktop x-scheme-handler/http
 96xdg-mime default brave.desktop x-scheme-handler/https
 97```
 98
 99### Desktop Entry example
100
101```ini
102# ~/.local/share/applications/brave.desktop
103[Desktop Entry]
104Exec=/home/m/Applications/brave
105Type=Application
106Categories=Applications
107Name=Brave Browser
108MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;
109```
110
111### Other useful commands/files
112
113```bash
114update-desktop-database ~/.local/share/applications
115less ~/.config/mimeapps.list
116less /usr/share/applications/mimeapps.list
117```
118
119## More material
120
121- https://commandmasters.com/commands/xdg-mime-linux/
122- https://noman.sh/en/pages/xdg-mime
123- https://linux.die.net/man/1/xdg-mime
124- https://wiki.archlinux.org/title/XDG_MIME_Applications
125- https://gnome.pages.gitlab.gnome.org/libsoup/gio/
126- https://docs.gtk.org/gio/