-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix default PDF reader when open in GNOME (#1038)
- Loading branch information
Showing
2 changed files
with
20 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
{ lib, pkgs, ... }: | ||
{ lib, ... }: | ||
|
||
let | ||
defaultBrowser = [ | ||
"google-chrome.desktop" | ||
"firefox.desktop" | ||
]; | ||
in | ||
{ | ||
imports = [ ./gnome.nix ]; | ||
|
||
# https://github.com/nix-community/home-manager/blob/release-24.11/modules/home-environment.nix# | ||
# https://github.com/nix-community/home-manager/blob/release-24.11/modules/lib/dag.nix | ||
home = { | ||
activation = { | ||
# defaultApplications in xdg=* modules do not support except mime types. So required this for hotkey use | ||
setDefaultBrowser = lib.hm.dag.entryAfter [ "writeBoundary" ] '' | ||
run '${pkgs.xdg-utils}/bin/xdg-settings' set 'default-web-browser' 'google-chrome.desktop' | ||
''; | ||
}; | ||
}; | ||
|
||
xdg = { | ||
# https://github.com/nix-community/home-manager/blob/release-24.11/modules/misc/xdg-mime-apps.nix - different of https://github.com/NixOS/nixpkgs/blob/nixos-24.11/nixos/modules/config/xdg/mime.nix | ||
mimeApps = { | ||
enable = false; # Avoiding error: bin/xdg-mime: line 1002: hm_mimeapps.list.new: Read-only file system | ||
defaultApplications = { | ||
"application/pdf" = [ | ||
"google-chrome.desktop" | ||
"firefox.desktop" | ||
]; | ||
}; | ||
enable = true; | ||
# Don't use `xdg-settings set default-web-browser`. | ||
# https://github.com/nix-community/home-manager/issues/96#issuecomment-343650659 is old. Using both made errors such as https://github.com/kachick/dotfiles/pull/1038#discussion_r1910360832 | ||
# So use only xdg.mimeApps | ||
defaultApplications = lib.genAttrs [ | ||
"text/html" | ||
"x-scheme-handler/http" | ||
"x-scheme-handler/https" | ||
"x-scheme-handler/about" | ||
"x-scheme-handler/unknown" | ||
"application/pdf" # I prefer to open PDF with reader, editor is not frequently used. | ||
] (_: defaultBrowser); | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters