diff --git a/home/terminal/browser.nix b/home/terminal/browser.nix new file mode 100644 index 0000000..2656be9 --- /dev/null +++ b/home/terminal/browser.nix @@ -0,0 +1,242 @@ +{ + config, + lib, + pkgs, + self, + ... +}: +with lib; { + imports = [ + self.homeManagerModules.qutebrowser-profiles + ./scripts.nix + ./profiles.nix + ]; + + programs.qutebrowser = { + enable = true; + + keyBindings = { + normal = { + ",m" = "spawn umpv {url}"; + ",M" = "hint links spawn umpv {hint-url}"; + ";M" = "hint --rapid links spawn umpv {hint-url}"; + "tD" = "config-cycle -t -u {url} colors.webpage.darkmode.enabled false true ;; reload"; + }; + }; + + settings = { + auto_save.session = true; + confirm_quit = ["downloads"]; + + tabs.width = builtins.floor (1920 * 0.1); + tabs.position = "left"; + + # Colors + colors.tabs.pinned.even.bg = mkForce "#181818"; + colors.tabs.pinned.odd.bg = mkForce "#181818"; + + colors.tabs.selected.even.bg = mkForce "#CDD6F4"; # Catppuccin's Text + colors.tabs.selected.odd.bg = mkForce "#CDD6F4"; # Catppuccin's Text + colors.tabs.selected.even.fg = mkForce "#111111"; + colors.tabs.selected.odd.fg = mkForce "#111111"; + + colors.tabs.pinned.selected.even.bg = mkForce "#CDD6F4"; # Catppuccin's Text + colors.tabs.pinned.selected.odd.bg = mkForce "#CDD6F4"; # Catppuccin's Text + + ## Darkmode + colors.webpage.darkmode.enabled = true; + colors.webpage.darkmode.algorithm = "lightness-cielab"; + colors.webpage.darkmode.policy.images = "never"; + + # Prevent fingerprinting + content.canvas_reading = false; + content.cookies.accept = "all"; + content.cookies.store = true; + content.geolocation = false; + content.webgl = false; + content.webrtc_ip_handling_policy = "default-public-interface-only"; + }; + + extraConfig = '' + config.set('colors.webpage.darkmode.enabled', False, 'file://*') + config.set('colors.webpage.darkmode.enabled', False, 'http://*:*/*') + + config.set('colors.webpage.darkmode.enabled', False, 'capytal.company') + config.set('colors.webpage.darkmode.enabled', False, '*.capytal.company') + config.set('colors.webpage.darkmode.enabled', False, 'capytal.cc') + config.set('colors.webpage.darkmode.enabled', False, '*.capytal.cc') + config.set('colors.webpage.darkmode.enabled', False, 'lored.dev') + config.set('colors.webpage.darkmode.enabled', False, '*.lored.dev') + config.set('colors.webpage.darkmode.enabled', False, 'guz.one') + config.set('colors.webpage.darkmode.enabled', False, '*.guz.one') + + # Thanks to @hseg on GitHub (https://github.com/qutebrowser/qutebrowser/issues/6880#issuecomment-1815248845) + config.bind('o', 'cmd-set-text -s :open -s') + config.bind('go', 'cmd-set-text :open -s {url:pretty}') + config.bind('O', 'cmd-set-text -s :open -s -t') + config.bind('gO', 'cmd-set-text :open -s -t -r {url:pretty}') + config.bind('xo', 'cmd-set-text -s :open -s -b') + config.bind('xO', 'cmd-set-text :open -s -b -r {url:pretty}') + config.bind('wo', 'cmd-set-text -s :open -s -w') + config.bind('wO', 'cmd-set-text :open -s -w {url:pretty}') + config.bind('pp', 'open -s -- {clipboard}') + config.bind('pP', 'open -s -- {primary}') + config.bind('Pp', 'open -s -t -- {clipboard}') + config.bind('PP', 'open -s -t -- {primary}') + config.bind('wp', 'open -s -w -- {clipboard}') + config.bind('wP', 'open -s -w -- {primary}') + ''; + + searchEngines = { + DEFAULT = "https://search.brave.com/search?q={}"; + # Nix + pkg = "https://search.nixos.org/packages?query={}"; + opt = "https://search.nixos.org/options?query={}"; + lib = "https://noogle.dev/q?term={}"; + hm = "https://home-manager-options.extranix.com/?query={}"; + wiki = "https://wiki.nixos.org/w/index.php?search={}"; + + # Wikipedia + w = "https://en.wikipedia.org/wiki/Special:Search?search={}&go=Go&ns0=1"; + wpt = "https://pt.wikipedia.org/wiki/Special:Search?search={}&go=Go&ns0=1"; + }; + + profiles = let + programmingSearchEngines = { + # Languages + go = "https://pkg.go.dev/search?q={}"; + }; + setColor = c: { + colors.tabs.selected.even.bg = c; + colors.tabs.selected.odd.bg = c; + colors.tabs.pinned.selected.even.bg = c; + colors.tabs.pinned.selected.odd.bg = c; + }; + in { + "art".settings = setColor "#CBA6F7"; # Catppuccin's Mauve; + "personal".settings = setColor "#F5E0DC"; # Catppuccin's Rosewater + "work" = { + settings = setColor "#74C7EC"; # Catppuccin's Sapphire + searchEngines = programmingSearchEngines; + }; + "job" = { + settings = + (config.programs.qutebrowser.profiles."work".settings) + // { + confirm_quit = ["always"]; + content.webgl = true; + } + // (setColor "#A6E2A1"); # Catppuccin's Green + searchEngines = programmingSearchEngines; + }; + "shopping".settings = setColor "#F9E2AF"; # Catppuccin's Yellow + "goverment".settings = setColor "#A6ADC8"; # Catppuccin's Subtext 1 + "academic".settings = + { + confirm_quit = ["always"]; + content.webgl = true; + } + // setColor "#19236F"; + "facebook".settings = setColor "#1877F2"; # Facebook's Blue + "yt-music".settings = + { + tabs.width = 10; + } + // (setColor "#FF0000"); # Youtube's Red + }; + + greasemonkey = [ + # Youtube Adblocking + (pkgs.fetchurl { + url = "https://raw.githubusercontent.com/afreakk/greasemonkeyscripts/refs/heads/master/youtube_adblock.js"; + hash = "sha256-AyD9VoLJbKPfqmDEwFIEBMl//EIV/FYnZ1+ona+VU9c="; + }) + + # Youtube Sponsorblock + (pkgs.fetchurl { + url = "https://raw.githubusercontent.com/afreakk/greasemonkeyscripts/refs/heads/master/youtube_sponsorblock.js"; + hash = "sha256-nwNade1oHP+w5LGUPJSgAX1+nQZli4Rhe8FFUoF5mLE="; + }) + + # Reddit adblock + (pkgs.fetchurl { + url = "https://github.com/afreakk/greasemonkeyscripts/raw/refs/heads/master/reddit_adblock.js"; + hash = "sha256-KmCXL4GrZtwPLRyAvAxADpyjbdY5UFnS/XKZFKtg7tk="; + }) + + # Pinterest adblock + (pkgs.writeText "pinterest_adblock.js" '' + // ==UserScript== + // @name remove ads from pinterest + // @version 1.0.0 + // @author guz + // @match *://*.pinterest.com/* + // ==/UserScript== + + const removeShit = () => { + document.querySelectorAll('[data-grid-item]:has([title="Promoted by"])').forEach((e) => e.remove()); + document.querySelectorAll('[data-grid-item]:has([data-test-id="oneTapPromotedPin"])').forEach((e) => e.remove()); + document.querySelectorAll('[data-grid-item]:has([aria-label="Product Pin"])').forEach((e) => e.remove()); + // document.querySelectorAll('[data-grid-item]:has-text(ideas you might love)').forEach((e) => e.remove()); + // document.querySelectorAll('[data-grid-item]:has-text(Seaches to try)').forEach((e) => e.remove()); + }; + (trySetInterval = () => { + window.setInterval(removeShit, 1000); + })(); + '') + + # Privacy Redirector + (pkgs.substitute { + src = pkgs.fetchurl { + url = "https://github.com/dybdeskarphet/privacy-redirector/raw/refs/heads/main/privacy-redirector.user.js"; + hash = "sha256-xj36+/3coiStIxftWCJUWHokSEmr+YRLOTktbmn5TkU="; + }; + substitutions = [ + # ON-OFF (Redirection / Farside) + "--replace" + "pinterest = [true, true]" + "pinterest = [false, false]" + "--replace" + "tumblr = [true, false]" + "tumblr = [false, false]" + "--replace" + "wikipedia = [true, false]" + "wikipedia = [false, false]" + "--replace" + "youtube = [true, false]" + "youtube = [false, false]" + "--replace" + "instagram = [true, true]" + "instagram = [false, false]" + ]; + }) + ]; + }; + + programs.mpv.enable = true; + programs.mpv.scripts = with pkgs.mpvScripts; [ + quality-menu + sponsorblock + ]; + + xdg.mimeApps.defaultApplications = listToAttrs (map (name: { + inherit name; + value = config.programs.qutebrowser.package.meta.desktopFileName; + }) [ + "application/x-extension-shtml" + "application/x-extension-xhtml" + "application/x-extension-html" + "application/x-extension-xhtm" + "application/x-extension-htm" + "x-scheme-handler/unknown" + "x-scheme-handler/mailto" + "x-scheme-handler/chrome" + "x-scheme-handler/about" + "x-scheme-handler/https" + "x-scheme-handler/http" + "application/xhtml+xml" + "application/json" + "text/plain" + "text/html" + ]); +} diff --git a/home/terminal/configuration.nix b/home/terminal/configuration.nix new file mode 100644 index 0000000..bd10155 --- /dev/null +++ b/home/terminal/configuration.nix @@ -0,0 +1,44 @@ +{ + config, + inputs, + pkgs, + pkgs-unstable, + self, + ... +}: { + imports = [ + inputs.home-manager.nixosModules.default + ]; + + # User + users.users."guz" = { + extraGroups = ["wheel" "guz"]; + isNormalUser = true; + hashedPasswordFile = builtins.toString config.sops.secrets."guz/password".path; + shell = self.packages.${pkgs.stdenv.hostPlatform.system}.devkit.zsh; + }; + users.groups."guz" = {}; + + home-manager.backupFileExtension = "bkp"; + home-manager.extraSpecialArgs = {inherit inputs self pkgs-unstable;}; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users."guz" = ./home.nix; + + services.displayManager.sddm = { + enable = true; + wayland.enable = true; + }; + + programs.hyprland = { + enable = true; + withUWSM = true; + xwayland.enable = true; + }; + + xdg.portal.xdgOpenUsePortal = true; + xdg.portal.extraPortals = with pkgs; [xdg-desktop-portal-gtk]; + + # Shell + programs.zsh.enable = true; +} diff --git a/home/terminal/desktop.nix b/home/terminal/desktop.nix new file mode 100644 index 0000000..dff44bf --- /dev/null +++ b/home/terminal/desktop.nix @@ -0,0 +1,285 @@ +{ + config, + lib, + osConfig, + pkgs, + ... +}: +with lib; { + xdg.configFile."uwsm/env".source = "${config.home.sessionVariablesPackage}/etc/profile.d/hm-session-vars.sh"; # Set environment variables + + wayland.windowManager.hyprland = { + enable = true; + systemd.enable = mkForce false; # Incompatible with UWSM + package = null; # Use the package from the NixOS module + portalPackage = null; # Use the package from the NixOS module + settings = { + "$MONITOR-1" = mkDefault ""; + "$MONITOR-2" = mkDefault ""; + + animations.enabled = true; + + decoration.rounding = 5; + decoration.dim_inactive = true; + decoration.dim_strength = 0.2; + decoration.dim_around = 0.4; + + exec-once = [ + "wl-paste --type text --watch cliphist store" + "wl-paste --type image --watch cliphist store" + ]; + + dwindle.pseudotile = true; + dwindle.preserve_split = true; + + general.gaps_in = 5; + general.gaps_out = 10; + general.border_size = 0; + general.layout = "dwindle"; + + input.kb_layout = elemAt 0 (strings.splitString "-" osConfig.console.keyMap); + input.kb_variant = elemAt 1 (strings.splitString "-" osConfig.console.keyMap); + input.follow_mouse = 1; + input.sensitivity = 0; + + monitor = [", preferred, auto, 1"]; + + workspace = [ + # Primary monitor + "1,monitor:$MONITOR-1,default:true" + "2,monitor:$MONITOR-1" + "3,monitor:$MONITOR-1" + "4,monitor:$MONITOR-1" + "5,monitor:$MONITOR-1" + # Second monitor + "6,monitor:$MONITOR-2" + "7,monitor:$MONITOR-2" + "8,monitor:$MONITOR-2" + "9,monitor:$MONITOR-2" + "10,monitor:$MONITOR-2,default:true" + ]; + + # Keymaps + bind = [ + # Applications shortcut + "SUPER, Q, exec, ${config.home.sessionVariables.TERMINAL}" # Terminal + # TODO: "SUPER, E, exec, " # File manager + "SUPER, W, exec, xdg-open https://search.brave.com" + + # Launcher + # TODO: "SUPER, S, exec, " + "SUPER, I, exec, ${getExe pkgs.rofimoji}" # Emoji Picker + + # Navigation + "SUPER, C, killactive" + "SUPER, F, fullscreen" + "SUPER_SHIFT, F, togglefloating" + + "SUPER, h, movefocus l" + "SUPER, l, movefocus r" + "SUPER, k, movefocus u" + "SUPER, j, movefocus d" + + "SUPER, 1, workspace 1" + "SUPER, 2, workspace 2" + "SUPER, 3, workspace 3" + "SUPER, 4, workspace 4" + "SUPER, 5, workspace 5" + "SUPER, 6, workspace 6" + "SUPER, 7, workspace 7" + "SUPER, 8, workspace 8" + "SUPER, 9, workspace 9" + "SUPER, 0, workspace 10" + + "SUPER_SHIFT, 1, movetoworkspace 1" + "SUPER_SHIFT, 2, movetoworkspace 2" + "SUPER_SHIFT, 3, movetoworkspace 3" + "SUPER_SHIFT, 4, movetoworkspace 4" + "SUPER_SHIFT, 5, movetoworkspace 5" + "SUPER_SHIFT, 6, movetoworkspace 6" + "SUPER_SHIFT, 7, movetoworkspace 7" + "SUPER_SHIFT, 8, movetoworkspace 8" + "SUPER_SHIFT, 9, movetoworkspace 9" + "SUPER_SHIFT, 0, movetoworkspace 10" + + # Clipboard manager + "SUPER, V, exec, cliphist list | rofi -dmenu -display-columns 2 | cliphist decode | wl-copy" + + # Print region + ",Print, exec, ${getExe pkgs.grim} -g \"$(${getExe slurp} -d)\" - | wl-copy" + + # Copy color + "SUPER, P, exec, ${getExe pkgs.hyprpicker} | wl-copy" + ]; + # Mouse Keymaps + bindm = [ + "SUPER, mouse:272, movewindow" # Left-click + "SUPER, mouse:273, resizewindow" # Right-click + ]; + }; + }; + + # Application Launcher + programs.rofi = { + enable = true; + modes = ["drun" "emoji"]; + }; + + # Clipboard + services.cliphist = { + enable = true; + allowImages = true; + }; + home.packages = with pkgs; [ + wl-clipboard + ]; + + # Notifications + services.dunst = { + enable = true; + settings = { + global.follow = "mouse"; + }; + }; + + # Bar + programs.waybar.settings = let + layer = "top"; + position = "top"; + + height = 25; + spacing = 5; + + margin-top = 5; + margin-x = 10; + margin-right = margin-x; + margin-left = margin-x; + in { + main = let + monitor = config.wayland.windowManager.hyprland.settings."$MONITOR-1"; + in { + inherit + layer + position + height + spacing + margin-top + margin-right + margin-left + ; + + output = [monitor]; + + modules-left = [ + "hyprland/workspaces" + ]; + + "hyprland/workspaces" = { + active-only = false; + persistent-workspaces = { + "${monitor}" = [1 2 3 4 5]; + }; + format = "{icon}"; + format-icons = { + default = ""; + active = ""; + }; + }; + + modules-center = [ + "clock" + ]; + + modules-right = [ + "pulseaudio" + ]; + + "clock" = { + format = "{:%d 󰥔 %R}"; + format-alt = "{:%B %d, 12.0%y (%A)}"; + tooltip-format = "{calendar}"; + calendar = { + mode = "year"; + mode-mon-col = 3; + weeks-pos = "left"; + on-scroll = 1; + format = with config.lib.stylix.colors.withHashtag; { + months = "{}"; + days = "{}"; + weeks = "W{}"; + weeksdays = "{}"; + today = "{}"; + }; + }; + }; + + "pulseaudio" = { + format = "{icon} {volume}%"; + format-muted = ""; + format-icons = { + default = ["" ""]; + }; + onclick = "${lib.getExe pkgs.pwvucontrol}"; + }; + }; + secondary = let + monitor = config.wayland.windowManager.hyprland.settings."$MONITOR-2"; + in { + inherit + layer + position + height + spacing + margin-top + margin-right + margin-left + ; + + output = [monitor]; + + modules-left = [ + "cpu" + "memory" + "disk" + ]; + + "cpu" = { + format = " {usage}%"; + }; + + "memory" = { + format = " {percentage}%"; + }; + + "disk" = { + interval = 30; + format = "󰨣 {specific_free:0.2f}"; + unit = "GB"; + }; + + modules-center = [ + "hyprland/window" + ]; + + "hyprland/window" = { + format = "{title}"; + }; + + modules-right = [ + "hyprland/workspaces" + ]; + + "hyprland/workspaces" = { + active-only = false; + persistent-workspaces = { + "${monitor}" = [6 7 8 9 10]; + }; + format = "{icon}"; + format-icons = { + default = ""; + active = ""; + }; + }; + }; + }; +} diff --git a/home/terminal/home.nix b/home/terminal/home.nix new file mode 100644 index 0000000..ed290c2 --- /dev/null +++ b/home/terminal/home.nix @@ -0,0 +1,25 @@ +{ + lib, + options, + ... +}: +with lib; { + imports = + [ + ./browser.nix + ./desktop.nix + ] + ++ (optionals (options.home?persistence) [ + ./impermanence.nix + ]); + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + home.stateVersion = "25.11"; +} diff --git a/home/terminal/impermanence.nix b/home/terminal/impermanence.nix new file mode 100644 index 0000000..e75cd44 --- /dev/null +++ b/home/terminal/impermanence.nix @@ -0,0 +1,40 @@ +{lib, ...}: +with lib; { + home.persistence."/persist" = { + directories = map (d: + if isList d + then { + directory = elemAt 1 d; + mode = elemAt 0 d; + } + else d) [ + ["0755" "Documents"] + ["0755" "Downloads"] + ["0755" "KritaRecorder"] + ["0755" "Music"] + ["0755" "Nextcloud"] + ["0755" "Projects"] + ["0755" "Pictures"] + ["0755" "Videos"] + ["0755" "go"] + ["0700" ".gnupg"] + ["0700" ".ssh"] + ["0755" ".cache/blender"] + ["0755" ".cache/go-build"] + ["0755" ".cache/godot"] + ["0700" ".cache/gopls"] + ["0755" ".cache/nvim"] + ["0700" ".cache/qutebrowser"] + ["0755" ".cache/starship"] + ["0700" ".cache/wezterm"] + ["0755" ".cache/zellij"] + ["0755" ".config/blender"] + ["0751" ".config/inkscape"] + ["0600" ".config/kritarc"] + ["0644" ".config/kritadisplayrc"] + ["0755" ".config/qutebrowser"] + ["0755" ".local/share/direnv"] + ["0700" ".local/share/keyrings"] + ]; + }; +}