{ config, lib, pkgs, inputs, system, ... }: let colors = import ../colors.nix; in { options.custom.gui = with lib; { i3 = { enable = mkEnableOption "Enable i3"; }; }; config = lib.mkIf config.custom.gui.i3.enable { xdg.configFile."i3status/config".source = pkgs.replaceVars ./i3status.config { inherit (colors) green warning error; }; services.picom = { enable = true; }; services.dunst = { enable = true; settings = { global = { width = 300; height = 300; origin = "top-right"; offset = "10x50"; notification_limit = 5; progress_bar = true; progress_bar_height = 10; progress_bar_frame_width = 1; progress_bar_min_width = 150; progress_bar_max_width = 300; transparency = 0; separator_height = 2; padding = 8; horizontal_padding = 8; frame_width = 2; frame_color = colors.border; separator_color = "frame"; sort = true; idle_threshold = 120; font = "Monospace 10"; line_height = 0; markup = "full"; format = "%s\\n%b"; alignment = "left"; vertical_alignment = "center"; show_age_threshold = 60; ellipsize = "middle"; stack_duplicates = true; show_indicators = true; icon_position = "left"; min_icon_size = 32; max_icon_size = 128; sticky_history = true; history_length = 20; corner_radius = 8; mouse_left_click = "close_current"; mouse_middle_click = "do_action, close_current"; mouse_right_click = "close_all"; }; urgency_low = { background = colors.bg; foreground = colors.fg; frame_color = colors.border; timeout = 5; }; urgency_normal = { background = colors.bg; foreground = colors.fg; frame_color = colors.info; timeout = 10; }; urgency_critical = { background = colors.bg_dark; foreground = colors.fg; frame_color = colors.error; timeout = 0; }; }; }; home.pointerCursor = { package = pkgs.adwaita-icon-theme; name = "Adwaita"; size = 32; x11.enable = true; }; xsession = { enable = true; scriptPath = ".xsession-hm"; initExtra = '' # export GDK_SCALE=2 # export GDK_DPI_SCALE=0.5 export _JAVA_OPTIONS="-Dsun.java2d.uiScale=2" export QT_AUTO_SCREEN_SCALE_FACTOR=1 export QT_DEVICE_PIXEL_RATIO=2 # export XCURSOR_SIZE=128 # ${pkgs.xorg.xsetroot}/bin/xsetroot -cursor_name ${pkgs.vanilla-dmz}/share/icons/Vanilla-DMZ/cursors/left_ptr 128 &disown if test -e $HOME/.Xresources; then ${pkgs.xorg.xrdb}/bin/xrdb -merge $HOME/.Xresources &disown fi # echo "Xft.dpi: 192" | ${pkgs.xorg.xrdb}/bin/xrdb -merge echo "Xft.dpi: 144" | ${pkgs.xorg.xrdb}/bin/xrdb -merge ''; windowManager.i3 = let modifier = "Mod4"; powerManagementMode = " : Screen [l]ock, [e]xit, [s]uspend, [h]ibernate, [R]eboot, [S]hutdown"; miscellaneousMode = "D [p]ause, D [c]ontinue"; resizeMode = " : [h]  , [j]  , [k]  , [l] "; light = lib.getExe' pkgs.brightnessctl "brightnessctl"; pactl = lib.getExe' pkgs.pulseaudio "pactl"; maim = lib.getExe' pkgs.maim "maim"; clipboard = lib.getExe' pkgs.xclip "xclip"; yazi = lib.getExe' pkgs.yazi "yazi"; terminal = lib.getExe' inputs.ghostty.packages."${system}".default "ghostty"; # terminal = lib.getExe' pkgs.kitty "kitty"; # second_terminal = lib.getExe' pkgs.wezterm "wezterm"; playerctl = lib.getExe' pkgs.playerctl "playerctl"; dmenu = lib.getExe' pkgs.dmenu "dmenu_run"; refresh_i3status = "killall -SIGUSR1 i3status"; boomer = lib.getExe' pkgs.custom.boomer "boomer"; # config = pkgs.substituteAll { # inherit term second_term; # src = ./config; # raise_vol = "${pactl} set-sink-volume @DEFAULT_SINK@ +1% && $refresh_i3status"; # lower_vol = "${pactl} set-sink-volume @DEFAULT_SINK@ -1% && $refresh_i3status"; # mute_vol = "${pactl} set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status"; # mute_mic = "${pactl} set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status"; # screenshot = "${maim} -s ~/Pictures/screenshots/$(date +%Y-%m-%d-%H-%M-%S).png"; # screenshot_clipboard = "${maim} -s | ${clipboard} -selection clipboard -t image/png"; # media_play = "${playerctl} play-pause"; # media_pause = "${playerctl} play-pause"; # media_next = "${playerctl} next"; # media_prev = "${playerctl} previous"; # fm = "${term} -e ${fm}"; # startup = '' # exec --no-startup-id ${pkgs.dex}/bin/dex --autostart --environment i3 # exec --no-startup-id ${pkgs.networkmanagerapplet}/bin/nm-applet # exec --no-startup-id ${pkgs.pasystray}/bin/pasystray # exec --no-startup-id ${pkgs.xss-lock}/bin/xss-lock --transfer-sleep-lock -- i3lock --nofork # ''; # }; in { enable = true; config = { inherit modifier terminal; fonts = { names = [ "SpaceMono Nerd Font" ]; size = 10.0; }; keybindings = lib.mkOptionDefault { "${modifier}+h" = "focus left"; "${modifier}+j" = "focus down"; "${modifier}+k" = "focus up"; "${modifier}+l" = "focus right"; "${modifier}+Shift+h" = "move left"; "${modifier}+Shift+j" = "move down"; "${modifier}+Shift+k" = "move up"; "${modifier}+Shift+l" = "move right"; "${modifier}+v" = "split h"; "${modifier}+Shift+v" = "split v"; "${modifier}+s" = "layout stacking"; "${modifier}+t" = "layout tabbed"; "${modifier}+e" = "layout toggle split"; "${modifier}+p" = "floating toggle"; "${modifier}+Shift+p" = "focus mode_toggle"; "${modifier}+Shift+c" = "reload"; "${modifier}+Shift+r" = "restart"; # mode "${modifier}+r" = ''mode "${resizeMode}"''; "${modifier}+Escape" = ''mode "${powerManagementMode}"''; "${modifier}+Shift+Escape" = ''mode "${miscellaneousMode}"''; # workspace # "${modifier}+Shift+minus" = "move scratchpad"; # "${modifier}+minus" = "scratchpad show"; # media "XF86AudioRaiseVolume" = "exec --no-startup-id ${pactl} set-sink-volume @DEFAULT_SINK@ +1% && ${refresh_i3status}"; "XF86AudioLowerVolume" = "exec --no-startup-id ${pactl} set-sink-volume @DEFAULT_SINK@ -1% && ${refresh_i3status}"; "XF86AudioMute" = "exec --no-startup-id ${pactl} set-sink-mute @DEFAULT_SINK@ toggle && ${refresh_i3status}"; "XF86AudioMicMute" = "exec --no-startup-id ${pactl} set-source-mute @DEFAULT_SOURCE@ toggle && ${refresh_i3status}"; "XF86AudioPlay" = "exec --no-startup-id ${playerctl} play-pause"; "XF86AudioPause" = "exec --no-startup-id ${playerctl} play-pause"; "XF86AudioNext" = "exec --no-startup-id ${playerctl} next"; "XF86AudioPrev" = "exec --no-startup-id ${playerctl} previous"; # brightness "XF86MonBrightnessUp" = "exec --no-startup-id ${light} s +10%"; "XF86MonBrightnessDown" = "exec --no-startup-id ${light} s 10%-"; # screenshot "${modifier}+o" = "exec --no-startup-id ${maim} -s ~/Pictures/screenshots/$(date +%Y-%m-%d-%H-%M-%S).png"; "${modifier}+Shift+o" = "exec --no-startup-id ${maim} -s | ${clipboard} -selection clipboard -t image/png"; # others "${modifier}+space" = "exec --no-startup-id ${dmenu}"; "${modifier}+b" = "exec --no-startup-id ${terminal} -e ${yazi}"; "${modifier}+z" = "exec --no-startup-id ${boomer}"; # tsoding's zoom # "${modifier}+Shift+Return" = "exec ${second_terminal}"; # reset "${modifier}+Shift+e" = null; "${modifier}+w" = null; "${modifier}+d" = null; }; modes = let exitMode = { "Escape" = "mode default"; "Return" = "mode default"; }; in { "${resizeMode}" = { "Left" = "resize shrink width 10 px or 10 ppt"; "Down" = "resize grow height 10 px or 10 ppt"; "Up" = "resize shrink height 10 px or 10 ppt"; "Right" = "resize grow width 10 px or 10 ppt"; "Escape" = "mode default"; "Return" = "mode default"; } // exitMode; "${powerManagementMode}" = { l = "mode default, exec loginctl lock-session"; e = "mode default, exec loginctl terminate-session $XDG_SESSION_ID"; s = "mode default, exec systemctl suspend"; h = "mode default, exec systemctl hibernate"; "Shift+r" = "mode default, exec systemctl reboot"; "Shift+s" = "mode default, exec systemctl poweroff"; } // exitMode; "${miscellaneousMode}" = { p = "mode default, exec kill -SIGUSR1 $(pidof dunst)"; c = "mode default, exec kill -SIGUSR2 $(pidof dunst"; } // exitMode; }; colors = { focused = { border = colors.info; background = colors.bg_highlight; text = colors.fg; indicator = colors.info; childBorder = colors.info; }; focusedInactive = { border = colors.border; background = colors.bg_float; text = colors.fg_dark; indicator = colors.border; childBorder = colors.border; }; unfocused = { border = colors.bg_dark; background = colors.bg_dark; text = colors.comment; indicator = colors.bg_dark; childBorder = colors.bg_dark; }; urgent = { border = colors.error; background = colors.error; text = colors.fg; indicator = colors.error; childBorder = colors.error; }; }; bars = [ { position = "bottom"; statusCommand = "${pkgs.i3status}/bin/i3status"; fonts = { names = [ "SpaceMono Nerd Font" ]; size = 10.0; }; colors = { background = colors.bar_bg; statusline = colors.fg; separator = colors.border; focusedWorkspace = { border = colors.bar_accent; background = colors.bar_accent; text = colors.bg_darker; }; activeWorkspace = { border = colors.bg_highlight; background = colors.bg_highlight; text = colors.fg; }; inactiveWorkspace = { border = colors.bar_bg; background = colors.bar_bg; text = colors.fg_dark; }; urgentWorkspace = { border = colors.error; background = colors.error; text = colors.fg; }; }; } ]; startup = [ { command = "${pkgs.hsetroot}/bin/hsetroot -solid \"${colors.bg}\""; notification = false; } { command = "${pkgs.dex}/bin/dex --autostart --environment i3"; notification = false; } { command = "${pkgs.networkmanagerapplet}/bin/nm-applet"; notification = false; } { command = "${pkgs.pasystray}/bin/pasystray"; notification = false; } { command = "${pkgs.xss-lock}/bin/xss-lock --transfer-sleep-lock -- i3lock --nofork"; notification = false; } { command = "${pkgs.autorandr}/bin/autorandr -c"; always = false; # Important, run only on first start (will loop otherwise)! notification = false; } { command = "${pkgs.xfce.xfce4-volumed-pulse}/bin/xfce4-volumed-pulse &"; always = false; notification = false; } { command = "${light} s 25%"; } ]; }; }; }; }; }