Kaynağa Gözat

dev: automated commit - 2026-01-26 20:07:13

Mariano Z. 1 hafta önce
ebeveyn
işleme
38f63235ee

+ 26 - 26
local-bin/.local/bin/niri-dev-launcher

@@ -43,7 +43,7 @@ def _has_fd():
 def find_git_repos(dev_dir, no_cache=False):
     cache_file, _ = get_cache_files(dev_dir)
     debug("find_git_repos: checking cache...")
-    
+
     if not no_cache and cache_file.exists():
         cache_age = time.time() - os.path.getmtime(cache_file)
         debug(f"Cache age: {cache_age:.0f}s (max: {CACHE_MAX_AGE}s)")
@@ -51,28 +51,28 @@ def find_git_repos(dev_dir, no_cache=False):
             debug("Using cached repos")
             return [r for r in cache_file.read_text().strip().split("\n") if r]
         debug("Cache expired, rescanning...")
-    
+
     debug(f"Scanning for git repositories in {dev_dir}...")
     if not Path(dev_dir).exists():
         return []
-    
+
     repos = []
     if _has_fd():
         debug("Using fd for scanning")
         result = subprocess.run(
-            ["fd", "-H", "-t", "d", "^\.git$", dev_dir, "-d", "3", "-0"],
+            ["fd", "-H", "-t", "d", "^\.git$", dev_dir, "-d", "4", "-0"],
             capture_output=True, text=True,
         )
     else:
         debug("Using find for scanning")
         result = subprocess.run(
-            ["find", dev_dir, "-maxdepth", "3", "-type", "d", "-name", ".git", "-print0"],
+            ["find", dev_dir, "-maxdepth", "4", "-type", "d", "-name", ".git", "-print0"],
             capture_output=True, text=True,
         )
-    
+
     if result.returncode == 0:
         repos = [str(Path(g).parent) for g in result.stdout.strip("\0").split("\0") if g]
-    
+
     repos = sorted(set(repos))
     cache_file.parent.mkdir(parents=True, exist_ok=True)
     cache_file.write_text("\n".join(repos))
@@ -102,10 +102,10 @@ def sort_by_mru(display_list, dev_dir):
     mru_set = set()
     if mru_file.exists():
         mru_set = {l.strip() for l in mru_file.read_text().split("\n") if l.strip()}
-    
+
     if not mru_set:
         return sorted(display_list)
-    
+
     # Use set for O(1) lookup instead of list
     mru_repos = sorted([f"⭐ {d}" for d in display_list if d in mru_set])
     non_mru_repos = sorted([d for d in display_list if d not in mru_set])
@@ -131,10 +131,10 @@ def find_window_by_app_id(app_id):
 def focus_or_launch_alacritty(class_name, title, working_dir, session_name):
     debug(f"focus_or_launch_alacritty: class={class_name}, title={title}, dir={working_dir}")
     window_id = find_window_by_app_id(class_name)
-    
+
     if window_id:
         debug("Found existing window, focusing...")
