dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
commit 5c0af10e564cf926d5df08d87ac3928f9622e30f parent d436a83a2196855eb02cd3d9dcd6b673f2e4bf33 Author: maydayv7 <maydayv7@gmail.com> Date: Fri, 21 Mar 2025 00:42:41 +0530 feat(Hyprland): Use `hyprswitch`
Diffstat:
15 files changed, 208 insertions(+), 126 deletions(-)
diff --git a/files/flake.nix b/files/flake.nix @@ -67,33 +67,27 @@ gtk.bookmarks = readFile ./gtk/bookmarks; # Hyprland WM - hyprland = { - # Keybinds Viewer - kebihelp = readFile ./hyprland/kebihelp.json; + hyprland = + { + # Keybinds Viewer + kebihelp = readFile ./hyprland/kebihelp.json; + + # Clipboard Manager + clipse = map.files { + directory = ./hyprland/clipse; + apply = readFile; + extension = ".json"; + }; - # Clipboard Manager - clipse = map.files { - directory = ./hyprland/clipse; + # Pyprland + pypr = readFile ./hyprland/pypr.toml; + } + // map.files { + directory = ./hyprland/theme; apply = readFile; - extension = ".json"; + extension = ".css"; }; - # Application Drawer - drawer = readFile ./hyprland/drawer.css; - - # Minimize Workspace - minimize = ""; - - # Pyprland - pypr = readFile ./hyprland/pypr.toml; - - # Waybar - waybar = readFile ./hyprland/waybar.css; - - # WLogout - wlogout = readFile ./hyprland/wlogout.css; - }; - # Pictures images.profile = ./images/Profile.png; diff --git a/files/hyprland/kebihelp.json b/files/hyprland/kebihelp.json @@ -143,16 +143,16 @@ "_hidden": false, "keybindings": [ { - "value": "$mod Tab", - "label": "Show workspace overview for current monitor" + "value": "$mod ` (or 4F Swipe Up)", + "label": "Show workspace overview" }, { - "value": "$mod SHIFT Tab", - "label": "Show workspace overview for all monitors" + "value": "ALT [SHIFT] Tab", + "label": "Cycle [backwards] through open windows on current workspace" }, { - "value": "ALT [SHIFT] Tab", - "label": "Cycle [backwards] through open windows" + "value": "$mod [SHIFT] Tab", + "label": "Cycle [backwards] through open windows on all workspaces" }, { "value": "ALT [SHIFT] `", @@ -172,7 +172,7 @@ "label": "Move window to workspace 'NUM' {1 to 9}" }, { - "value": "$mod , or .", + "value": "$mod , or . (or 3F Swipe Left/Right)", "label": "Move to previous/next non-empty workspace" }, { diff --git a/files/hyprland/drawer.css b/files/hyprland/theme/drawer.css diff --git a/files/hyprland/theme/hyprswitch.css b/files/hyprland/theme/hyprswitch.css @@ -0,0 +1,39 @@ +:root { + --bg-color: rgba(0, 0, 0, 0.5); + --bg-color-hover: rgba(255, 255, 255, 0.2); + --border-radius: 10px; + --border-color: #@base04; + --border-color-active: #@base05; +} + +.monitor { + background: var(--bg-color); + border: var(--border-size) solid var(--border-color-active); +} + +.index { + color: #@base01; + background: var(--border-color-active); + border: var(--border-size) solid var(--border-color); +} + +.workspace { + background: var(--bg-color); +} + +.client { + background: transparent; +} + +.client-image { + background: transparent; +} + +.client:hover { + background-color: var(--bg-color-hover); +} + +.client_active { + background: var(--bg-color-hover); + border: var(--border-size) solid var(--border-color-active); +} diff --git a/files/hyprland/waybar.css b/files/hyprland/theme/waybar.css diff --git a/files/hyprland/wlogout.css b/files/hyprland/theme/wlogout.css diff --git a/modules/gui/desktop/hyprland/apps/panel.nix b/modules/gui/desktop/hyprland/apps/panel.nix @@ -66,7 +66,11 @@ in { "hyprland/window" ]; - modules-center = ["wlr/taskbar"]; + modules-center = [ + "wlr/taskbar" + "custom/minimize" + ]; + modules-right = [ "group/menu" "bluetooth" @@ -83,7 +87,6 @@ in { format = ""; tooltip = false; on-click = "nwg-drawer"; - on-click-right = "hyprctl dispatch hycov:toggleoverview"; }; "group/users" = { @@ -109,24 +112,23 @@ in { "hyprland/workspaces" = { all-outputs = true; show-special = true; - format = "<small>{name}</small> {icon}"; + format = "<small>{name}</small>{icon}"; on-scroll-up = "hyprctl dispatch workspace m+1"; on-scroll-down = "hyprctl dispatch workspace m-1"; persistent-workspaces."${config.gui.display}" = 3; - ignore-workspaces = ["special:scratch_.*"]; + ignore-workspaces = ["special:scratch_.*" "special:minimize"]; format-icons = { - default = ""; - special = ""; - "1" = ""; - "2" = ""; - "3" = ""; - "4" = ""; - "5" = ""; - "6" = ""; - "7" = ""; - "8" = ""; - "9" = ""; - OVERVIEW = ""; + default = ""; + special = " "; + "1" = " "; + "2" = " "; + "3" = " "; + "4" = " "; + "5" = " "; + "6" = " "; + "7" = " "; + "8" = " "; + "9" = " "; }; }; @@ -161,6 +163,11 @@ in { }; }; + "custom/minimize" = { + format = ""; + on-click = "hyprutils toggle minimize"; + }; + "group/menu" = { orientation = "horizontal"; modules = ["custom/dropdown" "keyboard-state" "tray"]; diff --git a/modules/gui/desktop/hyprland/apps/settings.nix b/modules/gui/desktop/hyprland/apps/settings.nix @@ -6,7 +6,11 @@ files, theme, ... -}: { +}: let + inherit (lib) flatten; + inherit (builtins) map toFile; + inherit (util) build; +in { ## App Environment xdg.portal.extraPortals = [pkgs.xdg-desktop-portal-gtk]; @@ -44,34 +48,15 @@ "SLURP_ARGS, -dc ${config.lib.stylix.colors.base0D}" ]; - ## Shortcuts - bind = let - toggle = app: "pkill ${app} || uwsm app -u ${app}.scope -- ${app}"; - runOnce = app: "pgrep ${app} || uwsm app -u ${app}.scope -- ${app}"; - in [ - "$mod SHIFT, slash, exec, ${toggle "kebihelp"} show -a" - "$mod, slash, exec, ulauncher-toggle" - "$mod, A, exec, nwg-drawer" - "$mod SHIFT, A, exec, hyprutils toggle service waybar" - "$mod SHIFT, C, exec, ${runOnce "hyprpicker"} -arf hex" - "$mod, D, exec, pypr toggle displays" - "$mod, F, exec, nemo" - "$mod, N, exec, dunstctl history-pop" - "$mod, T, exec, kitty" - "$mod SHIFT, T, exec, pypr toggle term" - "$mod, V, exec, pypr show clip" - "$mod, W, exec, firefox" - "$mod, Return, exec, ${runOnce "resources"}" - ", XF86Calculator, exec, qalculate-gtk" - "$mod, Escape, exec, ${toggle "wlogout"} -p layer-shell" - ]; - ## Autostart exec-once = ["uwsm finalize"] - ++ (builtins.map (app: "uwsm app -t service -u ${util.build.until " " app}.service -- " + app) [ + ++ (map (app: "uwsm app -t service -u ${build.until " " app}.service -- " + app) [ "hyprutils daemon" + # Pyprland + "pypr" + # Application Drawer "nwg-drawer -r" @@ -81,19 +66,55 @@ # Desktop Icons "dicons" - # Pyprland - "pypr" + # Window Switcher + "hyprswitch init --workspaces-per-row 3 --custom-css ${toFile "style.css" (build.theme { + inherit (config.lib.stylix) colors; + file = files.hyprland.hyprswitch; + })} &" ]); + ## Shortcuts + bind = let + toggle = app: "pkill ${app} || uwsm app -u ${app}.scope -- ${app}"; + runOnce = app: "pgrep ${app} || uwsm app -u ${app}.scope -- ${app}"; + in [ + # Applications + "$mod, F, exec, nemo" + "$mod, T, exec, kitty" + "$mod, W, exec, firefox" + "$mod, Return, exec, ${runOnce "resources"}" + ", XF86Calculator, exec, qalculate-gtk" + + # Utilities + "$mod, A, exec, nwg-drawer" + "$mod, slash, exec, ulauncher-toggle" + "$mod SHIFT, slash, exec, ${toggle "kebihelp"} show -a" + "$mod SHIFT, C, exec, ${runOnce "hyprpicker"} -arf hex" + "$mod, D, exec, pypr toggle displays" + "$mod, Escape, exec, ${toggle "wlogout"} -p layer-shell" + + # Tools + "$mod SHIFT, A, exec, hyprutils toggle service waybar" + "$mod, N, exec, dunstctl history-pop" + "$mod SHIFT, T, exec, pypr toggle term" + "$mod, V, exec, pypr show clip" + + # Switcher + "ALT, Tab, exec, hyprswitch simple -w -m" + "ALT SHIFT, Tab, exec, hyprswitch simple -w -m -r" + "$mod, Tab, exec, hyprswitch gui --mod-key super --key tab --close mod-key-release --reverse-key=mod=shift --max-switch-offset 9 -m && hyprswitch dispatch" + ]; + ## Layer Rules layerrule = [ + "blur, ^(hyprswitch)$" "blur, ^(logout_dialog)$" "blur, ^(nwg-drawer)$" "blur, ^(waybar)$" ]; ## Window Rules - windowrulev2 = lib.flatten ([ + windowrulev2 = flatten ([ "pin, class:^(gnome-control-center)$" # Clipboard Manager @@ -126,7 +147,7 @@ "float, class:^(xdg-desktop-portal-gtk)" "dimaround, class:^(xdg-desktop-portal-gtk)" ] - ++ (builtins.map (class: [ + ++ (map (class: [ "pin, class:^(${class})" "dimaround, class:^(${class})" "stayfocused, class:^(${class})" @@ -135,7 +156,7 @@ "gay.vaskel.Soteria" "gcr-prompter" ]) - ++ (builtins.map (title: [ + ++ (map (title: [ # Dialogs "float, title:^(${title})(.*)$" ]) [ diff --git a/modules/gui/desktop/hyprland/apps/utilities.nix b/modules/gui/desktop/hyprland/apps/utilities.nix @@ -17,6 +17,7 @@ in { gnome-clocks gnome-disk-utility hyprpicker + custom.hyprswitch nwg-displays nwg-drawer overskride diff --git a/modules/gui/desktop/hyprland/settings/keybindings.nix b/modules/gui/desktop/hyprland/settings/keybindings.nix @@ -1,8 +1,4 @@ -{ - sys, - files, - ... -}: { +{sys, ...}: { ## Compositor Binds ## wayland.windowManager.hyprland = { ## Keybindings @@ -12,6 +8,7 @@ [ # Compositor Commands "ALT, F4, killactive," + "$mod, Q, killactive," "$mod SHIFT, Q, forcekillactive," "$mod, P, pin" "$mod, E, fullscreen, 1" @@ -27,12 +24,6 @@ "ALT, A, focusurgentorlast" "ALT, A, alterzorder, top" - # Window Switcher - "ALT, Tab, cyclenext," - "ALT, Tab, bringactivetotop," - "ALT SHIFT, Tab, cyclenext, prev" - "ALT SHIFT, Tab, bringactivetotop," - # Window Swap "$mod SHIFT, left, swapwindow, l" "$mod SHIFT, right, swapwindow, r" @@ -50,7 +41,7 @@ "$mod, C, centerwindow" # Window Minimization - "ALT, Q, movetoworkspacesilent, special:${files.hyprland.minimize}" + "ALT, Q, movetoworkspacesilent, special:minimize" "ALT SHIFT, Q, exec, hyprutils toggle minimize" # Cycle Workspaces @@ -58,8 +49,8 @@ "$mod, period, split:workspace, m+1" # Special Workspace - "$mod, 0, togglespecialworkspace, " - "$mod SHIFT, 0, exec, pypr toggle_special " + "$mod, 0, togglespecialworkspace, Stash" + "$mod SHIFT, 0, exec, pypr toggle_special Stash" # Move Window to Workspace "$mod SHIFT, comma, split:movetoworkspace, r-1" @@ -183,7 +174,7 @@ bind = , Return, submap, reset bind = , mouse:272, movetoworkspace, +0 bind = , mouse:272, submap, reset - bind = , escape, togglespecialworkspace, ${files.hyprland.minimize} + bind = , escape, togglespecialworkspace, minimize bind = , escape, submap, reset submap = reset ''; diff --git a/modules/gui/desktop/hyprland/settings/plugins.nix b/modules/gui/desktop/hyprland/settings/plugins.nix @@ -7,43 +7,31 @@ ## Plugin Settings wayland.windowManager.hyprland = { plugins = with pkgs.hyprworld; [ + hyprexpo Hypr-DarkWindow hyprsplit - hyprtasking ]; settings = { - plugin = let - inherit (config.wayland.windowManager.hyprland.settings) general; - in { - # Overview - hyprtasking = { - layout = "grid"; - inherit (general) border_size; - gap_size = general.gaps_in; - exit_behavior = "interacted"; - bg_color = "0x${sys.lib.stylix.colors.base00-hex}"; - gestures = { - enabled = true; - open_fingers = 3; - open_positive = true; - }; + plugin = { + # Workspaces per Monitor + hyprsplit.num_workspaces = 9; - grid = { - rows = 3; - cols = 3; - }; + # Workspace Overview + hyprexpo = { + columns = 3; + workspace_method = "first 1"; + enable_gesture = true; + gesture_positive = false; + gesture_fingers = 4; + bg_col = "rgb(${sys.lib.stylix.colors.base00})"; + gap_size = config.wayland.windowManager.hyprland.settings.general.gaps_in; }; - - # Split Monitor Workspaces - hyprsplit.num_workspaces = 9; }; bind = [ # Overview - "$mod, Tab, hyprtasking:toggle, cursor" - "$mod SHIFT, Tab, hyprtasking:toggle, all" - "$mod, Q, hyprtasking:killhovered" + "$mod, grave, hyprexpo:expo, toggle" # Compositor Shaders "$mod, S, exec, hyprutils toggle shader" diff --git a/packages/hyprswitch/default.nix b/packages/hyprswitch/default.nix @@ -0,0 +1,35 @@ +{ + lib, + pkgs, + ... +}: +with pkgs; let + metadata = import ./metadata.nix; +in + rustPlatform.buildRustPackage rec { + pname = "hyprswitch"; + version = metadata.rev; + + src = fetchFromGitHub { + owner = "H3rmt"; + repo = pname; + inherit (metadata) rev sha256; + }; + + useFetchCargoVendor = true; + inherit (metadata) cargoHash; + buildInputs = [gtk4-layer-shell]; + nativeBuildInputs = [ + wrapGAppsHook4 + pkg-config + ]; + + meta = with lib; { + mainProgram = "hyprswitch"; + description = "CLI/GUI that allows switching between windows in Hyprland"; + homepage = metadata.repo; + license = licenses.mit; + platforms = platforms.linux; + maintainers = ["maydayv7"]; + }; + } diff --git a/packages/hyprswitch/metadata.nix b/packages/hyprswitch/metadata.nix @@ -0,0 +1,7 @@ +{ + repo = "https://github.com/H3rmt/hyprswitch"; + release = true; + rev = "v3.3.2"; + sha256 = "sha256-cmo544QvdacVTHPqmc6er4xnSSc63e6Z71BS0FxSklE="; + cargoHash = "sha256-DEifup2oAcqZplx2JoN3hkP1VmxwYVFS8ZqfpR80baA="; +} diff --git a/scripts/hyprutils.nix b/scripts/hyprutils.nix @@ -27,11 +27,10 @@ touchpad - Toggle touchpad ''; - minimize = "special:${files.hyprland.minimize}"; daemon = builtins.toFile "daemon.sh" '' event_activespecial() { case "$WORKSPACENAME" in - ${minimize}*) + special:minimize*) hyprctl dispatch submap reset hyprctl dispatch submap Minimize ;; @@ -270,9 +269,9 @@ in hyprctl dispatch workspaceopt allfloat ;; "minimize") - if hyprctl workspaces | grep "${minimize}" + if hyprctl workspaces | grep "special:minimize" then - hyprctl dispatch workspace ${minimize} + hyprctl dispatch workspace special:minimize else hyprctl notify 1 2000 0 "No minimized windows present" fi diff --git a/scripts/packages.sh b/scripts/packages.sh @@ -28,12 +28,12 @@ update() { rev="$(cat "${t1}" | jq -r .rev)" sha256="$(cat "${t1}" | jq -r .sha256)" repo="$(cat "${t1}" | jq -r .repo)" - branch="$(cat "${t1}" | jq -r .branch)" # Optional - release="$(cat "${t1}" | jq -r .release)" # Optional - cargoHash="$(cat "${t1}" | jq -r .cargoHash)" # Optional - vendorHash="$(cat "${t1}" | jq -r .vendorHash)" # Optional - skip="$(cat "${t1}" | jq -r .skip)" # Optional - upattr="$(cat "${t1}" | jq -r .upattr)"; # Optional + branch="$(cat "${t1}" | jq -r .branch)" # Optional + release="$(cat "${t1}" | jq -r .release)" # Optional + cargoHash="$(cat "${t1}" | jq -r .cargoHash)" # Optional + vendorHash="$(cat "${t1}" | jq -r .vendorHash)" # Optional + skip="$(cat "${t1}" | jq -r .skip)" # Optional + upattr="$(cat "${t1}" | jq -r .upattr)"; # Optional if [[ "${upattr}" == "null" ]] then upattr="${pkgname}"