fix: try to make firefox the default browser

This commit is contained in:
ryan4yin
2023-05-28 13:45:30 +08:00
parent 967b408e41
commit 3d93f5e624
12 changed files with 120 additions and 75 deletions

View File

@@ -14,6 +14,8 @@ This repository is home to the nix code that builds my systems.
- auto unlock with `ssh-agent` after login - auto unlock with `ssh-agent` after login
- [People using ssh-agent, how do you unlock it on login? - reddit](https://www.reddit.com/r/NixOS/comments/lsbo9a/people_using_sshagent_how_do_you_unlock_it_on/) - [People using ssh-agent, how do you unlock it on login? - reddit](https://www.reddit.com/r/NixOS/comments/lsbo9a/people_using_sshagent_how_do_you_unlock_it_on/)
- update scripts for i3wm, especially rofi & screenshot - update scripts for i3wm, especially rofi & screenshot
- fix `xdg-open`: after set `firefox.desktop` as defaultApplication, NixOS returned error `no apps installed that can open "https://baidu.com"`
- `Xcursor.size` do not take effect in i3
## Why Nix? ## Why Nix?

View File

@@ -1,8 +1,6 @@
{config, pkgs, ...}: let {config, pkgs, ...}:
d = config.xdg.dataHome;
c = config.xdg.configHome; {
cache = config.xdg.cacheHome;
in rec {
home.packages = with pkgs; [ home.packages = with pkgs; [
neofetch neofetch
nnn # terminal file manager nnn # terminal file manager
@@ -72,10 +70,6 @@ in rec {
}; };
}; };
services = {
# syncthing.enable = true;
};
programs.bash = { programs.bash = {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;
@@ -84,29 +78,6 @@ in rec {
''; '';
}; };
# add environment variables
systemd.user.sessionVariables = {
# clean up ~
LESSHISTFILE = cache + "/less/history";
LESSKEY = c + "/less/lesskey";
WINEPREFIX = d + "/wine";
# set this variable make i3 failed to start
# related issue:
# https://github.com/sddm/sddm/issues/871
# XAUTHORITY = "$XDG_RUNTIME_DIR/Xauthority";
# set default applications
BROWSER = "firefox";
TERMINAL = "alacritty";
# enable scrolling in git diff
DELTA_PAGER = "less -R";
MANPAGER = "sh -c 'col -bx | bat -l man -p'";
};
home.sessionVariables = systemd.user.sessionVariables;
home.shellAliases = { home.shellAliases = {
k = "kubectl"; k = "kubectl";

View File

@@ -1,8 +1,5 @@
{config, pkgs, ...}: let {config, pkgs, ...}:
d = config.xdg.dataHome; {
c = config.xdg.configHome;
cache = config.xdg.cacheHome;
in rec {
imports = [ imports = [
./nushell ./nushell

View File

@@ -0,0 +1,31 @@
{config, ...}:
let
d = config.xdg.dataHome;
c = config.xdg.configHome;
cache = config.xdg.cacheHome;
in rec {
# add environment variables
systemd.user.sessionVariables = {
# clean up ~
LESSHISTFILE = cache + "/less/history";
LESSKEY = c + "/less/lesskey";
WINEPREFIX = d + "/wine";
# set this variable make i3 failed to start
# related issue:
# https://github.com/sddm/sddm/issues/871
# XAUTHORITY = "$XDG_RUNTIME_DIR/Xauthority";
# set default applications
BROWSER = "firefox";
TERMINAL = "alacritty";
# enable scrolling in git diff
DELTA_PAGER = "less -R";
MANPAGER = "sh -c 'col -bx | bat -l man -p'";
};
home.sessionVariables = systemd.user.sessionVariables;
}

View File

@@ -34,6 +34,7 @@
}; };
services = { services = {
playerctld.enable = true; # syncthing.enable = true;
}; };
} }

View File

@@ -2,35 +2,9 @@
# It's a bunch of specifications from freedesktop.org intended to standardize desktops and # It's a bunch of specifications from freedesktop.org intended to standardize desktops and
# other GUI applications on various systems (primarily Unix-like) to be interoperable: # other GUI applications on various systems (primarily Unix-like) to be interoperable:
# https://www.freedesktop.org/wiki/Specifications/ # https://www.freedesktop.org/wiki/Specifications/
{config, pkgs, ...}: let {config, pkgs, ...}:
browser = ["firefox.desktop"]; {
# XDG MIME types
associations = {
"application/x-extension-htm" = browser;
"application/x-extension-html" = browser;
"application/x-extension-shtml" = browser;
"application/x-extension-xht" = browser;
"application/x-extension-xhtml" = browser;
"application/xhtml+xml" = browser;
"text/html" = browser;
"x-scheme-handler/about" = browser;
"x-scheme-handler/ftp" = browser;
"x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser;
"x-scheme-handler/unknown" = browser;
"audio/*" = ["mpv.desktop"];
"video/*" = ["mpv.dekstop"];
"image/*" = ["imv.desktop"];
"application/json" = browser;
"application/pdf" = browser; # TODO: pdf viewer
"x-scheme-handler/discord" = ["discord.desktop"];
"x-scheme-handler/tg" = ["telegramdesktop.desktop"];
};
in {
home.packages = with pkgs; [ home.packages = with pkgs; [
xdg-utils
xdg-user-dirs xdg-user-dirs
]; ];
@@ -38,9 +12,70 @@ in {
enable = true; enable = true;
cacheHome = config.home.homeDirectory + "/.local/cache"; cacheHome = config.home.homeDirectory + "/.local/cache";
# manage $XDG_CONFIG_HOME/mimeapps.list
# xdg search all desktop entries from $XDG_DATA_DIRS, check it by command:
# echo $XDG_DATA_DIRS
# the system-level desktop entries can be list by command:
# ls -l /run/current-system/sw/share/applications/
# the user-level desktop entries can be list by command(user ryan):
# ls /etc/profiles/per-user/ryan/share/applications/
mimeApps = { mimeApps = {
enable = true; enable = true;
defaultApplications = associations; associations.added =
let
browser = ["firefox.desktop"];
in
{
"application/json" = browser;
"application/pdf" = browser; # TODO: pdf viewer
"text/html" = browser;
"text/xml" = browser;
"application/xml" = browser;
"application/xhtml+xml" = browser;
"application/xhtml_xml" = browser;
"application/rdf+xml" = browser;
"application/rss+xml" = browser;
"application/x-extension-htm" = browser;
"application/x-extension-html" = browser;
"application/x-extension-shtml" = browser;
"application/x-extension-xht" = browser;
"application/x-extension-xhtml" = browser;
"x-scheme-handler/about" = browser;
"x-scheme-handler/ftp" = browser;
"x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser;
"x-scheme-handler/unknown" = browser;
"x-scheme-handler/discord" = ["discord.desktop"];
"x-scheme-handler/tg" = ["telegramdesktop.desktop"];
"audio/*" = ["mpv.desktop"];
"video/*" = ["mpv.dekstop"];
"image/*" = ["imv.desktop"];
};
associations.removed =
let
browser = ["google-chrome.desktop"];
in
{
"text/html" = browser;
"text/xml" = browser;
"application/xml" = browser;
"application/xhtml+xml" = browser;
"application/xhtml_xml" = browser;
"application/rdf+xml" = browser;
"application/rss+xml" = browser;
"image/gif" = browser;
"image/jpeg" = browser;
"image/png" = browser;
"image/webp" = browser;
"x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser;
"application/pdf" = browser;
};
}; };
userDirs = { userDirs = {

View File

@@ -16,6 +16,7 @@
]; ];
programs = { programs = {
# live streaming
obs-studio.enable = true; obs-studio.enable = true;
}; };
} }

View File

@@ -9,6 +9,10 @@
# networking # networking
wireshark wireshark
# e-book viewer(.epub/.mobi/...)
# do not support .pdf
foliate
# instant messaging # instant messaging
telegram-desktop telegram-desktop
discord discord

View File

@@ -26,7 +26,9 @@
defaultProfiles = ["gpu-hq"]; defaultProfiles = ["gpu-hq"];
scripts = [pkgs.mpvScripts.mpris]; scripts = [pkgs.mpvScripts.mpris];
}; };
};
obs-studio.enable = true; services = {
playerctld.enable = true;
}; };
} }

