From 5e770b536c71c1a136c7db391200b5563d8516ec Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 16 Jan 2025 10:02:16 +0100 Subject: ... --- accounts/gkleen@sif/niri/default.nix | 60 +++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 8 deletions(-) (limited to 'accounts/gkleen@sif/niri/default.nix') diff --git a/accounts/gkleen@sif/niri/default.nix b/accounts/gkleen@sif/niri/default.nix index afedd6e3..36811d21 100644 --- a/accounts/gkleen@sif/niri/default.nix +++ b/accounts/gkleen@sif/niri/default.nix @@ -96,6 +96,28 @@ let ''; }; with-unnamed-workspace-action = config.lib.niri.actions.spawn (lib.getExe with_unnamed_workspace); + + with_select_window = pkgs.writeShellApplication { + name = "with-unnamed-workspace"; + runtimeInputs = [ niri pkgs.gojq pkgs.socat config.programs.fuzzel.package pkgs.gawk ]; + text = '' + window_select="$1" + shift + action="$1" + shift + + windows_json="$(niri msg -j windows)" + active_workspace="$(jq -r '.[] | select(.is_focused) | .workspace_id' <<<"$windows_json")" + window="$(gojq -r --arg active_workspace "$active_workspace" '.[] | select('"$window_select"') | "\(.title)\t\(.id)"' <<<"$windows_json" | fuzzel --log-level=warning --dmenu)" + window_id="$(awk -F $'\t' '{print $2}' <<<"$window")" + window_json="$(jq -r --arg window_id "$window_id" '.[] | select(.id == ($window_id | tonumber))' <<<"$windows_json")" + + [[ -z "$window_json" ]] && exit 1 + + jq -c "$action" <<<"$window_json" | socat STDIO "$NIRI_SOCKET" + ''; + }; + with-select-window-action = config.lib.niri.actions.spawn (lib.getExe with_select_window); in { imports = [ ./waybar.nix @@ -152,7 +174,7 @@ in { }; outputs = { - "Samsung Display Corp. 0x4141 Unknown" = { + "eDP-1" = { scale = 1.5; position = { x = 0; y = 0; }; }; @@ -209,11 +231,11 @@ in { cursor.hide-when-typing = true; workspaces = { - "001".name = "pwctl"; - "002".name = "kpxc"; - "003".name = "bmgr"; - "004".name = "term"; - "005".name = "edit"; + "001" = { name = "pwctl"; open-on-output = "eDP-1"; }; + "002" = { name = "kpxc"; open-on-output = "eDP-1"; }; + "003" = { name = "bmgr"; open-on-output = "eDP-1"; }; + "004" = { name = "term"; open-on-output = "eDP-1"; }; + "005" = { name = "edit"; open-on-output = "eDP-1"; }; "101".name = "comm"; "102".name = "web"; "104".name = "read"; @@ -329,8 +351,10 @@ in { fi [[ -n "$QALC_RES" ]] || exit 1 EXISTING=false + set +e grep -Fxrl "$QALC_RES" "$RESULTS_DIR" | xargs -r touch [[ ''${PIPESTATUS[0]} -eq 0 ]] && EXISTING=true + set -e if [[ $QALC_RET -eq 0 ]] && ! $EXISTING; then RES_FILE="$RESULTS_DIR"/$(date -uIs).$(tr -Cd 'a-zA-Z0-9' "$RES_FILE" <<<"$QALC_RES" @@ -349,6 +373,26 @@ in { wl-copy "$(cut -d ':' -f 1 <<<"$FUZZEL_RES" | tr -d '\n')" && wtype -k XF86Paste ''; })); + "Print".action = spawn (lib.getExe (pkgs.writeShellApplication { + name = "screenshot"; + runtimeInputs = with pkgs; [ grim slurp wl-clipboard-rs coreutils ]; + text = '' + grim -g "$(slurp -b 00000080 -c FFFFFFFF -s 00000000 -w 1)" - \ + | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \ + | wl-copy --type image/png + ''; + })); + "Shift+Print".action = spawn (lib.getExe (pkgs.writeShellApplication { + name = "screenshot"; + runtimeInputs = with pkgs; [ grim niri gojq wl-clipboard-rs coreutils ]; + text = '' + grim -o "$(niri msg -j workspaces | jq -r '.[] | select(.is_focused) | .output')" - \ + | tee "$HOME/screenshots/$(date +"%Y-%m-%dT%H:%M:%S").png" \ + | wl-copy --type image/png + ''; + })); + "Mod+B".action = with-select-window-action ".workspace_id == ($active_workspace | tonumber)" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; + "Mod+Shift+B".action = with-select-window-action "true" "{\"Action\":{\"FocusWindow\":{\"id\": .id}}}"; "Mod+H".action = focus-column-left; "Mod+T".action = focus-window-down; @@ -406,8 +450,8 @@ in { "Mod+Shift+F".action = maximize-column; "Mod+Shift+Ctrl+F".action = fullscreen-window; - "Mod+B".action = switch-focus-between-floating-and-tiling; - "Mod+Shift+B".action = toggle-window-floating; + "Mod+V".action = switch-focus-between-floating-and-tiling; + "Mod+Shift+V".action = toggle-window-floating; "Mod+Left".action = set-column-width "-10%"; "Mod+Down".action = set-window-height "-10%"; -- cgit v1.2.3