diff options
Diffstat (limited to 'home/desktops')
-rw-r--r-- | home/desktops/default.nix | 81 | ||||
-rw-r--r-- | home/desktops/hyprland/binds.nix | 139 | ||||
-rw-r--r-- | home/desktops/hyprland/default.nix | 33 | ||||
-rw-r--r-- | home/desktops/hyprland/env.nix | 14 | ||||
-rw-r--r-- | home/desktops/hyprland/idle.nix | 35 | ||||
-rw-r--r-- | home/desktops/hyprland/plugins.nix | 40 | ||||
-rw-r--r-- | home/desktops/hyprland/settings.nix | 125 | ||||
-rw-r--r-- | home/desktops/hyprland/wallpaper.nix | 11 | ||||
-rw-r--r-- | home/desktops/sway/binds.nix | 89 | ||||
-rw-r--r-- | home/desktops/sway/config.nix | 122 | ||||
-rw-r--r-- | home/desktops/sway/default.nix | 28 | ||||
-rw-r--r-- | home/desktops/sway/idle.nix | 25 |
12 files changed, 742 insertions, 0 deletions
diff --git a/home/desktops/default.nix b/home/desktops/default.nix new file mode 100644 index 0000000..9c17bb0 --- /dev/null +++ b/home/desktops/default.nix @@ -0,0 +1,81 @@ +{ + lib, + config, + pkgs, + inputs, + ... +}: let + inherit (lib) mkEnableOption mkIf optionals; + cfg = config.desktops; +in { + imports = [ + ./hyprland + ./sway + ]; + + config = mkIf cfg.enable { + # desktop specific programs + home.packages = + (with pkgs; [ + # gtk + adwaita-icon-theme + # codecs + libaacs + libavif + libbluray + libjxl + # wayland + cage + grimblast + wl-clipboard + wl-clip-persist + wl-mirror + # xdg + libnotify + # fonts + corefonts + dejavu_fonts + fira-code + fira-code-symbols + jetbrains-mono + material-icons + nerd-fonts.fira-code + noto-fonts + noto-fonts-cjk-sans + noto-fonts-emoji + twemoji-color-font + vistafonts + ]) + ++ (with inputs.apple-fonts.packages.${pkgs.system}; [ + # apple fonts + sf-pro + sf-mono + sf-compact + ]); + + fonts.fontconfig = { + enable = true; + defaultFonts = { + serif = [ + "Twemoji" + "DejaVu Serif" + ]; + sansSerif = [ + "Twemoji" + "DejaVu Sans" + ]; + monospace = [ + "Fira Code" + "FiraCode Nerd Font Mono" + "Font Awesome 6 Pro Regular" + "Twemoji" + "DejaVu Sans Mono" + ]; + emoji = [ + "Twemoji" + "Noto Color Emoji" + ]; + }; + }; + }; +} diff --git a/home/desktops/hyprland/binds.nix b/home/desktops/hyprland/binds.nix new file mode 100644 index 0000000..94e0f39 --- /dev/null +++ b/home/desktops/hyprland/binds.nix @@ -0,0 +1,139 @@ +{config, ...}: { + wayland.windowManager.hyprland.settings = { + # Keybinds + "$mod" = "SUPER"; + bind = [ + # Launch programs + + "$mod, W, exec, ${config.default.browser}" + "$mod, D, exec, ${config.default.appLauncher}" + "$mod, L, exec, ${config.default.lockScreen}" + "$mod, Return, exec, ${config.default.terminal}" + ", Print, exec, grimblast copy area" + + # Misc + + "$mod SHIFT, L, exit" + "$mod, tab, hyprexpo:expo, toggle" + + # Window operations + + "$mod SHIFT, Q, killactive" + "$mod SHIFT, SPACE, togglefloating" + "$mod, F, fullscreen" + "$mod, J, togglesplit" + + # Move focus with mod + arrow keys + + "$mod, left, movefocus, l" + "$mod, right, movefocus, r" + "$mod, up, movefocus, u" + "$mod, down, movefocus, d" + + # Move window across workspace with mod + arrow keys + + "$mod SHIFT, left, hy3:movewindow, l" + "$mod SHIFT, right, hy3:movewindow, r" + "$mod SHIFT, up, hy3:movewindow, u" + "$mod SHIFT, down, hy3:movewindow, d" + + # Switch workspaces with mod + [0-9] + + "$mod, 1, workspace, 1" + "$mod, 2, workspace, 2" + "$mod, 3, workspace, 3" + "$mod, 4, workspace, 4" + "$mod, 5, workspace, 5" + "$mod, 6, workspace, 6" + "$mod, 7, workspace, 7" + "$mod, 8, workspace, 8" + "$mod, 9, workspace, 9" + + # Move active window to a workspace with mod + SHIFT + [0-9] + + "$mod SHIFT, 1, movetoworkspacesilent, 1" + "$mod SHIFT, 2, movetoworkspacesilent, 2" + "$mod SHIFT, 3, movetoworkspacesilent, 3" + "$mod SHIFT, 4, movetoworkspacesilent, 4" + "$mod SHIFT, 5, movetoworkspacesilent, 5" + "$mod SHIFT, 6, movetoworkspacesilent, 6" + "$mod SHIFT, 7, movetoworkspacesilent, 7" + "$mod SHIFT, 8, movetoworkspacesilent, 8" + "$mod SHIFT, 9, movetoworkspacesilent, 9" + "$mod SHIFT, 0, movetoworkspacesilent, 10" + + # Move to tab + + "LALT, 1, hy3:focustab, index, 01" + "LALT, 2, hy3:focustab, index, 02" + "LALT, 3, hy3:focustab, index, 03" + "LALT, 4, hy3:focustab, index, 04" + "LALT, 5, hy3:focustab, index, 05" + "LALT, 6, hy3:focustab, index, 06" + "LALT, 7, hy3:focustab, index, 07" + "LALT, 8, hy3:focustab, index, 08" + "LALT, 9, hy3:focustab, index, 09" + "LALT, 0, hy3:focustab, index, 10" + + "$mod SHIFT, B, hy3:makegroup, h" + "$mod SHIFT, V, hy3:makegroup, v" + "$mod SHIFT, C, hy3:changegroup, toggletab" + + # Scroll through existing workspaces with mod + scroll + + "$mod, mouse_down, workspace, e+1" + "$mod, mouse_up, workspace, e-1" + ]; + + bindn = [ + # Focus windows with scroll wheel or middle click + + ", mouse:272, hy3:focustab, mouse" + ", mouse_down, hy3:focustab, l, require_hovered" + ", mouse_up, hy3:focustab, r, require_hovered" + ]; + + bindm = [ + # Move/resize windows with mod + LMB/RMB and dragging + + "$mod, mouse:272, movewindow" + "$mod, mouse:273, resizewindow" + ]; + + binde = [ + # Audio + + # raise volume + ", XF86AudioRaiseVolume, exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+" + # lower volume + ", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" + # mute speaker + ", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" + # mute mic + ", XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle" + + # Media + + # play + ", XF86AudioPlay, exec, playerctl play-pause" + # next + ", XF86AudioNext, exec, playerctl next" + # prev + ", XF86AudioPrev, exec, playerctl previous" + + # Backlight + + ", XF86MonBrightnessDown, exec, brightnessctl set 5%-" + ", XF86MonBrightnessUp, exec, brightnessctl set 5%+" + ]; + + bindl = let + monitor = builtins.elemAt config.monitors 0; + cfg = "highres, auto, ${toString monitor.scale}, bitdepth, ${toString monitor.bitdepth}"; + in [ + # Laptops when docked + ", switch:on:Lid, exec, hyprctl keyword monitor \"${monitor.name}, disable\"" + ", switch:off:Lid, exec, hyprctl keyword monitor \"${monitor.name}, ${cfg}\"" + ]; + }; +} diff --git a/home/desktops/hyprland/default.nix b/home/desktops/hyprland/default.nix new file mode 100644 index 0000000..53a1d2a --- /dev/null +++ b/home/desktops/hyprland/default.nix @@ -0,0 +1,33 @@ +{ + inputs, + config, + pkgs, + lib, + ... +}: let + inherit (lib) mkIf mkDefault; + cfg = config.desktops.hyprland; +in { + imports = [ + ./binds.nix + ./env.nix + ./idle.nix + ./plugins.nix + ./settings.nix + ./wallpaper.nix + ]; + + config = mkIf cfg.enable { + home.packages = [ + inputs.rose-pine-hyprcursor.packages.${pkgs.system}.default + ]; + + wayland.windowManager.hyprland = { + enable = true; + package = inputs.hyprland.packages.${pkgs.system}.hyprland; + + xwayland.enable = true; + systemd.enable = true; + }; + }; +} diff --git a/home/desktops/hyprland/env.nix b/home/desktops/hyprland/env.nix new file mode 100644 index 0000000..620efd9 --- /dev/null +++ b/home/desktops/hyprland/env.nix @@ -0,0 +1,14 @@ +{config, ...}: { + wayland.windowManager.hyprland.settings = { + env = [ + "XDG_CURRENT_DESKTOP,Hyprland" + "XDG_SESSION_TYPE,wayland" + "XDG_SESSION_DESKTOP,Hyprland" + "MOZ_ENABLE_WAYLAND,1" + "NIXOS_OZONE_WL,1" + + "HYPRCURSOR_THEME,rose-pine-hyprcursor" + "HYPRCURSOR_SIZE,24" + ]; + }; +} diff --git a/home/desktops/hyprland/idle.nix b/home/desktops/hyprland/idle.nix new file mode 100644 index 0000000..0a2b951 --- /dev/null +++ b/home/desktops/hyprland/idle.nix @@ -0,0 +1,35 @@ +{config, ...}: { + services.hypridle = { + enable = config.desktops.hyprland.enable; + systemdTarget = "hyprland-session.target"; + + settings = { + general = { + lock_cmd = "pidof ${config.default.lockScreen} || ${config.default.lockScreen}"; + before_sleep_cmd = "loginctl lock-session"; + after_sleep_cmd = "hyprctl dispatch dpms on"; + ignore_dbus_inhibit = false; + }; + + listener = [ + # dim screen + { + timeout = 150; + on-timeout = "brightnessctl -s set 10"; + on-resume = "brightnessctl -r"; + } + # lock + { + timeout = 300; + on-timeout = "loginctl lock-session"; + } + # turn off screen + { + timeout = 350; + on-timeout = "hyprctl dispatch dpms off"; + on-resume = "hyprctl dispatch dpms on"; + } + ]; + }; + }; +} diff --git a/home/desktops/hyprland/plugins.nix b/home/desktops/hyprland/plugins.nix new file mode 100644 index 0000000..0440e12 --- /dev/null +++ b/home/desktops/hyprland/plugins.nix @@ -0,0 +1,40 @@ +{ + inputs, + config, + pkgs, + ... +}: { + wayland.windowManager.hyprland = { + plugins = [ + inputs.hyprland-plugins.packages.${pkgs.system}.hyprexpo + inputs.hy3.packages.${pkgs.system}.hy3 + ]; + + settings.plugin = { + # hy3 + hy3 = { + tabs = { + height = 24; + text_height = 9; + text_padding = 10; + padding = 2; + render_text = true; + text_font = "monospace"; + radius = config.theme.outerRadius; + border_width = config.theme.borderWidth; + + "col.active" = "rgb(${config.theme.colors.base})"; + "col.active.border" = "rgb(${config.theme.colors.primary})"; + "col.active.text" = "rgb(${config.theme.colors.text})"; + "col.inactive" = "rgb(${config.theme.colors.base})"; + "col.inactive.border" = "rgb(${config.theme.colors.surface})"; + "col.inactive.text" = "rgb(${config.theme.colors.text})"; + }; + + autotile = { + enable = true; + }; + }; + }; + }; +} diff --git a/home/desktops/hyprland/settings.nix b/home/desktops/hyprland/settings.nix new file mode 100644 index 0000000..daaf749 --- /dev/null +++ b/home/desktops/hyprland/settings.nix @@ -0,0 +1,125 @@ +{ + config, + pkgs, + lib, + inputs, + ... +}: { + wayland.windowManager.hyprland = { + importantPrefixes = [ + "bezier" + "enabled" + "output" + ]; + + settings = { + # Monitors + monitorv2 = + map (monitor: { + output = monitor.name; + mode = "highres"; + scale = toString monitor.scale; + bitdepth = toString monitor.bitdepth; + }) + config.monitors; + + # Autostart + exec-once = config.autoRun; + + # General + general = { + gaps_in = config.theme.innerGap; + gaps_out = config.theme.outerGap; + layout = "hy3"; + resize_on_border = "yes"; + extend_border_grab_area = 20; + border_size = config.theme.borderWidth; + "col.active_border" = "rgb(${config.theme.colors.primary})"; + "col.inactive_border" = "rgb(${config.theme.colors.surface})"; + }; + + # Gestures + gestures = { + workspace_swipe = true; + workspace_swipe_fingers = 3; + workspace_swipe_forever = true; + workspace_swipe_cancel_ratio = 0.15; + }; + + # Decoration + decoration = { + rounding = config.theme.outerRadius; + shadow.enabled = false; + blur = { + enabled = config.theme.blur; + size = 4; + passes = 2; + noise = 0.008; + contrast = 0.8916; + brightness = 0.8; + }; + }; + + animations = { + enabled = true; + + bezier = [ + "windowIn, 0.06, 0.71, 0.25, 1" + "windowResize, 0.04, 0.67, 0.38, 1" + ]; + + animation = [ + "windowsIn, 1, 3, windowIn, slide #popin 20%" + "windowsOut, 1, 3, windowIn, slide #popin 70%" + "windowsMove, 1, 2.5, windowResize" + "border, 1, 10, default" + "borderangle, 1, 8, default" + "fade, 1, 3, default" + "workspaces, 1, 6, default" + "layers, 1, 5, windowIn, slide" + ]; + }; + + # Input + input = { + kb_layout = "us"; + kb_variant = ""; + kb_model = ""; + kb_options = "gtp:alt_shift_toggle, compose:ralt"; + kb_rules = ""; + follow_mouse = 1; + touchpad = { + natural_scroll = "yes"; + }; + sensitivity = 0; + }; + + # XWayland + xwayland = { + force_zero_scaling = "true"; + use_nearest_neighbor = "false"; + }; + + # Misc + misc = { + disable_hyprland_logo = true; + disable_splash_rendering = true; + key_press_enables_dpms = true; + mouse_move_enables_dpms = true; + enable_anr_dialog = false; + vrr = 1; + }; + + # Ecosystem + ecosystem = { + no_update_news = true; + no_donation_nag = true; + }; + + # Experimental + experimental = { + xx_color_management_v4 = true; + }; + }; # end settings + }; # end hyprland +} diff --git a/home/desktops/hyprland/wallpaper.nix b/home/desktops/hyprland/wallpaper.nix new file mode 100644 index 0000000..e8fc861 --- /dev/null +++ b/home/desktops/hyprland/wallpaper.nix @@ -0,0 +1,11 @@ +{config, ...}: { + services.hyprpaper = { + enable = config.desktops.hyprland.enable; + + settings = { + preload = config.theme.wallpaper; + wallpaper = ",${config.theme.wallpaper}"; + splash = false; + }; + }; +} diff --git a/home/desktops/sway/binds.nix b/home/desktops/sway/binds.nix new file mode 100644 index 0000000..d35f0a7 --- /dev/null +++ b/home/desktops/sway/binds.nix @@ -0,0 +1,89 @@ +{config, ...}: let + mod = "Mod4"; +in { + wayland.windowManager.sway = { + config = { + keybindings = { + # apps + "${mod}+Return" = "exec ${config.default.terminal}"; + "${mod}+l" = "exec ${config.default.lockScreen}"; + "${mod}+d" = "exec ${config.default.appLauncher}"; + "${mod}+w" = "exec ${config.default.browser}"; + + # exit + "${mod}+Shift+l" = "exit"; + # kill focused window + "${mod}+Shift+q" = "kill"; + # reload sway + "${mod}+F5" = "reload"; + + # audio + "XF86AudioRaiseVolume" = "exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"; + "XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"; + "XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; + "XF86AudioMicMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; + + # media + "XF86AudioPlay" = "exec playerctl play-pause"; + "XF86AudioNext" = "exec playerctl next"; + "XF86AudioPrev" = "exec playerctl previous"; + + # backlight + "XF86MonBrightnessDown" = "exec brightnessctl set 5%-"; + "XF86MonBrightnessUp" = "exec brightnessctl set 5%+"; + + # screenshot + "Print" = "exec grimblast copy area"; + + # move focus + "${mod}+Left" = "focus left"; + "${mod}+Down" = "focus down"; + "${mod}+Up" = "focus up"; + "${mod}+Right" = "focus right"; + + # move focused window + "${mod}+Shift+Left" = "move left"; + "${mod}+Shift+Down" = "move down"; + "${mod}+Shift+Up" = "move up"; + "${mod}+Shift+Right" = "move right"; + + # switch workspace + "${mod}+1" = "workspace number 1"; + "${mod}+2" = "workspace number 2"; + "${mod}+3" = "workspace number 3"; + "${mod}+4" = "workspace number 4"; + "${mod}+5" = "workspace number 5"; + "${mod}+6" = "workspace number 6"; + "${mod}+7" = "workspace number 7"; + "${mod}+8" = "workspace number 8"; + "${mod}+9" = "workspace number 9"; + + # move focused container to workspace + "${mod}+Shift+1" = "move container to workspace number 1"; + "${mod}+Shift+2" = "move container to workspace number 2"; + "${mod}+Shift+3" = "move container to workspace number 3"; + "${mod}+Shift+4" = "move container to workspace number 4"; + "${mod}+Shift+5" = "move container to workspace number 5"; + "${mod}+Shift+6" = "move container to workspace number 6"; + "${mod}+Shift+7" = "move container to workspace number 7"; + "${mod}+Shift+8" = "move container to workspace number 8"; + "${mod}+Shift+9" = "move container to workspace number 9"; + + # layout + "${mod}+Shift+d" = "layout default"; + "${mod}+Shift+b" = "layout splith"; + "${mod}+Shift+v" = "layout splitv"; + "${mod}+Shift+c" = "layout tabbed"; + + # fullscreen + "${mod}+f" = "fullscreen"; + # float + "${mod}+Shift+space" = "floating toggle"; + # focus + "${mod}+space" = "focus mode_toggle"; + # parent + "${mod}+a" = "focus parent"; + }; + }; + }; +} diff --git a/home/desktops/sway/config.nix b/home/desktops/sway/config.nix new file mode 100644 index 0000000..b3d07d4 --- /dev/null +++ b/home/desktops/sway/config.nix @@ -0,0 +1,122 @@ +{config, ...}: { + wayland.windowManager.sway = { + config = { + # monitors + output = + (builtins.listToAttrs (map (mon: { + name = mon.name; + value = { + dpms = "on"; + scale = toString mon.scale; + render_bit_depth = toString mon.bitdepth; + }; + }) + config.monitors)) + // { + # wallpaper + "*" = { + bg = "${config.theme.wallpaper} fill"; + }; + }; + + # inputs + input = { + "*" = { + xkb_layout = "us"; + xkb_options = "compose:ralt"; + xkb_numlock = "enable"; + }; + + "type:touchpad" = { + tap = "enabled"; + natural_scroll = "enabled"; + middle_emulation = "enabled"; + }; + }; + + startup = + # autostart apps + builtins.map (command: { + inherit command; + always = false; + }) + config.autoRun; + + # colors + colors = let + base = "#${config.theme.colors.base}"; + surface = "#${config.theme.colors.surface}"; + primary = "#${config.theme.colors.primary}"; + text = "#${config.theme.colors.text}"; + white = "#${config.theme.colors.bright.white}"; + error = "#${config.theme.colors.error}"; + in rec { + background = base; + + focused = { + border = primary; + background = base; + text = text; + indicator = white; + childBorder = primary; + }; + + focusedInactive = { + border = surface; + background = base; + text = text; + indicator = surface; + childBorder = surface; + }; + + unfocused = focusedInactive; + + urgent = { + border = error; + background = error; + text = text; + indicator = error; + childBorder = error; + }; + + placeholder = unfocused; + }; + + window = { + titlebar = false; + border = config.theme.borderWidth; + }; + + floating = { + titlebar = false; + border = config.theme.borderWidth; + modifier = "Mod4 normal"; + }; + + gaps = { + inner = config.theme.innerGap; + outer = config.theme.outerGap; + }; + + modes = {}; + bars = []; + }; + + extraConfig = '' + # gestures + bindgesture swipe:right workspace prev + bindgesture swipe:left workspace next + + # swayfx + corner_radius ${toString config.theme.outerRadius} + smart_corner_radius ${toString config.theme.outerRadius} + blur ${ + if config.theme.blur + then "enabled" + else "disabled" + } + blur_radius 10 + blur_passes 3 + ''; + }; +} diff --git a/home/desktops/sway/default.nix b/home/desktops/sway/default.nix new file mode 100644 index 0000000..3553c4a --- /dev/null +++ b/home/desktops/sway/default.nix @@ -0,0 +1,28 @@ +{ + lib, + config, + pkgs, + ... +}: let + inherit (lib) mkIf mkDefault; + cfg = config.desktops.sway; +in { + imports = [ + ./binds.nix + ./config.nix + ./idle.nix + ]; + + config = mkIf cfg.enable { + wayland.windowManager.sway = { + enable = true; + package = pkgs.swayfx; + + # TODO: get swayfx to work with check config + checkConfig = false; + + xwayland = true; + systemd.enable = true; + }; + }; +} diff --git a/home/desktops/sway/idle.nix b/home/desktops/sway/idle.nix new file mode 100644 index 0000000..1af4a6a --- /dev/null +++ b/home/desktops/sway/idle.nix @@ -0,0 +1,25 @@ +{config, ...}: { + services.swayidle = { + enable = config.desktops.sway.enable; + systemdTarget = "sway-session.target"; + + timeouts = [ + { + timeout = 300; + command = "${config.default.lockScreen}"; + } + { + timeout = 300; + command = "swaymsg \"output * power off\""; + resumeCommand = "swaymsg \"output * power on\""; + } + ]; + + events = [ + { + event = "before-sleep"; + command = "${config.default.lockScreen}"; + } + ]; + }; +} |