View File

@@ -1,7 +1,6 @@
{ {
pkgs, pkgs,
nixpkgs-stable, nixpkgs-stable,
config,
... ...
}: let }: let
pkgs-stable = import nixpkgs-stable { pkgs-stable = import nixpkgs-stable {
@@ -9,12 +8,6 @@
config.allowUnfree = true; config.allowUnfree = true;
}; };
in { in {
home.packages = with pkgs-stable; [
firefox-wayland # firefox with wayland support
wineWowPackages.wayland
];
# TODO vscode & chrome both have wayland support, but they don't work with fcitx5, need to fix it. # TODO vscode & chrome both have wayland support, but they don't work with fcitx5, need to fix it.
programs = { programs = {
@@ -38,6 +31,12 @@
]; ];
}; };
firefox = {
enable = true;
enableGnomeExtensions = false;
package = pkgs-stable.firefox-wayland; # firefox with wayland support
};
vscode = { vscode = {
enable = true; enable = true;
# use the stable version # use the stable version

View File

@@ -9,6 +9,7 @@
./fcitx5 ./fcitx5
./desktop ./desktop
./common/shell.nix
./common/ssh.nix ./common/ssh.nix
./common/system-tools.nix ./common/system-tools.nix
./common/xdg.nix ./common/xdg.nix

View File

@@ -9,6 +9,7 @@
./fcitx5 ./fcitx5
./desktop ./desktop
./common/shell.nix
./common/ssh.nix ./common/ssh.nix
./common/system-tools.nix ./common/system-tools.nix
./common/xdg.nix ./common/xdg.nix