Niri floating rule for the experimental Emacs selector
This commit is contained in:
parent
e21a61c360
commit
bfa2f177d3
2 changed files with 35 additions and 18 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue