dotfiles/home/modules/niri.nix

220 lines
7.3 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
];
programs.niri = {
# enable = true;
settings = {
prefer-no-csd = true;
binds = with config.lib.niri.actions; let
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/nirilof emacs 'emacslient -c'"];
"Super+Return".action.spawn = "alacritty";
"Super+B".action = spawn ["${pkgs.nushell}/bin/nu" "/home/chris/nirilof org.qutebrowser.qutebrowser qutebrowser"];
"Super+Space".action.spawn = "cosmic-launcher";
"Super+V".action= spawn ["${pkgs.fish}/bin/fish" "-c" "${pkgs.cliphist}/bin/cliphist list | ${pkgs.rofi-wayland}/bin/rofi -p '󱃔 ' -dmenu | ${pkgs.cliphist}/bin/cliphist decode | ${pkgs.wl-clipboard}/bin/wl-copy"];
"Super+I".action.spawn = ["alacritty" "--class" "btm" "-e" "btm"];
"Super+A".action.spawn = ["alacritty" "--class" "pulsemixer" "-e" "pulsemixer"];
"Super+Shift+Q".action = quit;
"Super+O".action = toggle-overview;
"Super+F".action = fullscreen-window;
"Super+Shift+F".action = toggle-windowed-fullscreen;
"Super+C".action = close-window;
"Super+Shift+C".action = center-window;
"Super+P".action.spawn = "/home/chris/bin/rbw.sh";
"Super+Left".action = focus-column-left;
"Super+H".action = focus-column-left;
"Super+Shift+H".action = move-column-left;
"Super+Right".action = focus-column-right;
"Super+L".action = focus-column-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;
};
spawn-at-startup = [
{ argv = ["${pkgs.xwayland-satellite}/bin/xwayland-satellite"]; }
{ argv = ["waybar"]; }
{ argv = ["cosmic-osd"]; }
{ argv = ["kwalled6"]; }
{ argv = ["swww-daemon"]; }
{ argv = ["rbw-agent"]; }
{ argv = ["/usr/lib/kdeconnectd"]; }
{ 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"]; }
{ argv = ["dbus-update-activation-environment --systemd --all"]; }
];
workspaces = {
"main" = {
open-on-output = "eDP-1";
};
};
window-rules = [
{
geometry-corner-radius = {
top-left = 16.0;
top-right = 16.0;
bottom-left = 16.0;
bottom-right = 16.0;
};
clip-to-geometry = true;
draw-border-with-background = false;
}
{
matches = [ {app-id = "emacs";} ];
open-on-workspace = "main";
}
{
matches = [{app-id = "org.qutebrowser.qutebrowser";}];
open-on-workspace = "main";
}
{
matches = [{app-id = "com.system76.CosmicFiles";}];
open-floating = true;
}
{
matches = [{app-id = "btm";}];
open-floating = true;
default-column-width.proportion = 0.7;
default-window-height.proportion = 0.7;
}
{
matches = [{app-id = "pulsemixer";}];
open-floating = true;
}
];
layout = {
center-focused-column = "never";
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 = { color = "#57c7ff"; };
inactive = { color = "#5af78e"; };
};
focus-ring = {
enable = true;
width = 4;
active = { color = "#5af78e"; };
};
};
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 = {
"eDP-1" = {
enable = true;
name = "A";
mode = {
height = 1504;
width = 2256;
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 = 180;
};
warp-mouse-to-focus = {
enable = true;
};
};
environment = {
};
};
};
}