TUW55WSRA6NVCAGKF5N6V3VKO6KGZUDEWI4MUZQ4ELZIV4RWLF6QC OAMXEFGRQWETSLTHNMSF723NKR734ZWDYWF7WAZA7QLFLSQBJZTAC YEQESH54N5Z3EGBCHGKADNP3DQYVURUD5N4UH3BKIYVTQOWBVXLQC RTBMBSBABSGTRICJ4AWBKWO3JJHBRKV6FGOMYPDD7X6SS6X35ZIQC NLGCV3BRXEQ6DRHZUCKU2F7DLEEYMB2F56NJP7LBPUWJGZ2A7DVAC DQKCPBYIW34BPR3BNMCBID7HL3MHGKR47LGBJ6B7VSIKMCOV3EFAC R5EABBYA5FVI4TE4L7XEZZWUHNWJRQDKHYCVIDR4KDHPIMPCAH7QC } else {}}todoScratchpad = mkScratchpad' {name = "todo";file = "todo.md";title = "Todo";};randomScratchpad = mkScratchpad' {name = "random";file = "random.md";title = "Random";};in{environment.systemPackages = [todoScratchpadrandomScratchpad];};in{config.flake.modules.nixos.scratchpads ={ pkgs, ... }:letmkScratchpad' = mkScratchpad { inherit pkgs; };if ($existing | is-empty) {^${pkgs.kitty}/bin/kitty --detach --class $scratchpad_class --title "${title}" --override remember_window_size=no --override initial_window_width=80c --override initial_window_height=24c --directory $notes_dir ${hx} $notes_path} else if $compositor == "niri" and $niri_bin != null {let id = ($existing | first | get id?)if $id != null { ^$niri_bin msg action close-window --id $id }}'';let existing = if $compositor == "niri" {$windows | where app_id? == $scratchpad_class} else {[]}[]let windows = if $compositor == "niri" {try { ^$niri_bin msg --json windows | from json } catch { [] }let compositor = if $niri_bin != null {"niri"} else {"unknown"}if (not ($notes_dir | path exists)) { mkdir $notes_dir }if (not ($notes_path | path exists)) { ^${pkgs.coreutils}/bin/touch $notes_path }let scratchpad_class = "${name}-scratchpad"let notes_path = ([$env.HOME "notes" "${file}"] | path join)let notes_dir = ($notes_path | path dirname)let niri_bin = (try { (which niri | get 0.path) } catch { null })mkScratchpad ={ pkgs, ... }:{name,file,title,}:lethx = getExe' pkgs.helix "hx";inpkgs.writeScriptBin "${name}-scratchpad" /* nu */ ''#!${pkgs.nushell}/bin/nu{ lib, ... }:letinherit (lib) getExe';
letmkScratchpad ={ pkgs, ... }:{name,file,title,}:pkgs.writeScriptBin "${name}-scratchpad" /* nu */ ''#!${pkgs.nushell}/bin/nulet niri_bin = (try { (which niri | get 0.path) } catch { null })let scratchpad_class = "${name}-scratchpad"let notes_path = ([$env.HOME "notes" "${file}"] | path join)let notes_dir = ($notes_path | path dirname)if (not ($notes_dir | path exists)) { mkdir $notes_dir }if (not ($notes_path | path exists)) { ^${pkgs.coreutils}/bin/touch $notes_path }let compositor = if $niri_bin != null {"niri"} else {"unknown"}let windows = if $compositor == "niri" {try { ^$niri_bin msg --json windows | from json } catch { [] }} else {[]}let existing = if $compositor == "niri" {$windows | where app_id? == $scratchpad_class} else {[]}if ($existing | is-empty) {^${pkgs.kitty}/bin/kitty --detach --class $scratchpad_class --title "${title}" --override remember_window_size=no --override initial_window_width=80c --override initial_window_height=24c --directory $notes_dir "hx" $notes_path} else if $compositor == "niri" and $niri_bin != null {let id = ($existing | first | get id?)if $id != null { ^$niri_bin msg action close-window --id $id }}'';in
];};config.flake.modules.nixos.scratchpads ={ pkgs, ... }:letmkScratchpad' = mkScratchpad { inherit pkgs; };todoScratchpad = mkScratchpad' {name = "todo";file = "todo.md";title = "Todo";};randomScratchpad = mkScratchpad' {name = "random";file = "random.md";title = "Random";};in{environment.systemPackages = [todoScratchpadrandomScratchpad