diff --git a/home/default.nix b/home/default.nix index 42e6273..46d886d 100644 --- a/home/default.nix +++ b/home/default.nix @@ -10,7 +10,7 @@ ./programs/git.nix ./programs/lf/. ./programs/zsh.nix - ./programs/tmux.nix + ./programs/tmux/. ]; programs.home-manager.enable = true; diff --git a/home/desktop/hyprland/default.nix b/home/desktop/hyprland/default.nix index 7e7311d..81efc71 100644 --- a/home/desktop/hyprland/default.nix +++ b/home/desktop/hyprland/default.nix @@ -6,18 +6,11 @@ }: let modifier = config.windowManager.modifierKey; menu = config.programs.menu.dmenuCommand; - lock_cmd = "${config.programs.hyprlock.package}/bin/hyprlock"; - color = { - inherit (config.lib.stylix.colors) yellow red; - bg = config.lib.stylix.colors.base00; - fg = config.lib.stylix.colors.base07; - text = config.lib.stylix.colors.base05; - }; - rgb = color: "rgb(${color})"; in { imports = [ (import ../utils/waybar.nix) (import ../utils/display.nix) + (import ../utils/hypridle.nix) ../../workstation.nix ]; xdg.portal = { @@ -26,64 +19,6 @@ in { extraPortals = [pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-wlr]; }; - services.hypridle = { - enable = true; - settings = { - general = { - before_sleep_cmd = "rbw lock; hyprlock"; - after_sleep_cmd = "hyprctl dispatch dpms on"; - ignore_dbus_inhibit = false; - lock_cmd = "pidof ${lock_cmd} || ${lock_cmd}"; - }; - - listener = [ - { - timeout = 300; - on-timeout = "loginctl lock-session"; - } - { - timeout = 1200; - on-timeout = "hyprctl dispatch dpms off"; - on-resume = "hyprctl dispatch dpms on"; - } - ]; - }; - }; - - programs.hyprlock = { - enable = true; - settings = lib.mkForce { - # https://wiki.hyprland.org/Hypr-Ecosystem/hyprlock/ - general = { - hide_cursor = true; - grace = 10; - ignore_empty_input = true; - }; - - background = [ - { - path = "screenshot"; - blur_passes = 3; - blur_size = 8; - } - ]; - - input-field = [ - { - dots_center = true; - fade_on_empty = true; - outline_thickness = 5; - shadow_passes = 2; - inner_color = rgb color.bg; - outer_color = rgb color.fg; - font_color = rgb color.text; - fail_color = rgb color.red; - check_color = rgb color.yellow; - } - ]; - }; - }; - wayland.windowManager.hyprland = { enable = true; systemd = { diff --git a/home/desktop/niri/default.nix b/home/desktop/niri/default.nix index fcfa0a8..9fd5805 100644 --- a/home/desktop/niri/default.nix +++ b/home/desktop/niri/default.nix @@ -4,6 +4,14 @@ config, ... }: { + imports = [ + (import ../utils/hypridle.nix) + (import ../utils/waybar.nix) + ../../workstation.nix + ]; + + programs.waybar.settings.mainBar.modules-left = ["niri/workspaces" "niri/window"]; + programs.fuzzel = { enable = true; settings = { @@ -15,15 +23,18 @@ }; services.hyprpaper.enable = true; systemd.user.services.hyprpaper.Unit.WantedBy = ["niri.service"]; + systemd.user.services.waybar.Unit.WantedBy = ["niri.service"]; home.packages = with pkgs; [brightnessctl]; services.mako.enable = true; + systemd.user.services.mako.Unit.WantedBy = ["niri.service"]; programs.niri = { settings = { input.keyboard = { xkb.layout = "us"; xkb.variant = "dvorak"; + xkb.options = "caps:escape"; }; input.mouse = { accel-profile = "flat"; @@ -34,8 +45,35 @@ prefer-no-csd = true; spawn-at-startup = [ {command = [(lib.getExe pkgs.xwayland-satellite)];} - {command = [(lib.getExe config.services.mako.package)];} ]; + layout = { + preset-column-widths = [ + {proportion = 1.0;} + {proportion = 1.0 / 2.0;} + ]; + }; + environment = { + NIXOS_OZONE_WL = "1"; + DISPLAY = ":1"; + }; + outputs."DP-3" = { + mode = { + width = 1920; + height = 1080; + refresh = 143.855; + }; + variable-refresh-rate = true; + scale = 1.0; + }; + outputs."HDMI-A-1" = { + mode = { + width = 3840; + height = 2160; + refresh = 120.0; + }; + variable-refresh-rate = true; + scale = 2.5; + }; binds = with config.lib.niri.actions; { "Mod+Return".action.spawn = [(lib.getExe config.programs.terminal)]; "Mod+O".action.spawn = [(lib.getExe pkgs.cosmic-files)]; @@ -47,12 +85,14 @@ "Mod+Ctrl+WheelScrollRight".action = move-column-right; "Mod+Right".action = focus-column-right; + "Mod+Ctrl+Right".action = move-column-right; "Mod+L".action = focus-column-right; "Mod+Ctrl+L".action = move-column-right; "Mod+WheelScrollLeft".action = focus-column-left; "Mod+Ctrl+WheelScrollLeft".action = move-column-left; "Mod+Left".action = focus-column-left; + "Mod+Ctrl+Left".action = move-column-left; "Mod+H".action = focus-column-left; "Mod+Ctrl+H".action = move-column-left; @@ -62,16 +102,28 @@ "Mod+Comma".action = consume-or-expel-window-left; "Mod+Period".action = consume-or-expel-window-right; + "Mod+F".action = fullscreen-window; "Mod+Q".action = close-window; "Mod+Shift+Escape".action = quit; + "Mod+Escape".action.spawn = lib.getExe config.programs.hyprlock.package; "Mod+WheelScrollDown".action = focus-workspace-down; "Mod+WheelScrollUp".action = focus-workspace-up; "Mod+Ctrl+WheelScrollDown".action = move-column-to-workspace-down; "Mod+Ctrl+WheelScrollUp".action = move-column-to-workspace-up; - "Mod+M".action = maximize-column; + "Mod+J".action = focus-workspace-down; + "Mod+K".action = focus-workspace-up; + "Mod+Ctrl+J".action = move-column-to-workspace-down; + "Mod+Ctrl+K".action = move-column-to-workspace-up; + + "Mod+Down".action = focus-workspace-down; + "Mod+Up".action = focus-workspace-up; + "Mod+Ctrl+Down".action = move-column-to-workspace-down; + "Mod+Ctrl+Up".action = move-column-to-workspace-up; + + "Mod+M".action = switch-preset-column-width; "Mod+G".action = toggle-window-floating; "Print".action = screenshot; diff --git a/home/desktop/utils/hypridle.nix b/home/desktop/utils/hypridle.nix new file mode 100644 index 0000000..d0c0316 --- /dev/null +++ b/home/desktop/utils/hypridle.nix @@ -0,0 +1,72 @@ +{ + config, + lib, + ... +}: let + rgb = color: "rgb(${color})"; + lock_cmd = "${config.programs.hyprlock.package}/bin/hyprlock"; + color = { + inherit (config.lib.stylix.colors) yellow red; + bg = config.lib.stylix.colors.base00; + fg = config.lib.stylix.colors.base07; + text = config.lib.stylix.colors.base05; + }; +in { + services.hypridle = { + enable = true; + settings = { + general = { + before_sleep_cmd = "rbw lock; hyprlock"; + after_sleep_cmd = "hyprctl dispatch dpms on"; + ignore_dbus_inhibit = false; + lock_cmd = "pidof ${lock_cmd} || ${lock_cmd}"; + }; + + listener = [ + { + timeout = 300; + on-timeout = "loginctl lock-session"; + } + { + timeout = 1200; + on-timeout = "hyprctl dispatch dpms off"; + on-resume = "hyprctl dispatch dpms on"; + } + ]; + }; + }; + + programs.hyprlock = { + enable = true; + settings = lib.mkForce { + # https://wiki.hyprland.org/Hypr-Ecosystem/hyprlock/ + general = { + hide_cursor = true; + grace = 10; + ignore_empty_input = true; + }; + + background = [ + { + path = "screenshot"; + blur_passes = 3; + blur_size = 8; + } + ]; + + input-field = [ + { + dots_center = true; + fade_on_empty = true; + outline_thickness = 5; + shadow_passes = 2; + inner_color = rgb color.bg; + outer_color = rgb color.fg; + font_color = rgb color.text; + fail_color = rgb color.red; + check_color = rgb color.yellow; + } + ]; + }; + }; +} diff --git a/home/desktop/utils/waybar.nix b/home/desktop/utils/waybar.nix index f03354f..02d90cb 100644 --- a/home/desktop/utils/waybar.nix +++ b/home/desktop/utils/waybar.nix @@ -7,9 +7,24 @@ layer = "bottom"; position = "top"; height = 36; - modules-right = ["mpris" "idle_inhibitor" "pulseaudio" "clock" "tray" "battery"]; + modules-right = ["mpris" "power-profiles-daemon" "cpu" "idle_inhibitor" "pulseaudio" "clock" "tray" "battery"]; + "cpu" = { + "format" = "{icon}"; + "format-icons" = ["▁" "▂" "▃" "▄" "▅" "▆" "▇" "█"]; + }; + "power-profiles-daemon" = { + "format" = "{icon}"; + "tooltip-format" = "Power profile: {profile}\nDriver: {driver}"; + "tooltip" = true; + "format-icons" = { + "default" = ""; + "performance" = ""; + "balanced" = ""; + "power-saver" = ""; + }; + }; clock = { - format = "📅 {:%a %b-%d %I:%M %p}"; + format = "📅 {:%a %b-%d, %I:%M %p}"; }; idle_inhibitor = { format = "{icon}"; diff --git a/home/programs/tmux.nix b/home/programs/tmux/default.nix similarity index 76% rename from home/programs/tmux.nix rename to home/programs/tmux/default.nix index 4d645ca..d964aae 100644 --- a/home/programs/tmux.nix +++ b/home/programs/tmux/default.nix @@ -1,4 +1,10 @@ { + pkgs, + lib, + ... +}: let + sessionizer = lib.getExe (pkgs.writeShellScriptBin "tmux-sessionizer" (lib.readFile ./sessionizer.sh)); +in { programs.tmux = { enable = true; baseIndex = 1; @@ -25,8 +31,12 @@ bind -n M-u copy-mode bind -n M-p previous-window bind -n M-n next-window + bind-key -r f run-shell "tmux neww ${sessionizer}" set-option -g renumber-windows on ''; }; + programs.zsh.initContent = '' + bindkey -s ^f "${sessionizer}\n" + ''; } diff --git a/home/programs/tmux/sessionizer.sh b/home/programs/tmux/sessionizer.sh new file mode 100644 index 0000000..33ac5fc --- /dev/null +++ b/home/programs/tmux/sessionizer.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +if [[ $# -eq 1 ]]; then + selected=$1 +else + selected=$(find ~/Documents/code ~/Documents/infra -mindepth 1 -maxdepth 1 -type d | fzf) +fi + +if [[ -z $selected ]]; then + exit 0 +fi + +selected_name=$(basename "$selected" | tr . _) +tmux_running=$(pgrep tmux) + +if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then + tmux new-session -s $selected_name -c $selected + exit 0 +fi + +if ! tmux has-session -t=$selected_name 2> /dev/null; then + tmux new-session -ds $selected_name -c $selected +fi + +if [[ -z $TMUX ]]; then + tmux attach -t $selected_name +else + tmux switch-client -t $selected_name +fi diff --git a/home/workstation.nix b/home/workstation.nix index f4e68c0..2e9b0c2 100644 --- a/home/workstation.nix +++ b/home/workstation.nix @@ -28,6 +28,7 @@ playerctl quickemu devenv + bottles ]; services.udiskie = {