From 57095fae317f06ec831d501c6d59309020dd5af0 Mon Sep 17 00:00:00 2001 From: alisceon Date: Tue, 2 Dec 2025 19:21:57 +0100 Subject: [PATCH] serious sway rice --- flake.lock | 12 +- flake.nix | 4 +- home/alisceon/workstation.nix | 12 +- home/conf/xonsh/xonshrc | 1 + home/wm/sway.nix | 203 ++++++++++++++++++++++------------ hosts/common/wm/sway.nix | 67 +++++++++-- 6 files changed, 208 insertions(+), 91 deletions(-) diff --git a/flake.lock b/flake.lock index 915dea8..6ab85eb 100644 --- a/flake.lock +++ b/flake.lock @@ -121,11 +121,11 @@ ] }, "locked": { - "lastModified": 1764623636, - "narHash": "sha256-uc4SR3NN4gfAVQrBS92TJVpUzWVchHxYvilI8lPATTo=", + "lastModified": 1764683664, + "narHash": "sha256-Mr5HKf/bjAJ8H7/H0qJSk2BEV/OILkDIFKrGK0dUVUk=", "owner": "nix-community", "repo": "NUR", - "rev": "1a35828a7f9a877bba61a701a8b947404fefb568", + "rev": "b8b40e258cf4c959b06b7322648c87674633629b", "type": "github" }, "original": { @@ -142,11 +142,11 @@ ] }, "locked": { - "lastModified": 1764623636, - "narHash": "sha256-uc4SR3NN4gfAVQrBS92TJVpUzWVchHxYvilI8lPATTo=", + "lastModified": 1764683664, + "narHash": "sha256-Mr5HKf/bjAJ8H7/H0qJSk2BEV/OILkDIFKrGK0dUVUk=", "owner": "nix-community", "repo": "NUR", - "rev": "1a35828a7f9a877bba61a701a8b947404fefb568", + "rev": "b8b40e258cf4c959b06b7322648c87674633629b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 0d77c17..25e07fc 100644 --- a/flake.nix +++ b/flake.nix @@ -81,13 +81,13 @@ modules = sharedModules ++ [ ./hosts/common/workstation.nix ./hosts/tower/configuration.nix - ./hosts/common/wm/gnome.nix + ./hosts/common/wm/sway.nix home-manager.nixosModules.home-manager ({ config, ...}: { home-manager.users.alisceon.imports = [ ./home/alisceon/base.nix ./home/alisceon/workstation.nix - ./home/wm/gnome.nix + ./home/wm/sway.nix ]; }) # end home-manager ]; # end modules diff --git a/home/alisceon/workstation.nix b/home/alisceon/workstation.nix index 78b5b1a..4113fed 100644 --- a/home/alisceon/workstation.nix +++ b/home/alisceon/workstation.nix @@ -1,4 +1,10 @@ { pkgs, config, hostName, lib, ... }: { + + home.packages = with pkgs; [ + signal-desktop + discord + ]; + programs = { vscode.enable = true; firefox = { @@ -31,14 +37,10 @@ "${pkgs.discord}/share/applications/discord.desktop" "${pkgs.signal-desktop}/share/applications/signal.desktop" "${pkgs.obsidian}/share/applications/obsidian.desktop" + "${pkgs.vscode}/share/applications/code.desktop" ]; }; # end xdg.autostart - home.packages = with pkgs; [ - signal-desktop - discord - ]; - xdg = { enable = true; userDirs.enable = true; diff --git a/home/conf/xonsh/xonshrc b/home/conf/xonsh/xonshrc index 9eebac2..ea53e8f 100644 --- a/home/conf/xonsh/xonshrc +++ b/home/conf/xonsh/xonshrc @@ -33,6 +33,7 @@ XSH.env['fzf_dir_binding'] = "c-g" # Ctrl+G aliases["tsla-fan"] = "ipmitool -H 10.30.0.3 -U ADMIN -P ADMIN raw 0x30 0x70 0x66 0x01 0x0" aliases["nixoss"] = "sudo nixos-rebuild switch --flake .#${config.networking.hostName}" aliases["nixost"] = "sudo nixos-rebuild test --flake .#${config.networking.hostName}" +aliases["nixosb"] = "sudo nixos-rebuild build --flake .#${config.networking.hostName}" aliases["nixosdb"] = "sudo nixos-rebuild dry-build --flake .#${config.networking.hostName}" aliases["devt"] = "devenv test" aliases["devtas"] = "devenv tasks list" diff --git a/home/wm/sway.nix b/home/wm/sway.nix index 9b0e944..89abf94 100644 --- a/home/wm/sway.nix +++ b/home/wm/sway.nix @@ -72,20 +72,111 @@ # other display = status: "swaymsg 'output * power ${status}'"; + hostnameOutput = + if hostName == "tower" then { + # Left monitor + DP-1 = { + mode = "1920x1080@143.981Hz"; + transform = "90"; + position = "0 0"; + }; + # Main monitor + DP-2 = { + mode = "3440x1440@99.982Hz"; + position = "1080 250"; + }; + # Right monitor + DP-3 = { + mode = "1920x1080@143.981Hz"; + position = "4520 250"; + }; + } + else if hostName == "electra" then {} + else {}; + hostnameWorkspaceAssign = + if hostName == "tower" then [ + { output = "DP-2"; workspace = "1"; } + { output = "DP-3"; workspace = "2"; } + { output = "DP-1"; workspace = "3"; } + { output = "DP-2"; workspace = "4"; } + { output = "DP-3"; workspace = "5"; } + { output = "DP-1"; workspace = "6"; } + { output = "DP-2"; workspace = "7"; } + { output = "DP-3"; workspace = "8"; } + { output = "DP-1"; workspace = "9"; } + ] + else if hostName == "electra" then [] + else []; + hostnameServices = + if hostName == "tower" then {} + else if hostName == "electra" then { + swayidle = { + enable = true; + timeouts = [ + { + timeout = 120; + command = "${pkgs.libnotify}/bin/notify-send 'Locking in 5 seconds' -t 5000"; + } + { + timeout = 125; + command = lock; + } + { + timeout = 125; + command = display "off"; + resumeCommand = display "on"; + } + { + timeout = 600; + command = "${pkgs.systemd}/bin/systemctl suspend"; + } + ]; # end timeouts + events = [ + { + event = "before-sleep"; + command = "display off; systemctl --user stop libinput-gestures" + lock; + } + { + event = "after-resume"; + command = "display on; systemctl --user start libinput-gestures"; + } + { + event = "lock"; + command = (display "off") + "; " + lock; + } + { + event = "unlock"; + command = display "on"; + } + ]; # end events + }; # end swayidle + } + else {}; in { wayland.windowManager.sway = { enable = true; wrapperFeatures.gtk = true; # Fixes common issues with GTK 3 apps + systemd = { + xdgAutostart = true; + variables = [ + "--all" + ]; + }; + extraSessionCommands = '' + export XDG_CURRENT_DESKTOP=GNOME:sway + ''; config = { modifier = "${key_mod}"; startup = [ - { command = "systemctl --user start libinput-gestures"; always = true; } - { command = "dbus-update-activation-environment --systemd --all"; always = true; } + { command = "systemctl --user start libinput-gestures"; } + #{ command = "firefox";} + #{ command = "discord";} + + ]; + bars = [ + { command = "${pkgs.waybar}/bin/waybar"; } ]; - bars = [{ - command = "${pkgs.waybar}/bin/waybar"; - }]; fonts = { names = ["${style_font}"]; size = style_font_sz; @@ -112,15 +203,6 @@ "${key_mod}+d" = "exec ${dmenu}"; "${key_mod}+Shift+q" = "kill"; "${key_mod}+L" = "exec ${lock}"; - #Screenshot region - "${key_mod}+Shift+s" = '' - bash -c '\ - ${pkgs.slurp}/bin/slurp | \ - ${pkgs.grim}/bin/grim -g - \ - ~/Pictures/Screenshots_${hostName}/$(date +"%Y-%m-%d-%H%M%S.png") | \ - ${pkgs.wl-clipboard}/bin/wl-copy -t image/png \ - ' - ''; # Workspaces "${key_mod}+f" = "fullscreen"; "${key_mod}+space" = "floating toggle"; @@ -175,6 +257,9 @@ "${key_mod}+Shift+${key_right}" = "move right"; # System + #Screenshot region + "${key_mod}+Shift+s" = "exec grimshot savecopy area"; + "Print" = "exec grimshot savecopy output"; "XF86AudioRaiseVolume" = "exec 'pactl set-sink-volume @DEFAULT_SINK@ +3%'"; "XF86AudioLowerVolume" = "exec 'pactl set-sink-volume @DEFAULT_SINK@ -3%'"; "XF86AudioMute" = "exec 'pactl set-sink-mute @DEFAULT_SINK@ toggle'"; @@ -222,49 +307,17 @@ childBorder = color_dark_3; }; }; # end colors + assigns = { + "1" = [{app_id = "firefox";}]; + "2" = [{class = "Code";}]; + "3" = [{class = "discord";}]; + + }; + output = {} // hostnameOutput; + workspaceOutputAssign = hostnameWorkspaceAssign; }; }; services = { - swayidle = { - enable = true; - timeouts = [ - { - timeout = 120; - command = "${pkgs.libnotify}/bin/notify-send 'Locking in 5 seconds' -t 5000"; - } - { - timeout = 125; - command = lock; - } - { - timeout = 125; - command = display "off"; - resumeCommand = display "on"; - } - { - timeout = 600; - command = "${pkgs.systemd}/bin/systemctl suspend"; - } - ]; # end timeouts - events = [ - { - event = "before-sleep"; - command = "display off; systemctl --user stop libinput-gestures" + lock; - } - { - event = "after-resume"; - command = "display on; systemctl --user start libinput-gestures"; - } - { - event = "lock"; - command = (display "off") + "; " + lock; - } - { - event = "unlock"; - command = display "on"; - } - ]; # end events - }; # end swayidle mako = { enable = true; settings = { @@ -287,7 +340,15 @@ markup = true; }; #end settings }; # end mako - }; # end services + gnome-keyring = { + enable = true; + components = [ + "ssh" + "pkcs11" + "secrets" + ]; + }; + } // hostnameServices; # end services programs = { rofi = { enable = true; @@ -374,16 +435,16 @@ spacing = 0; modules-left = [ "sway/workspaces" - "sway/window" ]; modules-center = [ - "clock" + "sway/window" ]; modules-right = [ + "tray" "network" "pulseaudio" "battery" - "tray" + "clock" ]; "sway/workspaces" = { on-click = "activate"; @@ -399,9 +460,9 @@ }; "clock" = { interval = 60; - tooltip = false; - format = "{:%R}"; - format-alt = "{:%a, %Y-%m-%d}"; + tooltip = true; + format = "| {:%Y-%m-%d %R} "; + tooltip-format = "{:%A}"; }; "battery" = { states = { @@ -412,23 +473,23 @@ over = 101; }; interval = 30; - format = "Bat {capacity}%"; - format-charging = "Bat {capacity}%"; - format-plugged = "Bat {capacity}%"; + format = "| Bat {capacity}% "; + format-charging = "| Chr {capacity}% "; + format-plugged = "| Plg {capacity}% "; }; "network" = { - format-wifi = "WiFi up"; - format-ethernet = "eth up"; + format-wifi = "| WiFi up "; + format-ethernet = ""; tooltip-format = "{ifname} = {ipaddr}/{cidr}"; - format-linked = "{ifname} (no ip)"; - format-disconnected = "No network"; - format-alt = "{essid}: {ipaddr}"; + format-linked = "| {ifname} (no ip) "; + format-disconnected = "| Disconnected "; + format-alt = "| {essid}: {ipaddr} "; interval = 10; }; "pulseaudio" = { # "scroll-step" = 1; # %; can be a float - format = "Sound: {volume}%"; - format-muted = "Sound Muted"; + format = "| Sound: {volume}% "; + format-muted = "| Sound: x% "; }; }; # end mainbar }; # end settings diff --git a/hosts/common/wm/sway.nix b/hosts/common/wm/sway.nix index 5516b44..34713e0 100644 --- a/hosts/common/wm/sway.nix +++ b/hosts/common/wm/sway.nix @@ -1,26 +1,57 @@ { config, pkgs, lib, ... }: { environment.systemPackages = with pkgs; [ - grim # screenshot functionality - slurp # screenshot functionality - wl-clipboard # wl-copy and wl-paste for copy/paste from stdin / stdout mako # notification system developed by swaywm maintainer rofi libinput libinput-gestures wmctrl + seahorse + libsecret + pkgs.xdg-desktop-portal-gtk ]; + environment.sessionVariables = rec { + XDG_CURRENT_DESKTOP = "GNOME:sway"; + }; + # enable Sway window manager programs = { sway = { enable = true; + wrapperFeatures.base = true; wrapperFeatures.gtk = true; + extraOptions = [ + "--unsupported-gpu" + ]; + extraPackages = with pkgs; [ + swayidle + swaylock + grim + slurp + wl-clipboard + brightnessctl + pulseaudio + sway-contrib.grimshot + ]; }; # end sway + # uwsm = { + # enable = true; + # waylandCompositors = { + # sway = { + # prettyName = "Sway"; + # comment = "Sway compositor managed by UWSM"; + # binPath = "${pkgs.sway}/bin/sway"; + # extraArgs = [ "--unsupported-gpu" ]; + # }; + # }; + # }; # end uwsm light = { enable = true; }; # end light + dconf.enable = true; + seahorse.enable = true; }; # end programs security = { polkit.enable = true; @@ -35,16 +66,38 @@ enable = true; settings = { default_session = { - command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd sway"; + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd 'sway --unsupported-gpu'"; + #command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd 'uwsm start -- sway-uwsm.desktop'"; user = "greeter"; }; # end default_session }; # end settings }; # end greetd logind = { - lidSwitch = "suspend"; - lidSwitchExternalPower = "suspend"; + settings = { + Login = { + HandleLidSwitch = "suspend"; + HandleLidSwitchExternalPower = "suspend"; + }; + }; }; # end logind - gnome.gnome-keyring.enable = true; + #gnome = { + #gnome-keyring.enable = true; + #gcr-ssh-agent.enable = true; + #}; # end gnome + dbus.packages = [ pkgs.seahorse pkgs.gnome-keyring pkgs.gcr ]; }; # end services users.users.alisceon.extraGroups = [ "video" "input" ]; + # xdg.portal = { + # enable = true; + # wlr.enable = true; + # extraPortals = [ + # pkgs.xdg-desktop-portal-gtk + # ]; + # config = { + # common = { + # default = [ "gtk" ]; + # "org.freedesktop.impl.portal.Secret" = [ "gnome-keyring" ]; + # }; + # }; + # }; } \ No newline at end of file