diff --git a/home/christoph/default.nix b/home/christoph/default.nix index d2387be7..90f7e836 100644 --- a/home/christoph/default.nix +++ b/home/christoph/default.nix @@ -82,136 +82,7 @@ signCommits = true; }; - hyprland = { - enable = !headless; - dunst.enable = !config.modules.hyprpanel.enable; # Disable for hyprpanel - - keybindings = { - main-mod = "SUPER"; - - bindings = { - "$mainMod, t" = ["exec, kitty"]; - "$mainMod, e" = ["exec, kitty --title=Yazi yazi"]; - "$mainMod, n" = ["exec, neovide"]; - # "$mainMod, r" = ["exec, kitty --title=Rmpc rmpc"]; - "$mainMod CTRL, n" = ["exec, kitty --title=Navi navi"]; - "$mainMod SHIFT, n" = ["exec, neovide ${config.paths.dotfiles}/navi/christoph.cheat"]; - "$mainMod SHIFT, f" = ["exec, neovide ${config.paths.dotfiles}/flake.nix"]; - - "$mainMod, p" = ["exec, hyprpicker --autocopy --format=hex"]; - "$mainMod, s" = ["exec, grim -g \"$(slurp)\""]; - "$mainMod CTRL, s" = ["exec, grim -g \"$(slurp)\" - | wl-copy"]; - "$mainMod SHIFT, s" = ["exec, grim -g \"$(slurp)\" - | wl-copy"]; - - ", XF86AudioRaiseVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"]; - ", XF86AudioLowerVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%-"]; - ", XF86AudioPlay" = ["exec, playerctl play-pause"]; - ", XF86AudioPrev" = ["exec, playerctl previous"]; - ", XF86AudioNext" = ["exec, playerctl next"]; - - ", XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset gamma -10"]; - ", XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset gamma +10"]; - "$mainMod, XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset temperature 5750"]; - "$mainMod, XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset identity"]; - - # "CTRL ALT, t" = ["exec, bash -c 'systemctl --user restart hyprpanel.service'"]; - }; - - ws-bindings = { - # "" = ""; - "1" = "1"; - "2" = "2"; - "3" = "3"; - "4" = "4"; - "5" = "5"; - "6" = "6"; - "7" = "7"; - "8" = "8"; - "9" = "9"; - "10" = "0"; - }; - - special-ws-bindings = { - "ferdium" = "x"; - "msty" = "z"; - "btop" = "b"; - "rmpc" = "r"; - }; - }; - - autostart = { - immediate = [ - "kitty" - "zeal" - "nextcloud --background" - "protonvpn-app" - - # "kdeconnect-indicator" # started by services.kdeconnect.indicator - ]; - - delayed = [ - "keepassxc" # The tray doesn't work when started too early - ]; - - special-silent = { - "ferdium" = ["ferdium"]; - "msty" = ["msty"]; - "btop" = ["kitty --title=Btop btop"]; - "rmpc" = ["kitty --title=Rmpc rmpc"]; - }; - }; - - windowrules = []; - - workspacerules = { - "1" = []; - "2" = ["Zotero" "neovide" "code-url-handler"]; - "3" = ["obsidian" "unityhub" "Unity"]; - "4" = ["firefox" "Google-chrome" "chromium-browser" "org.qutebrowser.qutebrowser"]; - "5" = ["steam"]; - "6" = ["steam_app_(.+)"]; - "7" = ["signal"]; - "8" = ["tidal-hifi"]; - "9" = ["discord"]; - "10" = ["python3"]; - }; - - floating = [ - {class = "org.kde.polkit-kde-authentication-agent-1";} - { - class = "thunar"; - title = "File Operation Progress"; - } - {class = "ffplay";} - ]; - - transparent-opacity = "0.75"; - - transparent = [ - "kitty" - "Alacritty" - "discord" - "signal" - "vesktop" - "Spotify" - "tidal-hifi" - "obsidian" - "firefox" - "org.qutebrowser.qutebrowser" - "jetbrains-clion" - "jetbrains-idea" - "jetbrains-pycharm" - "jetbrains-rustrover" - "jetbrains-rider" - "jetbrains-webstorm" - "code-url-handler" - "neovide" - "steam" - "ferdium" - "Msty" - ]; - }; - + hyprland = import ./hyprland.nix {inherit config headless;}; hyprpanel.enable = !headless; kitty.enable = !headless; lazygit.enable = true; @@ -561,17 +432,20 @@ waves = false; # default false }; - color = { + color = let + color = config.modules.color; + in { # https://github.com/catppuccin/cava/blob/main/themes/latte-transparent.cava gradient = 1; - gradient_color_1 = "'#179299'"; - gradient_color_2 = "'#04a5e5'"; - gradient_color_3 = "'#209fb5'"; - gradient_color_4 = "'#1e66f5'"; - gradient_color_5 = "'#8839ef'"; - gradient_color_6 = "'#ea76cb'"; - gradient_color_7 = "'#e64553'"; - gradient_color_8 = "'#d20f39'"; + + gradient_color_1 = "'${color.hexS.teal}'"; + gradient_color_2 = "'${color.hexS.sky}'"; + gradient_color_3 = "'${color.hexS.sapphire}'"; + gradient_color_4 = "'${color.hexS.blue}'"; + gradient_color_5 = "'${color.hexS.mauve}'"; + gradient_color_6 = "'${color.hexS.pink}'"; + gradient_color_7 = "'${color.hexS.maroon}'"; + gradient_color_8 = "'${color.hexS.red}'"; }; }; }; diff --git a/home/christoph/hyprland.nix b/home/christoph/hyprland.nix new file mode 100644 index 00000000..3f8cf9a1 --- /dev/null +++ b/home/christoph/hyprland.nix @@ -0,0 +1,132 @@ +{ + config, + headless, +}: { + enable = !headless; + dunst.enable = !config.modules.hyprpanel.enable; # Disable for hyprpanel + + keybindings = { + main-mod = "SUPER"; + + bindings = { + "$mainMod, t" = ["exec, kitty"]; + "$mainMod, e" = ["exec, kitty --title=Yazi yazi"]; + "$mainMod, n" = ["exec, neovide"]; + # "$mainMod, r" = ["exec, kitty --title=Rmpc rmpc"]; + "$mainMod CTRL, n" = ["exec, kitty --title=Navi navi"]; + "$mainMod SHIFT, n" = ["exec, neovide ${config.paths.dotfiles}/navi/christoph.cheat"]; + "$mainMod SHIFT, f" = ["exec, neovide ${config.paths.dotfiles}/flake.nix"]; + + "$mainMod, p" = ["exec, hyprpicker --autocopy --format=hex"]; + "$mainMod, s" = ["exec, grim -g \"$(slurp)\""]; + "$mainMod CTRL, s" = ["exec, grim -g \"$(slurp)\" - | wl-copy"]; + "$mainMod SHIFT, s" = ["exec, grim -g \"$(slurp)\" - | wl-copy"]; + + ", XF86AudioRaiseVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"]; + ", XF86AudioLowerVolume" = ["exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%-"]; + ", XF86AudioPlay" = ["exec, playerctl play-pause"]; + ", XF86AudioPrev" = ["exec, playerctl previous"]; + ", XF86AudioNext" = ["exec, playerctl next"]; + + ", XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset gamma -10"]; + ", XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset gamma +10"]; + "$mainMod, XF86MonBrightnessDown" = ["exec, hyprctl hyprsunset temperature 5750"]; + "$mainMod, XF86MonBrightnessUp" = ["exec, hyprctl hyprsunset identity"]; + + # "CTRL ALT, t" = ["exec, bash -c 'systemctl --user restart hyprpanel.service'"]; + }; + + ws-bindings = { + # "" = ""; + "1" = "1"; + "2" = "2"; + "3" = "3"; + "4" = "4"; + "5" = "5"; + "6" = "6"; + "7" = "7"; + "8" = "8"; + "9" = "9"; + "10" = "0"; + }; + + special-ws-bindings = { + "ferdium" = "x"; + "msty" = "z"; + "btop" = "b"; + "rmpc" = "r"; + }; + }; + + autostart = { + immediate = [ + "kitty" + "zeal" + "nextcloud --background" + "protonvpn-app" + + # "kdeconnect-indicator" # started by services.kdeconnect.indicator + ]; + + delayed = [ + "keepassxc" # The tray doesn't work when started too early + ]; + + special-silent = { + "ferdium" = ["ferdium"]; + "msty" = ["msty"]; + "btop" = ["kitty --title=Btop btop"]; + "rmpc" = ["kitty --title=Rmpc rmpc"]; + }; + }; + + windowrules = []; + + workspacerules = { + "1" = []; + "2" = ["Zotero" "neovide" "code-url-handler"]; + "3" = ["obsidian" "unityhub" "Unity"]; + "4" = ["firefox" "Google-chrome" "chromium-browser" "org.qutebrowser.qutebrowser"]; + "5" = ["steam"]; + "6" = ["steam_app_(.+)"]; + "7" = ["signal"]; + "8" = ["tidal-hifi"]; + "9" = ["discord"]; + "10" = ["python3"]; + }; + + floating = [ + {class = "org.kde.polkit-kde-authentication-agent-1";} + { + class = "thunar"; + title = "File Operation Progress"; + } + {class = "ffplay";} + ]; + + transparent-opacity = "0.75"; + + transparent = [ + "kitty" + "Alacritty" + "discord" + "signal" + "vesktop" + "Spotify" + "tidal-hifi" + "obsidian" + "firefox" + "org.qutebrowser.qutebrowser" + "jetbrains-clion" + "jetbrains-idea" + "jetbrains-pycharm" + "jetbrains-rustrover" + "jetbrains-rider" + "jetbrains-webstorm" + "code-url-handler" + "neovide" + "steam" + "ferdium" + "Msty" + ]; +} diff --git a/home/modules/hyprland/default.nix b/home/modules/hyprland/default.nix index 5cfe849c..230a30d6 100644 --- a/home/modules/hyprland/default.nix +++ b/home/modules/hyprland/default.nix @@ -150,205 +150,16 @@ in { inputs.hyprland-plugins.packages.${pkgs.system}.hyprbars ]; - settings = { - "$mainMod" = "${hyprland.keybindings.main-mod}"; - - general = { - gaps_in = 5; - gaps_out = 10; - border_size = 2; - - "col.active_border" = "rgb(${color.hex.accent})"; - "col.inactive_border" = "rgb(${color.hex.base})"; - }; - - group = { - groupbar = { - enabled = true; - render_titles = false; - font_size = 10; - gradients = false; - - "col.active" = "rgb(${color.hex.accent})"; - "col.inactive" = "rgb(${color.hex.base})"; - }; - - "col.border_active" = "rgb(${color.hex.accent})"; - "col.border_inactive" = "rgb(${color.hex.base})"; - }; - - input = { - kb_layout = hyprland.keyboard.layout; - kb_variant = hyprland.keyboard.variant; - kb_options = hyprland.keyboard.option; - kb_model = "pc104"; - kb_rules = ""; - - follow_mouse = true; - - touchpad = { - natural_scroll = "no"; - }; - - sensitivity = 0; # -1.0 - 1.0, 0 means no modification. - }; - - monitor = let - mkMonitor = name: conf: - "${name}, " - + "${builtins.toString conf.width}x${builtins.toString conf.height}@" - + "${builtins.toString conf.rate}, " - + "${builtins.toString conf.x}x${builtins.toString conf.y}, " - + "${builtins.toString conf.scale}"; - in - hyprland.monitors - |> builtins.mapAttrs mkMonitor - |> builtins.attrValues; - - workspace = let - mkWorkspace = monitor: workspace: - "${builtins.toString workspace}, " - + "monitor:${builtins.toString monitor}"; - - mkWorkspaces = monitor: workspace-list: - builtins.map (mkWorkspace monitor) workspace-list; - in - hyprland.workspaces - |> builtins.mapAttrs mkWorkspaces - |> builtins.attrValues - |> builtins.concatLists; - - bind = let - mkBind = key: action: "${key}, ${action}"; - mkBinds = key: actions: builtins.map (mkBind key) actions; - in - (hyprland.keybindings.bindings // always-bind) - |> builtins.mapAttrs mkBinds - |> builtins.attrValues - |> builtins.concatLists; - - bindm = let - mkBind = key: action: "${key}, ${action}"; - mkBinds = key: actions: builtins.map (mkBind key) actions; - in + settings = import ./settings.nix { + inherit + lib + config + hyprland + color + always-exec + always-bind always-bindm - |> builtins.mapAttrs mkBinds - |> builtins.attrValues - |> builtins.concatLists; - - exec-once = let - mkDelayedStart = str: ''hyprctl dispatch exec "sleep 5s && ${str}"''; - - mkSpecialSilentStart = w: str: "[workspace special:${w} silent] ${str}"; - mkSpecialSilentStarts = w: strs: builtins.map (mkSpecialSilentStart w) strs; - in - lib.mkMerge [ - always-exec - hyprland.autostart.immediate - (hyprland.autostart.special-silent - |> builtins.mapAttrs mkSpecialSilentStarts - |> builtins.attrValues - |> builtins.concatLists) - (hyprland.autostart.delayed - |> builtins.map mkDelayedStart) - ]; - - windowrule = let - mkWorkspaceRule = workspace: class: - "workspace ${workspace}, " - + "class:^(${class})$"; - mkWorkspaceRules = workspace: class-list: - builtins.map (mkWorkspaceRule workspace) class-list; - - mkFloatingRule = attrs: - "float" - + (lib.optionalString (builtins.hasAttr "class" attrs) ", class:^(${attrs.class})$") - + (lib.optionalString (builtins.hasAttr "title" attrs) ", title:^(${attrs.title})$"); - - mkTranslucentRule = class: - "opacity ${hyprland.transparent-opacity} ${hyprland.transparent-opacity}, " - + "class:^(${class})$"; - in - lib.mkMerge [ - (hyprland.workspacerules - |> builtins.mapAttrs mkWorkspaceRules - |> builtins.attrValues - |> builtins.concatLists) - (hyprland.floating - |> builtins.map mkFloatingRule) - (hyprland.transparent - |> builtins.map mkTranslucentRule) - hyprland.windowrules - ]; - - dwindle = { - pseudotile = true; - preserve_split = true; - }; - - master = { - new_status = "master"; - }; - - gestures = { - workspace_swipe = false; - }; - - misc = { - # Say no to the anime girl - disable_hyprland_logo = true; - force_default_wallpaper = 0; - - # Say no to the "Application not responding" window - enable_anr_dialog = false; - - disable_splash_rendering = true; - font_family = "${color.font}"; - }; - - # Because those are not windows, but layers, - # we have to blur them explicitly - layerrule = [ - "blur,rofi" - "ignorealpha 0.001,rofi" # Fix pixelated corners - "xray 0,rofi" # Render on top of other windows - "dimaround,rofi" - - "blur,waybar" - "blur,gtk4-layer-shell" - "blur,bar-0" - "blur,bar-1" - ]; - - decoration = { - rounding = 4; - - shadow = { - enabled = false; - }; - - blur = { - enabled = true; - size = 10; - passes = 3; - new_optimizations = true; - ignore_opacity = true; - xray = true; - }; - }; - - animations = { - enabled = true; - bezier = "myBezier, 0.05, 0.9, 0.1, 1.05"; - animation = [ - "windows, 1, 7, myBezier" - "windowsOut, 1, 7, default,popin 80%" - "border, 1, 10, default" - "borderangle, 1, 8, default" - "fade, 1, 7, default" - "workspaces, 1, 6, default" - ]; - }; + ; }; }; }; diff --git a/home/modules/hyprland/settings.nix b/home/modules/hyprland/settings.nix new file mode 100644 index 00000000..81732e3e --- /dev/null +++ b/home/modules/hyprland/settings.nix @@ -0,0 +1,208 @@ +{ + lib, + config, + hyprland, + color, + always-exec, + always-bind, + always-bindm, +}: { + "$mainMod" = "${hyprland.keybindings.main-mod}"; + + general = { + gaps_in = 5; + gaps_out = 10; + border_size = 2; + + "col.active_border" = "rgb(${color.hex.accent})"; + "col.inactive_border" = "rgb(${color.hex.base})"; + }; + + group = { + groupbar = { + enabled = true; + render_titles = false; + font_size = 10; + gradients = false; + + "col.active" = "rgb(${color.hex.accent})"; + "col.inactive" = "rgb(${color.hex.base})"; + }; + + "col.border_active" = "rgb(${color.hex.accent})"; + "col.border_inactive" = "rgb(${color.hex.base})"; + }; + + input = { + kb_layout = hyprland.keyboard.layout; + kb_variant = hyprland.keyboard.variant; + kb_options = hyprland.keyboard.option; + kb_model = "pc104"; + kb_rules = ""; + + follow_mouse = true; + + touchpad = { + natural_scroll = "no"; + }; + + sensitivity = 0; # -1.0 - 1.0, 0 means no modification. + }; + + monitor = let + mkMonitor = name: conf: + "${name}, " + + "${builtins.toString conf.width}x${builtins.toString conf.height}@" + + "${builtins.toString conf.rate}, " + + "${builtins.toString conf.x}x${builtins.toString conf.y}, " + + "${builtins.toString conf.scale}"; + in + hyprland.monitors + |> builtins.mapAttrs mkMonitor + |> builtins.attrValues; + + workspace = let + mkWorkspace = monitor: workspace: + "${builtins.toString workspace}, " + + "monitor:${builtins.toString monitor}"; + + mkWorkspaces = monitor: workspace-list: + builtins.map (mkWorkspace monitor) workspace-list; + in + hyprland.workspaces + |> builtins.mapAttrs mkWorkspaces + |> builtins.attrValues + |> builtins.concatLists; + + bind = let + mkBind = key: action: "${key}, ${action}"; + mkBinds = key: actions: builtins.map (mkBind key) actions; + in + (hyprland.keybindings.bindings // always-bind) + |> builtins.mapAttrs mkBinds + |> builtins.attrValues + |> builtins.concatLists; + + bindm = let + mkBind = key: action: "${key}, ${action}"; + mkBinds = key: actions: builtins.map (mkBind key) actions; + in + always-bindm + |> builtins.mapAttrs mkBinds + |> builtins.attrValues + |> builtins.concatLists; + + exec-once = let + mkDelayedStart = str: ''hyprctl dispatch exec "sleep 5s && ${str}"''; + + mkSpecialSilentStart = w: str: "[workspace special:${w} silent] ${str}"; + mkSpecialSilentStarts = w: strs: builtins.map (mkSpecialSilentStart w) strs; + in + lib.mkMerge [ + always-exec + hyprland.autostart.immediate + (hyprland.autostart.special-silent + |> builtins.mapAttrs mkSpecialSilentStarts + |> builtins.attrValues + |> builtins.concatLists) + (hyprland.autostart.delayed + |> builtins.map mkDelayedStart) + ]; + + windowrule = let + mkWorkspaceRule = workspace: class: + "workspace ${workspace}, " + + "class:^(${class})$"; + mkWorkspaceRules = workspace: class-list: + builtins.map (mkWorkspaceRule workspace) class-list; + + mkFloatingRule = attrs: + "float" + + (lib.optionalString (builtins.hasAttr "class" attrs) ", class:^(${attrs.class})$") + + (lib.optionalString (builtins.hasAttr "title" attrs) ", title:^(${attrs.title})$"); + + mkTranslucentRule = class: + "opacity ${hyprland.transparent-opacity} ${hyprland.transparent-opacity}, " + + "class:^(${class})$"; + in + lib.mkMerge [ + (hyprland.workspacerules + |> builtins.mapAttrs mkWorkspaceRules + |> builtins.attrValues + |> builtins.concatLists) + (hyprland.floating + |> builtins.map mkFloatingRule) + (hyprland.transparent + |> builtins.map mkTranslucentRule) + hyprland.windowrules + ]; + + dwindle = { + pseudotile = true; + preserve_split = true; + }; + + master = { + new_status = "master"; + }; + + gestures = { + workspace_swipe = false; + }; + + misc = { + # Say no to the anime girl + disable_hyprland_logo = true; + force_default_wallpaper = 0; + + # Say no to the "Application not responding" window + enable_anr_dialog = false; + + disable_splash_rendering = true; + font_family = "${color.font}"; + }; + + # Because those are not windows, but layers, + # we have to blur them explicitly + layerrule = [ + "blur,rofi" + "ignorealpha 0.001,rofi" # Fix pixelated corners + "xray 0,rofi" # Render on top of other windows + "dimaround,rofi" + + "blur,waybar" + "blur,gtk4-layer-shell" + "blur,bar-0" + "blur,bar-1" + ]; + + decoration = { + rounding = 4; + + shadow = { + enabled = false; + }; + + blur = { + enabled = true; + size = 10; + passes = 3; + new_optimizations = true; + ignore_opacity = true; + xray = true; + }; + }; + + animations = { + enabled = true; + bezier = "myBezier, 0.05, 0.9, 0.1, 1.05"; + animation = [ + "windows, 1, 7, myBezier" + "windowsOut, 1, 7, default,popin 80%" + "border, 1, 10, default" + "borderangle, 1, 8, default" + "fade, 1, 7, default" + "workspaces, 1, 6, default" + ]; + }; +}