-        subprocess.run(["niri", "msg", "action", "focus-window", "--id", window_id], 
+        subprocess.run(["niri", "msg", "action", "focus-window", "--id", window_id],
                       stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
     else:
         debug("No existing window found, launching alacritty...")
@@ -148,7 +148,7 @@ else
     tmux attach -t '{session_name}';
 fi"""
         subprocess.Popen(
-            ["alacritty", f"--class={class_name}", f"--title={title}", 
+            ["alacritty", f"--class={class_name}", f"--title={title}",
              f"--working-directory={working_dir}", "-e", "bash", "-c", tmux_cmd],
             stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, start_new_session=True,
         )
@@ -160,13 +160,13 @@ def main():
     parser.add_argument("--no-cache", action="store_true", help="Bypass cache and rescan repositories")
     parser.add_argument("--clear-cache", action="store_true", help="Clear cache and MRU files")
     args = parser.parse_args()
-    
+
     debug(f"Starting niri-dev-launcher with args: {sys.argv[1:]}")
     debug(f"DEV_DIR: {args.dev_dir}")
     cache_file, mru_file = get_cache_files(args.dev_dir)
     debug(f"CACHE_FILE: {cache_file}")
     debug(f"MRU_FILE: {mru_file}")
-    
+
     if args.clear_cache:
         if cache_file.exists():
             cache_file.unlink()
@@ -174,13 +174,13 @@ def main():
             mru_file.unlink()
         subprocess.run(["notify-send", "Niri Dev Launcher", "Cache cleared"], check=False)
         sys.exit(0)
-    
+
     repos = find_git_repos(args.dev_dir, args.no_cache)
     if not repos:
         debug("No repositories found!")
         subprocess.run(["notify-send", "Niri Dev Launcher", f"No git repositories found in {args.dev_dir}"], check=False)
         sys.exit(1)
-    
+
     debug("Found repositories, proceeding...")
     display_to_path = {}
     display_list = []
@@ -188,13 +188,13 @@ def main():
         display = str(Path(repo).relative_to(args.dev_dir)) if repo.startswith(args.dev_dir) else repo
         display_list.append(display)
         display_to_path[display] = repo
-    
+
     debug(f"Mapped {len(display_to_path)} projects")
     debug("Sorting by MRU...")
     sorted_list = sort_by_mru(display_list, args.dev_dir)
     debug("Presenting in fuzzel...")
-    
-    # Use default font to avoid subprocess call - can be overridden via env if needed    
+
+    # Use default font to avoid subprocess call - can be overridden via env if needed
     fuzzel_process = subprocess.Popen(
         ["fuzzel", "--prompt", "💀 Poison: ", "--dmenu", "--width", "30", "--lines", "20",
          "--border-width", "2", "--background-color", "#191724ff",
@@ -202,27 +202,27 @@ def main():
          "--selection-text-color", "#31748fff", "--selection-match-color", "#31748fff", "--prompt-color", "#f6c177ff"],
         stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True,
     )
-    
+
     stdout, _ = fuzzel_process.communicate(input="\n".join(sorted_list))
     selected_display = stdout.strip()
     debug(f"Selected display: '{selected_display}'")
-    
+
     if not selected_display:
         debug("No selection, exiting")
         sys.exit(0)
-    
+
     selected_display_clean = selected_display.replace("⭐ ", "", 1)
     selected = display_to_path.get(selected_display_clean, "")
     debug(f"Selected display (clean): '{selected_display_clean}'")
     debug(f"Selected path: '{selected}'")
-    
+
     if not selected or not Path(selected).is_dir():
         debug("Invalid selection, exiting")
         sys.exit(0)
-    
+
     debug("Updating MRU...")
     update_mru(selected_display_clean, args.dev_dir)
-    
+
     project_name = get_project_name(selected)
     session_name = f"dev-{project_name}"
     class_name = f"com.mzunino.dev.{project_name}"
@@ -230,7 +230,7 @@ def main():
     debug(f"Session name: {session_name}")
     debug(f"Class name: {class_name}")
     debug("Focusing or launching alacritty...")
-    
+
     focus_or_launch_alacritty(class_name, project_name, selected, session_name)
 
 

+ 48 - 27
local-bin/.local/bin/vmrss

@@ -2,40 +2,61 @@
 
 set -euo pipefail
 
-has_gum() {
-    command -v gum >/dev/null 2>&1
-}
+R='\033[0m' B='\033[1m' D='\033[2m' RED='\033[31m' BLU='\033[38;5;33m' YLW='\033[38;5;179m'
 
-die() {
-    if has_gum; then
-        gum style --foreground 196 --bold "error:" "$1"
-    else
-        echo "error: $1" >&2
-    fi
-    exit 1
-}
+die() { printf "${RED}${B}error:${R} %s\n" "$1" >&2; exit 1; }
 
-if [ -z "${1:-}" ]; then
-    die "usage: $0 <PID>"
-fi
+usage() { die "usage: $0 [-w] [-i interval] <PID>"; }
 
-PID=$1
+WATCH=0 INTERVAL=1
 
-if ! ps -p "$PID" >/dev/null 2>&1; then
-    die "process with PID $PID does not exist"
+while getopts "wi:" opt; do
+    case "$opt" in
+        w) WATCH=1 ;; i) INTERVAL="$OPTARG" ;; *) usage ;;
+    esac
+done
+shift $((OPTIND - 1))
+
+PID="${1:-}"
+
+if [ -z "$PID" ]; then
+    command -v fzf >/dev/null 2>&1 || usage
+    PID=$(ps -eo pid,user,%mem,comm --sort=-%mem | fzf --header-lines=1 | awk '{print $1}')
+    [ -z "$PID" ] && exit 0
 fi
 
-VMRSS_KB=$(awk '/^VmRSS:/ { print $2 }' /proc/"$PID"/status)
-[ -z "$VMRSS_KB" ] && die "could not read VmRSS for PID $PID"
+ps -p "$PID" >/dev/null 2>&1 || die "process $PID does not exist"
 
-VMRSS_MB=$(awk -v kb="$VMRSS_KB" 'BEGIN { printf "%.2f", kb / 1024 }')
+COMM=$(cat /proc/"$PID"/comm 2>/dev/null || echo "?")
 
-if has_gum; then
-    echo "$(gum style --bold "PID:") $(gum style --faint "$PID")"
-    echo "$(gum style --foreground 240 "VmRSS:") $(gum style --foreground 33 "${VMRSS_KB} kB") ($(gum style --foreground 244 "${VMRSS_MB} MB"))"
-else
-    echo "PID: $PID"
-    echo "VmRSS: $VMRSS_KB kB ($VMRSS_MB MB)"
-fi
+print_rss() {
+    read -r rss peak size swap < <(awk '
+        /^VmRSS:/  { rss=$2 }
+        /^VmPeak:/ { peak=$2 }
+        /^VmSize:/ { size=$2 }
+        /^VmSwap:/ { swap=$2 }
+        END { print rss, peak, size, swap }
+    ' /proc/"$PID"/status 2>/dev/null) || die "could not read memory for PID $PID"
+
+    fmt() { awk -v kb="$1" 'BEGIN { printf "%.1f MB", kb/1024 }'; }
 
+    printf "${B}%s${R} ${D}(PID %s)${R}\n" "$COMM" "$PID"
+    printf "  ${YLW}${B}RSS:${R}  ${BLU}%s${R}  ${D}Peak:${R} %s  ${D}Size:${R} %s  ${D}Swap:${R} %s\n" \
+        "$(fmt "$rss")" "$(fmt "$peak")" "$(fmt "$size")" "$(fmt "$swap")"
+}
 
+if [ "$WATCH" -eq 1 ]; then
+    printf '\033[?25l'
+    trap 'printf "\033[?25h"; exit' INT TERM
+    first=1
+    while ps -p "$PID" >/dev/null 2>&1; do
+        [ "$first" -eq 0 ] && printf '\033[2A'
+        first=0
+        print_rss
+        sleep "$INTERVAL"
+    done
+    printf '\033[?25h'
+    die "process $PID exited"
+else
+    print_rss
+fi

+ 16 - 16
noctalia/.config/noctalia/colors.json

@@ -1,18 +1,18 @@
 {
-    "mError": "#d95757",
-    "mHover": "#39bae6",
-    "mOnError": "#0b0e14",
-    "mOnHover": "#0b0e14",
-    "mOnPrimary": "#0b0e14",
-    "mOnSecondary": "#0b0e14",
-    "mOnSurface": "#bfbdb6",
-    "mOnSurfaceVariant": "#636a72",
-    "mOnTertiary": "#0b0e14",
-    "mOutline": "#565b66",
-    "mPrimary": "#e6b450",
-    "mSecondary": "#aad94c",
-    "mShadow": "#000000",
-    "mSurface": "#0b0e14",
-    "mSurfaceVariant": "#1e222a",
-    "mTertiary": "#39bae6"
+    "mError": "#eb6f92",
+    "mHover": "#524f67",
+    "mOnError": "#191724",
+    "mOnHover": "#e0def4",
+    "mOnPrimary": "#191724",
+    "mOnSecondary": "#191724",
+    "mOnSurface": "#e0def4",
+    "mOnSurfaceVariant": "#908caa",
+    "mOnTertiary": "#e0def4",
+    "mOutline": "#403d52",
+    "mPrimary": "#ebbcba",
+    "mSecondary": "#9ccfd8",
+    "mShadow": "#191724",
+    "mSurface": "#191724",
+    "mSurfaceVariant": "#26233a",
+    "mTertiary": "#31748f"
 }

+ 1 - 109
zsh/.config/zsh/functions/dev.zsh

@@ -150,92 +150,7 @@ function sb {
 }
 
 function yay() {
-  # Set up completion on first call
-  if [[ -z "$_yay_completion_setup" ]]; then
-    compdef _yay_completion yay 2>/dev/null
-    _yay_completion_setup=1
-  fi
-
-  case "$1" in
-    update|"-Syu")
-      echo "Updating NixOS system..."
-      cd ~/.config/nixos/ || exit && nix flake update && sudo nixos-rebuild switch --flake . && nix store optimise && sudo nix-collect-garbage --delete-older-than 3d
-      ;;
-
-    search|"-Ss")
-      [ -z "$2" ] && { echo "Usage: yay search <package>"; return 1; }
-      echo "Searching for '$2'..."
-      nix search nixpkgs "$2" 2>/dev/null || nix-env -qaP | grep -i "$2"
-      ;;
-
-    install|"-S")
-      [ -z "$2" ] && { echo "Usage: yay install <package>"; return 1; }
-      echo "Installing $2..."
-      nix-env -iA nixpkgs.$2
-      ;;
-
-    remove|"-R")
-      [ -z "$2" ] && { echo "Usage: yay remove <package>"; return 1; }
-      echo "Removing $2..."
-      nix-env -e "$2"
-      ;;
-
-    list|"-Q")
-      echo "Installed packages:"
-      nix-env -q
-      ;;
-
-    shell|"-p")
-      shift
-      if [ $# -eq 0 ]; then
-        echo "Usage: yay shell <pkg1> [pkg2 ...]"
-        return 1
-      fi
-      echo "Starting nix-shell with: $*"
-      nix-shell -p "$@"
-      ;;
-
-    clean|"-Sc")
-      echo "Cleaning nix store..."
-      nix-collect-garbage
-      sudo nix-collect-garbage -d
-      ;;
-
-    help|"-h")
-      bat -Pp << 'EOF'
-yay - Simple NixOS package manager wrapper
-
-Commands:
-  yay                    Rebuild system
-  yay update             Update system
-  yay search <pkg>       Search packages
-  yay install <pkg>      Install package (user)
-  yay remove <pkg>       Remove package
-  yay list               List installed packages
-  yay shell <pkg...>     Start nix-shell with packages
-  yay clean              Clean package cache
-  yay help               Show this help
-
-Note: For system packages, edit ~/.config/nixos/configuration.nix
-EOF
-      ;;
-
-    "")
-      echo "Rebuilding NixOS system..."
-      cd ~/.config/nixos/ || exit && sudo nixos-rebuild switch --flake .
-      ;;
-
-    *)
-      if [[ ! "$1" =~ ^- ]]; then
-        echo "Installing '$1'..."
-        nix-env -iA nixpkgs.$1
-      else
-        echo "Unknown option: $1"
-        echo "Run 'yay help' for available commands"
-        return 1
-      fi
-      ;;
-  esac
+  echo "use ny"
 }
 
 _package_manager_completion() {
@@ -253,26 +168,3 @@ _package_manager_completion() {
   _describe 'package manager commands' commands
 }
 
-_yay_completion() {
-  local -a opts
-  opts=(
-    '-Syyu:Update system'
-    '-Syu:Update system'
-    '-Ss:Search packages'
-    '-S:Install system-wide'
-    '-R:Remove package'
-    '-Q:List installed'
-    '-Si:Package info'
-    '-Sc:Clean cache'
-    '-p:Open nix-shell with packages'
-    'help:Show help'
-    'install:Install to user env'
-    'remove:Remove from user env'
-    'list:List installed packages'
-    'clean:Clean nix store'
-    'shell:Start nix-shell with packages'
-  )
-  _describe 'yay commands' opts
-}
-
-# Completion functions are set up when functions are first called