From 973993af608aa8ea7667bb2ac86946a2bc7d0471 Mon Sep 17 00:00:00 2001 From: cy Date: Sun, 19 Jan 2025 00:57:32 -0500 Subject: [PATCH] make mouse script work and add window rules --- home/niri/default.nix | 22 ++++++++++++++++++++++ home/niri/scripts/remote.sh | 25 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100755 home/niri/scripts/remote.sh diff --git a/home/niri/default.nix b/home/niri/default.nix index 0249b6f..bb9248f 100644 --- a/home/niri/default.nix +++ b/home/niri/default.nix @@ -39,6 +39,25 @@ in always-center-single-column = true; border.enable = false; }; + + window-rules = [ + { + matches = [{ app-id = "anki"; title = "Add"; }]; + open-floating = true; + } + { + matches = [{ app-id = "foot"; }]; + default-column-width.proportion = .5; + } + { + matches = [{ app-id = "Bitwarden"; }]; + open-floating = true; + } + { + matches = [{ app-id = "mpv"; }]; + open-floating = true; + } + ]; }; programs.niri.settings.binds = @@ -112,5 +131,8 @@ in "Mod+Alt+E".action = spawn "evolution"; "Mod+P".action = spawn "bitwarden"; "Mod+Comma".action = sh clipboard; + + "MouseForward".action = spawn "sh" "${./scripts/remote.sh}" "btn1"; + "MouseBack".action = spawn "sh" "${./scripts/remote.sh}"; }; } diff --git a/home/niri/scripts/remote.sh b/home/niri/scripts/remote.sh new file mode 100755 index 0000000..5065980 --- /dev/null +++ b/home/niri/scripts/remote.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +active_window=$(niri msg --json focused-window |jq -r .app_id) + +if [ "$1" = "btn1" ]; then + if [ "$active_window" = "anki" ]; then + wtype " " + elif [ "$active_window" = "foot" ]; then + wtype -M ctrl -M shift -k c -m ctrl -m shift + elif [ "$active_window" = "chromium-browser" ] || [ "$active_window" = "librewolf" ]; then + wtype -M alt -P right -p right -m alt + else + wtype -M ctrl -k c -m ctrl + fi +else + if [ "$active_window" = "anki" ]; then + wtype "1" + elif [ "$active_window" = "foot" ]; then + wtype -M ctrl -M shift -k v -m ctrl + elif [ "$active_window" = "chromium-browser" ] || [ "$active_window" = "librewolf" ]; then + wtype -M alt -P left -p left -m alt + else + wtype -M ctrl -k v -m ctrl + fi +fi