382 lines
		
	
	
	
		
			13 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			382 lines
		
	
	
	
		
			13 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
 | 
						|
{ config, lib, pkgs, niri, ... }:
 | 
						|
 | 
						|
let
 | 
						|
  laptop = builtins.readFile "/etc/hostname" == "syl\n";
 | 
						|
  cosmic-extra-niri = pkgs.writeShellScriptBin "cosmic-extra-niri" ''
 | 
						|
set -e
 | 
						|
 | 
						|
# From: https://people.debian.org/~mpitt/systemd.conf-2016-graphical-session.pdf
 | 
						|
 | 
						|
if command -v systemctl >/dev/null; then
 | 
						|
    # robustness: if the previous graphical session left some failed units,
 | 
						|
    # reset them so that they don't break this startup
 | 
						|
    for unit in $(systemctl --user --no-legend --state=failed --plain list-units | cut -f1 -d' '); do
 | 
						|
        partof="$(systemctl --user show -p PartOf --value "$unit")"
 | 
						|
        for target in cosmic-session.target graphical-session.target; do
 | 
						|
            if [ "$partof" = "$target" ]; then
 | 
						|
                systemctl --user reset-failed "$unit"
 | 
						|
                break
 | 
						|
            fi
 | 
						|
        done
 | 
						|
    done
 | 
						|
fi
 | 
						|
 | 
						|
# use the user's preferred shell to acquire environment variables
 | 
						|
# see: https://github.com/pop-os/cosmic-session/issues/23
 | 
						|
if [ -n "''${SHELL}" ]; then
 | 
						|
    # --in-login-shell: our flag to indicate that we don't need to recurse any further
 | 
						|
    if [ "''${1}" != "--in-login-shell" ]; then
 | 
						|
        # `exec -l`: like `login`, prefixes $SHELL with a hyphen to start a login shell
 | 
						|
        exec bash -c "''${0} --in-login-shell"
 | 
						|
    fi
 | 
						|
fi
 | 
						|
 | 
						|
export XDG_CURRENT_DESKTOP="''${XDG_CURRENT_DESKTOP:=niri}"
 | 
						|
export XDG_SESSION_TYPE="''${XDG_SESSION_TYPE:=wayland}"
 | 
						|
export XCURSOR_THEME="''${XCURSOR_THEME:=Cosmic}"
 | 
						|
export _JAVA_AWT_WM_NONREPARENTING=1
 | 
						|
export GDK_BACKEND=wayland,x11
 | 
						|
export MOZ_ENABLE_WAYLAND=1
 | 
						|
export QT_QPA_PLATFORM="wayland;xcb"
 | 
						|
export QT_AUTO_SCREEN_SCALE_FACTOR=1
 | 
						|
export QT_ENABLE_HIGHDPI_SCALING=1
 | 
						|
 | 
						|
if command -v systemctl >/dev/null; then
 | 
						|
    # set environment variables for new units started by user service manager
 | 
						|
    systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP
 | 
						|
fi
 | 
						|
# Run cosmic-session
 | 
						|
if [[ -z "''${DBUS_SESSION_BUS_ADDRESS}" ]]; then
 | 
						|
    exec dbus-run-session -- ${pkgs.cosmic-session}/bin/cosmic-session niri
 | 
						|
else
 | 
						|
    exec ${pkgs.cosmic-session}/bin/cosmic-session niri
 | 
						|
fi
 | 
						|
  '';
 | 
						|
