Niri floating rule for the experimental Emacs selector

This commit is contained in:
Andrea Ciceri 2025-01-14 17:38:32 +01:00
parent e21a61c360
commit bfa2f177d3
Signed by: aciceri
SSH key fingerprint: SHA256:/AagBweyV4Hlfg9u092n8hbHwD5fcB6A3qhDiDA65Rg
2 changed files with 35 additions and 18 deletions

View file

@ -1016,26 +1016,41 @@ This is meant to be an helper to be called from the window manager."
;;; Experiments, remove from here ;;; Experiments, remove from here
(defun ccr/test (niri-socket)
(defun ccr/test () "Select a window and focus it based on `niri msg` output."
"test"
(interactive) (interactive)
(with-selected-frame (let* ((niri-output (ccr/niri-get-windows niri-socket))
(make-frame '((name . "Emacs Selector") (display-list (mapcar (lambda (entry)
(minibuffer . only) (let ((title (cdr (assoc 'title entry)))
(fullscreen . 0) ; no fullscreen (app-id (cdr (assoc 'app_id entry)))
(undecorated . t) ; remove title bar (id (cdr (assoc 'id entry))))
;;(auto-raise . t) ; focus on this frame (cons (format "%s - %s" title app-id) id)))
;;(tool-bar-lines . 0) niri-output)))
;;(menu-bar-lines . 0) (with-selected-frame
(internal-border-width . 10) (make-frame '((name . "Emacs Selector")
(width . 50) (minibuffer . only)
(height . 10))) (fullscreen . 0)
(unwind-protect (undecorated . t)
(completing-read "ciao " '("foo" "bar" "pippo") nil t "") (internal-border-width . 10)
(delete-frame)))) (width . 120)
(height . 20)))
(unwind-protect
(let* ((entry (completing-read "Select window: " (mapcar #'car display-list) nil t ""))
(entry-id (cdr (assoc entry display-list))) ;; Get the ID associated with the selected entry
(command (format "NIRI_SOCKET=\"%s\" niri msg action focus-window --id %s" niri-socket entry-id)))
(message command)
(shell-command command))
(delete-frame)))))
(defun ccr/niri-get-windows (niri-socket)
"Esegue `niri msg --json windows` e parse l'output JSON in una alist."
(let* ((command (format "NIRI_SOCKET=\"%s\" niri msg --json windows" niri-socket))
(output (shell-command-to-string command))
(json-object-type 'alist) ; Usa alist per rappresentare gli oggetti JSON
(parsed-json (json-read-from-string output)))
parsed-json))
(provide 'init) (provide 'init)
;;; init.el ends here ;;; init.el ends here

View file

@ -301,7 +301,9 @@ window-rule {
} }
window-rule { window-rule {
match app-id=r#"^Emacs Selector$"# match title=r#"^Emacs Selector$"#
opacity 0.95
open-floating true
} }