WYLRCRR3GKEEFDE333WOMPWUZ2K5BX7KCU35MDHZVGFVBRGU7GWQC R5EABBYA5FVI4TE4L7XEZZWUHNWJRQDKHYCVIDR4KDHPIMPCAH7QC JNGUHQMQ6SH6P6ODHEAKNX2WK3XKVIG75XYJD3V4IZ4X5D7NLVLQC ADSDDVSAEJKH6UZ6PE74VDHSN4X2U3UNG3AEEWHRGP2BVKIXAG6QC L65HGT7CTSNIYIWGYIXPOWCXZZSNHXV5AV3TUBTTDBBPCYLSN4OQC MQT74AV47PUYNCX27OMFK6BFN7PP4DX46JAACN2EPRYXUXV7EL3AC DQKCPBYIW34BPR3BNMCBID7HL3MHGKR47LGBJ6B7VSIKMCOV3EFAC CG4ND52NJKGW4ZWDVJTNEL63CFPMLUVFXCDZFBQSRIO5QMBQVVXAC RTBMBSBABSGTRICJ4AWBKWO3JJHBRKV6FGOMYPDD7X6SS6X35ZIQC ICHS4YUWK6D3WCHMFD4NRZBAHIVSSKBAPXCS4G6KRH2WWNKOT7EQC ZV3WRRHZLMXNU5RKGY5WI2RMPYQY744SADPECCXU5F6X2VJIFEVAC NLGCV3BRXEQ6DRHZUCKU2F7DLEEYMB2F56NJP7LBPUWJGZ2A7DVAC RVV2KSCIXFU4HLXELZV67QDRTKG7OU6FZHFMPYO6HN6ISXPALX6QC { config, lib, pkgs, ... }: letinherit (lib) mkIf;
{config.flake.modules.nixos.process-management ={ pkgs, config, ... }:letprocessKiller = pkgs.writeScriptBin "process-killer" /* nu */ ''#!${pkgs.nushell}/bin/nudef get_processes [] {let nu_pids = ps | where name == "nu" | get pidlet filter_pids = if ($nu_pids | is-empty) { [] } else { $nu_pids }
process-killer = pkgs.writeScriptBin "process-killer" /* nu */ ''#!${pkgs.nushell}/bin/nudef get_processes [] {let nu_pids = ps | where name == "nu" | get pidlet filter_pids = if ($nu_pids | is-empty) { [] } else { $nu_pids }
ps| where pid not-in $filter_pids| where cpu != null and mem != null and name != null| sort-by cpu| reverse| select pid cpu mem name| each { |p|try {$"($p.name) (CPU: ($p.cpu | math round -p 1)%, MEM: ($p.mem | math round -p 1)%) [PID: ($p.pid)]"} catch {$"($p.name) [PID: ($p.pid)]"}}| where ($it | str length) > 0}
ps| where pid not-in $filter_pids| where cpu != null and mem != null and name != null| sort-by cpu| reverse| select pid cpu mem name| each { |p|
def extract_pid [choice: string] {$choice | parse "{name} [PID: {pid}]" | get pid.0? | into int}def get_process_name [pid: int] {ps | where pid == $pid | get name.0?}def fuzzel_select [items: list<string>, prompt: string] {$items | str join "\n" | ${pkgs.fuzzel}/bin/fuzzel --dmenu --prompt $prompt}def notify [title: string, message: string] {^${pkgs.libnotify}/bin/notify-send $title $message}def kill_process [pid: int] {
let pid = extract_pid $choice
if $confirm == "Yes" {if (kill_process $pid) {notify "Process Killed" ($"Killed ($process_name) \(PID: ($pid | into string)\)")} else {notify "Failed" ($"Could not kill ($process_name) \(PID: ($pid | into string)\)")}}}'';
if ($pid | is-empty) {notify "Error" "Could not extract PID"return}
processMonitorConfig = pkgs.writeText "btop-popup.conf" /* conf */ ''tty_mode = Trueforce_tty = Trueshown_boxes = "proc"proc_left = Falseproc_tree = Falseproc_gradient = Falseproc_colors = Falseproc_per_core = Falseproc_mem_bytes = Falseproc_cpu_graphs = Falseproc_mem_graphs = Falsemem_graphs = Falseshow_detailed = Falseshow_cpu_freq = Falseshow_uptime = Falseshow_disks = Falseshow_io_stat = Falseshow_swap = False'';
if $confirm == "Yes" {if (kill_process $pid) {notify "Process Killed" ($"Killed ($process_name) \(PID: ($pid | into string)\)")
let windows = if $compositor == "niri" {try { ^$niri_bin msg --json windows | from json } catch { [] }
notify "Failed" ($"Could not kill ($process_name) \(PID: ($pid | into string)\)")
[]}let existing = if $compositor == "niri" {$windows | where app_id? == $class_name} else {[]}if ($existing | is-empty) {^${pkgs.kitty}/bin/kitty --detach --class $class_name --title "Process Monitor" --override remember_window_size=no --override initial_window_width=44c --override initial_window_height=16c --override window_padding_width=${toString (config.theme.padding.small)} ${pkgs.btop}/bin/btop --config ${processMonitorConfig}} 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 }
{ config, lib, pkgs, ... }: letinherit (lib) mkIf;power-menu = pkgs.writeShellScriptBin "power-menu" ''case "$choice" in"Shutdown")systemctl poweroff;;"Reboot")systemctl reboot;;"Sleep");;"Lock")hyprlock --quiet --grace 60"Hibernate")hyprlock --quiet & systemctl hibernate;;;;*)exit 1;;esac'';in mkIf config.isDesktopNotWsl {environment.systemPackages = [power-menu];}hyprlock --quiet & systemctl suspendchoice=$(echo -e "Shutdown\nReboot\nSleep\nHibernate\nLock" | ${pkgs.fuzzel}/bin/fuzzel --dmenu --prompt "Power: ")
{ config, lib, pkgs, ... }: letinherit (lib) mkIf;btopPopupConfig = pkgs.writeText "btop-popup.conf" /* conf */ ''tty_mode = Trueforce_tty = Trueshown_boxes = "proc"proc_left = Falseproc_tree = Falseproc_gradient = Falseproc_colors = Falseproc_per_core = Falseproc_mem_bytes = Falseproc_cpu_graphs = Falseproc_mem_graphs = Falsemem_graphs = Falseshow_detailed = Falseshow_cpu_freq = Falseshow_uptime = Falseshow_disks = Falseshow_io_stat = Falseshow_swap = False'';process-monitor = pkgs.writeScriptBin "process-monitor" /* nu */ ''#!${pkgs.nushell}/bin/nulet niri_bin = (try { (which niri | get 0.path) } catch { null })let class_name = "btop-popup""niri"} else {"unknown"}try { ^$niri_bin msg --json windows | from json } catch { [] }let existing = if $compositor == "niri" {$windows | where app_id? == $class_name} else {[]}if ($existing | is-empty) {} 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 mkIf config.isDesktopNotWsl {environment.systemPackages = [process-monitor];}^${pkgs.kitty}/bin/kitty --detach --class $class_name --title "Process Monitor" --override remember_window_size=no --override initial_window_width=44c --override initial_window_height=16c --override window_padding_width=${toString (config.theme.padding.small)} ${pkgs.btop}/bin/btop --config ${btopPopupConfig}} else {[]}let windows = if $compositor == "niri" {let compositor = if $niri_bin != null {