in
 | 
						|
{
 | 
						|
  home.packages = with pkgs; [
 | 
						|
    cosmic-extra-niri
 | 
						|
  ];
 | 
						|
  xdg.desktopEntries = {
 | 
						|
    cosmic-settings = {
 | 
						|
      name = "Cosmic Settings";
 | 
						|
      genericName = "Cosmic Settings App";
 | 
						|
      exec = "${pkgs.cosmic-settings}/bin/cosmic-settings";
 | 
						|
      terminal = false;
 | 
						|
      type = "Application";
 | 
						|
      categories = [ "Application" "Settings" "COSMIC" ];
 | 
						|
      icon = "com.system76.CosmicSettings";
 | 
						|
    };
 | 
						|
    cosmic-settings-power = {
 | 
						|
      name = "Cosmic Power Settings";
 | 
						|
      genericName = "Cosmic Power Settings App";
 | 
						|
      exec = "${pkgs.cosmic-settings}/bin/cosmic-settings power";
 | 
						|
      terminal = false;
 | 
						|
      type = "Application";
 | 
						|
      categories = [ "Application" "Settings" "COSMIC" ];
 | 
						|
      icon = "preferences-power-and-battery";
 | 
						|
    };
 | 
						|
    cosmic-settings-about = {
 | 
						|
      name = "Cosmic About Settings";
 | 
						|
      genericName = "Cosmic About Settings App";
 | 
						|
      exec = "${pkgs.cosmic-settings}/bin/cosmic-settings about";
 | 
						|
      terminal = false;
 | 
						|
      type = "Application";
 | 
						|
      categories = [ "Application" "Settings" "COSMIC" ];
 | 
						|
      icon = "preferences-about";
 | 
						|
    };
 | 
						|
  };
 | 
						|
  programs.niri = {
 | 
						|
    # enable = true;
 | 
						|
    settings = {
 | 
						|
      prefer-no-csd = true;
 | 
						|
      binds = with config.lib.niri.actions; let
 | 
						|
        sh = spawn "sh" "-c";
 | 
						|
      in {
 | 
						|
        "XF86AudioRaiseVolume".action.spawn = ["pamixer" "--allow-boost" "-i" "5"];
 | 
						|
        "XF86AudioLowerVolume".action.spawn = ["pamixer" "--allow-boost" "-d" "5"];
 | 
						|
        "Super+E".action = spawn ["${pkgs.nushell}/bin/nu" "/home/chris/bin/niriemacslof"];
 | 
						|
        "Super+Return".action.spawn = "alacritty";
 | 
						|
        "Super+B".action = spawn ["${pkgs.nushell}/bin/nu" "/home/chris/bin/nirilof" "org.qutebrowser.qutebrowser" "qutebrowser"];
 | 
						|
        "Super+Alt+Space".action.spawn = "${pkgs.cosmic-launcher}/bin/cosmic-launcher";
 | 
						|
        "Super+Space".action.spawn = ["${pkgs.fish}/bin/fish" "-c" "rofi -no-lazy-grab -modi combi -show combi -combi-modi drun,run"];
 | 
						|
        "Super+Shift+W".action.spawn = "rofi -i -show window";
 | 
						|
        "Super+V".action = spawn ["${pkgs.fish}/bin/fish" "-c" "${pkgs.cliphist}/bin/cliphist list | ${pkgs.rofi}/bin/rofi -p ' ' -dmenu | ${pkgs.cliphist}/bin/cliphist decode | ${pkgs.wl-clipboard}/bin/wl-copy"];
 | 
						|
        "Super+I".action.spawn = ["alacritty" "--class" "btm" "-e" "btop"];
 | 
						|
        "Super+Alt+B".action.spawn = ["alacritty" "--class" "bluetui" "-e" "bluetui"];
 | 
						|
        "Super+Alt+W".action.spawn = ["alacritty" "--class" "impala" "-e" "impala"];
 | 
						|
        "Super+A".action.spawn = ["alacritty" "--class" "pulsemixer" "-e" "${pkgs.wiremix}/bin/wiremix"];
 | 
						|
        "Super+Shift+F".action.spawn = ["cosmic-files"];
 | 
						|
        "Super+Shift+Q".action = quit;
 | 
						|
        "Super+O".action = toggle-overview;
 | 
						|
        "Super+F".action = fullscreen-window;
 | 
						|
        "Super+Alt+F".action = toggle-windowed-fullscreen;
 | 
						|
        "Super+C".action = close-window;
 | 
						|
        "Super+Shift+C".action = center-window;
 | 
						|
        "Super+Shift+O".action = toggle-window-floating;
 | 
						|
        "Super+P".action.spawn = "/home/chris/bin/rbw.sh";
 | 
						|
        "Super+Up".action = focus-window-or-monitor-up;
 | 
						|
        "Super+K".action = focus-window-or-monitor-up;
 | 
						|
        "Super+Down".action = focus-window-or-monitor-down;
 | 
						|
        "Super+J".action = focus-window-or-monitor-down;
 | 
						|
        "Super+Left".action = focus-column-or-monitor-left;
 | 
						|
        "Super+H".action = focus-column-or-monitor-left;
 | 
						|
        "Super+Shift+H".action = move-column-left;
 | 
						|
        "Super+Right".action = focus-column-or-monitor-right;
 | 
						|
        "Super+L".action = focus-column-or-monitor-right;
 | 
						|
        "Super+Shift+L".action = move-column-right;
 | 
						|
        "Super+Ctrl+L".action = set-column-width "+10%";
 | 
						|
        "Super+Ctrl+H".action = set-column-width "-10%";
 | 
						|
        "Super+M".action = maximize-column;
 | 
						|
        "Super+W".action = switch-preset-column-width;
 | 
						|
        "Super+Comma".action = consume-or-expel-window-left;
 | 
						|
        "Super+Period".action = consume-or-expel-window-right;
 | 
						|
        "Super+Alt+L".action = focus-monitor-right;
 | 
						|
        "Super+Alt+H".action = focus-monitor-left;
 | 
						|
        "Super+Shift+P".action = screenshot;
 | 
						|
      };
 | 
						|
      spawn-at-startup = [
 | 
						|
        { argv = ["waybar"]; }
 | 
						|
        { argv = ["hyprpaper"]; }
 | 
						|
        { argv = ["${pkgs.xwayland-satellite}/bin/xwayland-satellite"]; }
 | 
						|
        { argv = ["/usr/lib/kdeconnectd"]; }
 | 
						|
        { argv = ["cosmic-osd"]; }
 | 
						|
        { argv = ["cosmic-idle"]; }
 | 
						|
        { argv = ["cosmic-settings-daemon"]; }
 | 
						|
        { argv = ["kwalletd6"]; }
 | 
						|
        { argv = ["swww-daemon"]; }
 | 
						|
        { argv = ["dbus-update-activation-environment --systemd --all"]; }
 | 
						|
        { argv = ["systemctl --user start jellyfin-mpv-shim"]; }
 | 
						|
        { argv = ["systemctl --user start nextcloud-client"]; }
 | 
						|
        { argv = ["systemctl --user start syncthingtray"]; }
 | 
						|
        { argv = ["rbw-agent"]; }
 | 
						|
        { argv = ["kdeconnect-indicator"]; }
 | 
						|
        { argv = ["wl-paste --watch cliphist store"]; }
 | 
						|
        { argv = ["swww img /home/chris/pics/wallpapers/tech.jpg --resize crop -t grow --transition-bezier .14,0,.14,.99"]; }
 | 
						|
      ];
 | 
						|
      workspaces = {
 | 
						|
        "main" = {
 | 
						|
          open-on-output = "eDP-1";
 | 
						|
        };
 | 
						|
      };
 | 
						|
      window-rules = [
 | 
						|
        {
 | 
						|
          geometry-corner-radius = {
 | 
						|
            top-left = 14.0;
 | 
						|
            top-right = 14.0;
 | 
						|
            bottom-left = 14.0;
 | 
						|
            bottom-right = 14.0;
 | 
						|
          };
 | 
						|
          clip-to-geometry = true;
 | 
						|
          draw-border-with-background = false;
 | 
						|
        }
 | 
						|
        {
 | 
						|
          matches = [ {app-id = "emacs";} ];
 | 
						|
          open-on-output = "DP-1";
 | 
						|
        }
 | 
						|
        {
 | 
						|
          matches = [{app-id = "org.qutebrowser.qutebrowser";}];
 | 
						|
          open-on-output = "DP-1";
 | 
						|
        }
 | 
						|
        {
 | 
						|
          matches = [{app-id = "mpv";}];
 | 
						|
          open-on-output = "DP-2";
 | 
						|
        }
 | 
						|
        {
 | 
						|
          matches = [{app-id = "com.system76.CosmicFiles";}];
 | 
						|
          open-floating = true;
 | 
						|
          default-column-width.proportion = 0.6;
 | 
						|
          default-window-height.proportion = 0.7;
 | 
						|
        }
 | 
						|
        {
 | 
						|
          matches = [{app-id = "bluetui";}];
 | 
						|
          open-floating = true;
 | 
						|
          default-column-width.proportion = 0.7;
 | 
						|
          default-window-height.proportion = 0.7;
 | 
						|
        }
 | 
						|
        {
 | 
						|
          matches = [{app-id = "impala";}];
 | 
						|
          open-floating = true;
 | 
						|
          default-column-width.proportion = 0.7;
 | 
						|
          default-window-height.proportion = 0.7;
 | 
						|
        }
 | 
						|
        {
 | 
						|
          matches = [{app-id = "btm";}];
 | 
						|
          open-floating = true;
 | 
						|
          default-column-width.proportion = 0.9;
 | 
						|
          default-window-height.proportion = 0.9;
 | 
						|
        }
 | 
						|
        {
 | 
						|
          matches = [{app-id = "pulsemixer";}];
 | 
						|
          open-floating = true;
 | 
						|
        }
 | 
						|
      ];
 | 
						|
      layer-rules = [
 | 
						|
        {
 | 
						|
          matches = [{namespace = "hyprpaper";}];
 | 
						|
          place-within-backdrop = true;
 | 
						|
        }
 | 
						|
        {
 | 
						|
          matches = [{namespace = "rofi";}];
 | 
						|
          geometry-corner-radius = {
 | 
						|
            top-left = 14.0;
 | 
						|
            top-right = 14.0;
 | 
						|
            bottom-left = 14.0;
 | 
						|
            bottom-right = 14.0;
 | 
						|
          };
 | 
						|
          shadow = {
 | 
						|
            enable = true;
 | 
						|
            draw-behind-window = false;
 | 
						|
            inactive-color = "#00000000";
 | 
						|
            softness = 10;
 | 
						|
            spread = 15;
 | 
						|
          };
 | 
						|
        }
 | 
						|
        {
 | 
						|
          matches = [{namespace = "launcher";}];
 | 
						|
          geometry-corner-radius = {
 | 
						|
            top-left = 14.0;
 | 
						|
            top-right = 14.0;
 | 
						|
            bottom-left = 14.0;
 | 
						|
            bottom-right = 14.0;
 | 
						|
          };
 | 
						|
          shadow = {
 | 
						|
            enable = true;
 | 
						|
            draw-behind-window = false;
 | 
						|
            inactive-color = "#00000000";
 | 
						|
            softness = 10;
 | 
						|
            spread = 15;
 | 
						|
          };
 | 
						|
        }
 | 
						|
      ];
 | 
						|
      animations = {
 | 
						|
      };
 | 
						|
      hotkey-overlay.skip-at-startup = true;
 | 
						|
      layout = {
 | 
						|
        center-focused-column = "never";
 | 
						|
        always-center-single-column = true;
 | 
						|
        preset-column-widths = [
 | 
						|
          { proportion = 1. / 3.; }
 | 
						|
          { proportion = 1. / 2.; }
 | 
						|
          { proportion = 2. / 3.; }
 | 
						|
          { proportion = 1. / 1.; }
 | 
						|
        ];
 | 
						|
        gaps = 15;
 | 
						|
        struts = {
 | 
						|
          bottom = 5;
 | 
						|
          left = 5;
 | 
						|
          right = 5;
 | 
						|
          top = 5;
 | 
						|
        };
 | 
						|
        shadow = {
 | 
						|
          enable = true;
 | 
						|
          draw-behind-window = false;
 | 
						|
          inactive-color = "#00000000";
 | 
						|
          softness = 10;
 | 
						|
          spread = 15;
 | 
						|
        };
 | 
						|
        border = {
 | 
						|
          enable = false;
 | 
						|
          width = 4;
 | 
						|
          active = {
 | 
						|
            gradient = {
 | 
						|
              from = "#57c7ff";
 | 
						|
              to = "#57c7ff";
 | 
						|
              relative-to = "workspace-view";
 | 
						|
              in' = "oklch increasing hue";
 | 
						|
            };
 | 
						|
          };
 | 
						|
          inactive = { color = "#5af78e"; };
 | 
						|
        };
 | 
						|
        focus-ring = {
 | 
						|
          enable = true;
 | 
						|
          width = 4;
 | 
						|
          active = {
 | 
						|
            gradient = {
 | 
						|
              angle = 120;
 | 
						|
              from = "#5af78e";
 | 
						|
              to = "#57c7ff";
 | 
						|
              relative-to = "window";
 | 
						|
              in' = "oklch increasing hue";
 | 
						|
            };
 | 
						|
          };
 | 
						|
          inactive = { color = "#43454f"; };
 | 
						|
        };
 | 
						|
      };
 | 
						|
      screenshot-path = "~/pics/screenshot_%Y-%m-%d_%H-%M-%S.png";
 | 
						|
      cursor = {
 | 
						|
        hide-after-inactive-ms = 3000;
 | 
						|
        hide-when-typing = true;
 | 
						|
        theme = "phinger-cursors-light";
 | 
						|
      };
 | 
						|
      outputs = {
 | 
						|
        "laptop" = {
 | 
						|
          enable = true;
 | 
						|
          name = "eDP-1";
 | 
						|
          focus-at-startup = true;
 | 
						|
          mode = {
 | 
						|
            height = 1504;
 | 
						|
            width = 2256;
 | 
						|
            refresh = 60.0;
 | 
						|
          };
 | 
						|
        };
 | 
						|
        "desktop-center" = {
 | 
						|
          enable = true;
 | 
						|
          name = "DP-1";
 | 
						|
          scale = 1.5;
 | 
						|
          position.x = 1080;
 | 
						|
          position.y = 0;
 | 
						|
          focus-at-startup = true;
 | 
						|
          mode = {
 | 
						|
            height = 2160;
 | 
						|
            width = 3640;
 | 
						|
            refresh = 60.0;
 | 
						|
          };
 | 
						|
        };
 | 
						|
        "desktop-right" = {
 | 
						|
          enable = true;
 | 
						|
          name = "DP-2";
 | 
						|
          position.x = 3640;
 | 
						|
          position.y = 0;
 | 
						|
          mode = {
 | 
						|
            height = 900;
 | 
						|
            width = 1600;
 | 
						|
            refresh = 59.94600;
 | 
						|
          };
 | 
						|
        };
 | 
						|
        "desktop-left" = {
 | 
						|
          enable = true;
 | 
						|
          name = "HDMI-A-1";
 | 
						|
          transform.rotation = 90;
 | 
						|
          position.x = 0;
 | 
						|
          position.y = 0;
 | 
						|
          mode = {
 | 
						|
            height = 1080;
 | 
						|
            width = 1920;
 | 
						|
            refresh = 60.0;
 | 
						|
          };
 | 
						|
        };
 | 
						|
      };
 | 
						|
      input = {
 | 
						|
        mod-key = "Super";
 | 
						|
        touchpad = {
 | 
						|
          accel-profile = "adaptive";
 | 
						|
          accel-speed = 0.75;
 | 
						|
          click-method = "clickfinger";
 | 
						|
          drag = true;
 | 
						|
        };
 | 
						|
        keyboard = {
 | 
						|
          repeat-delay = 180;
 | 
						|
          repeat-rate = 250;
 | 
						|
        };
 | 
						|
        warp-mouse-to-focus = {
 | 
						|
          enable = true;
 | 
						|
        };
 | 
						|
      };
 | 
						|
      environment = {
 | 
						|
 | 
						|
      };
 | 
						|
    };
 | 
						|
  };
 | 
						|
}
 |