From 47db71fe3ea267086451d5f7a04edb1d2b72ea66 Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Fri, 23 Feb 2024 13:54:03 +0100 Subject: [PATCH] docs: XDG mime types --- NixOS.md | 55 +++++++++++++++++++++++++++++++++++++++++++ modules/autostart.nix | 4 ---- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/NixOS.md b/NixOS.md index 64cefe4..23a7bd3 100644 --- a/NixOS.md +++ b/NixOS.md @@ -31,6 +31,7 @@ This document contains general notes about NixOS that are independent of my NixO * [Run AppImages](#run-appimages) * [Audio troubleshooting - Realtek ALC898 Audio Codec on ASRock Z77 Extreme 4](#audio-troubleshooting---realtek-alc898-audio-codec-on-asrock-z77-extreme-4) * [Graphic drivers](#graphic-drivers) + * [XDG mimes, desktop files](#xdg-mimes-desktop-files) * [Additional resources](#additional-resources) * [Nix Pills](#nix-pills) * [Papers](#papers) @@ -791,6 +792,60 @@ Configuration example to disable integrated GUP: See [./hosts/yodaGaming/configu Configuration example for an AMD GPU (https://github.com/tolgaerok/nixos-kde/blob/main/core/gpu/amd/default.nix): See [./modules/gpu-amd.nix](./modules/gpu-amd.nix) +## XDG mimes, desktop files + +Desktop files: +- `/run/current-system/sw/share/applications` +- `/etc/profiles/per-user/yoda/share/applications/` + +Both above sub-paths are part of the `XDG_DATA_DIRS` variable: +- `echo $XDG_DATA_DIRS | grep /run/current-system/sw/share` +- `echo $XDG_DATA_DIRS | grep /etc/profiles/per-user/yoda/share` + +List default apps and the associated handlers: + +```shell +handlr list +``` +```console +┌────────────────────────────────┬─────────────────────────────────────────┐ +│ application/octet-stream │ thunderbird.desktop │ +│ ... │ │ +│ x-scheme-handler/sgnl │ signal-desktop.desktop │ +└────────────────────────────────┴─────────────────────────────────────────┘ +``` + +Set default handler for mime/extension: + +```shell +handlr set text/html re.sonny.Junction.desktop +``` + +Open any URI with `handlr`: + +```shell +handlr open https://wikipedia.org +``` + +Open any URI with `gio`, part of `glib`: + +```shell +gio open https://wikipedia.org +``` + +- Note: `gio open` does not follow the XDG spec. https://discourse.nixos.org/t/configure-how-xdg-open-opens-html-files/6419/23 + +Further examples: + +```shell +xdg-settings get default-web-browser +#=> re.sonny.Junction.desktop +xdg-mime query default x-scheme-handler/http and x-scheme-handler/https +#=> re.sonny.Junction.desktop +xdg-mime query default text/html +#=> firefox.desktop +``` + ## Additional resources * Simple NixOS flake template for NixOS with HomeManager. https://github.com/Misterio77/nix-starter-configs#readme diff --git a/modules/autostart.nix b/modules/autostart.nix index 7f27ad9..98424e9 100644 --- a/modules/autostart.nix +++ b/modules/autostart.nix @@ -3,10 +3,6 @@ # See also: # Temporary workaround until https://github.com/nix-community/home-manager/issues/3447 is merged. - # Desktop files: - # /run/current-system/sw/share/applications - # /etc/profiles/per-user/yoda/share/applications/ - home-manager.users.yoda = { osConfig, config, pkgs, ... }: { home.file."keepassxc" = { target = ".config/autostart/org.keepassxc.KeePassXC.desktop";