blob: 496ed129da683858e4448b1dda0f6215ef8fd9fe (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# nixos-config - My current NixOS configuration
#
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of my nixos-config.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
{
pkgs,
lib,
config,
...
}: let
lf-wrapper = pkgs.writeShellApplication {
name = "lf-wrapper";
runtimeInputs = [pkgs.lf pkgs.alacritty];
inheritPath = true;
text = builtins.readFile ./scripts/lf-wrapper.sh;
};
url-handler = pkgs.writeShellApplication {
name = "url-handler";
runtimeInputs = [pkgs.rofi pkgs.libnotify pkgs.zathura pkgs.tskm];
# We need to run the browser in tskm or nvim and alacritty.
inheritPath = true;
text = builtins.readFile ./scripts/url-handler.sh;
};
tfcConfigFile = (pkgs.formats.ini {}).generate "xdg-desktop-portal-termfilechooser.ini" {
filechooser = {
default_dir = "/tmp";
cmd = "${lib.getExe lf-wrapper}";
};
};
cfg = config.soispha.xdg;
in {
options.soispha.xdg = {
enable = lib.mkEnableOption "xdg";
};
config = lib.mkIf cfg.enable {
home-manager.users.soispha = {
xdg = {
configFile."xdg-desktop-portal-termfilechooser/config".source = tfcConfigFile;
desktopEntries = {
url-handler = {
name = "url-handler";
genericName = "Web Browser";
exec = "${lib.getExe url-handler} %u";
terminal = false;
categories = [
"Application"
"Network"
"WebBrowser"
];
mimeType = [
"text/html"
"text/xml"
"x-scheme-handler/http"
"x-scheme-handler/https"
"x-scheme-handler/about"
"x-scheme-handler/unknown"
];
};
};
};
};
services.dbus.enable = true;
xdg = {
mime = {
enable = true;
defaultApplications = {
"application/pdf" = ["url-handler.desktop"];
"application/x-pdf" = ["url-handler.desktop"];
"text/html" = ["url-handler.desktop"];
"text/xml" = ["url-handler.desktop"];
"x-scheme-handler/http" = ["url-handler.desktop"];
"x-scheme-handler/https" = ["url-handler.desktop"];
"x-scheme-handler/about" = ["url-handler.desktop"];
"x-scheme-handler/unknown" = ["url-handler.desktop"];
};
};
portal = {
enable = true;
wlr = {
enable = true;
};
config = {
common = {
# NOTE: The next entry is supposedly needed for gtk based apps <2023-08-31>
default = ["wlr" "gtk"];
"org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"];
};
# TODO: Also activate, when on another wlr-based compositor <2023-11-25>
river = {
default = ["wlr" "gtk"];
"org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"];
};
};
extraPortals = [
pkgs.xdg-desktop-portal-gtk
pkgs.xdg-desktop-portal-wlr
pkgs.xdg-desktop-portal-termfilechooser
];
};
};
systemd.user.services.xdg-desktop-portal-termfilechooser = {
serviceConfig.ExecStart = [
""
"${pkgs.xdg-desktop-portal-termfilechooser}/libexec/xdg-desktop-portal-termfilechooser --loglevel=TRACE"
];
};
};
}
|