summaryrefslogtreecommitdiff
path: root/nixos/parts/graphical.nix
blob: 8c340fc148ecf099c08daf4d4225e59bfc3a8e70 (plain)
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
{ config, pkgs, ... }:

{
  programs.sway = {
    enable = true;
    # Execute sway with required environment variables for GTK apps.
    wrapperFeatures.gtk = true;
  };
  programs.ssh.startAgent = true;

  environment.sessionVariables = {
    # Tell .zshrc to source zshrc-graphical.sh.
    MYNIX_GRAPHICAL = "true";
  };

  environment.systemPackages = with pkgs; [
    # CLI tools
    brightnessctl
    wl-clipboard # for wl-copy and wl-paste

    # When I ssh into a server my terminal changes to a host-specific background color via
    # a LocalCommand configured in ~/.ssh/config and a ZSH function to reset the color on exit.
    (writeShellScriptBin "set-bg" ''
      #!/usr/bin/env bash
      rgb_with_slashes=$(echo "$1" | sed -r 's,(..)(..),\1/\2/,')
      echo -en "\033]11;rgb:$rgb_with_slashes\007"
    '')
    (writeShellScriptBin "reset-bg" ''
      #!/usr/bin/env bash
      echo -en "\033]111\007"
    '')

    # graphical tools
    imv
    mpv

    # set and forget
    i3status-rust
  ];

  # This generates /etc/xdg/mimeapps.list. The XDG spec and xdg-open don't support wildcards in MIME types.
  # TODO: use an xdg-open alternative that supports wildcards in MIME types and doesn't use mimeapps.list
  xdg.mime.defaultApplications =
    let
      defaultBrowser = "firefox.desktop";
    in
    {
      "text/html" = defaultBrowser;

      "x-scheme-handler/http" = defaultBrowser;
      "x-scheme-handler/https" = defaultBrowser;
      "x-scheme-handler/mailto" = "thunderbird.desktop";
    };

  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };
  security.rtkit.enable = true; # recommended for PipeWire

  programs.thunderbird = {
    enable = true;
  };

  programs.firefox = {
    enable = true;

    policies = {
      DontCheckDefaultBrowser = true;
      DisablePocket = true;
      FirefoxHome = {
        SponsoredTopSites = false;
      };

      SearchSuggestEnabled = false;
      # cannot use SearchEngines because it's only available on ESR :(
      # (https://mozilla.github.io/policy-templates/#searchengines-this-policy-is-only-available-on-the-esr)

      ExtensionSettings = {
        "uBlock0@raymondhill.net" = {
          install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
          installation_mode = "force_installed";
        };
      };

      PasswordManagerEnabled = false;
      ExtensionSettings."{446900e4-71c2-419f-a6a7-df9c091e268b}" = {
        install_url = "https://addons.mozilla.org/firefox/downloads/latest/bitwarden-password-manager/latest.xpi";
        installation_mode = "force_installed";
      };
    };
  };
}