EXWM and Qutebrowser

2024/06/29

Select files with dired

qutebrowser can pass a file where to put the selected paths. Let emacsclient just open the file and replace it with dired. C-c C-c binding puts the marked files (or file-at-point if nothing is marked) to the result file and kills the buffer, returning control back to qutebrowser

c.fileselect.single_file.command = ['emacsclient', '{}']
c.fileselect.folder.command = ['emacsclient', '{}']
c.fileselect.multiple_files.command = ['emacsclient', '{}']
Code Snippet 1: config.py
(defun qute/choose-file ()
  (interactive)
  (let ((files (dired-get-marked-files)))
    (with-temp-file qute-filename
      (insert (s-join "\n" files)))
    (kill-buffer)))

(defun qute/dired-hook (&optional f)
  (when (s-starts-with? "/tmp/qutebrowser-fileselect" buffer-file-name)
    (setq qute-filename buffer-file-name)
    (dired "~/")
    (kill-buffer (find-file-noselect qute-filename))))

(keymap-set dired-mode-map "C-c C-c" #'qute/choose-file)
(add-hook 'server-visit-hook #'qute/dired-hook)
Code Snippet 2: dired hook

Fill passwords with autocompletion

Bind password_fill somewhere: config.bind('xp', 'spawn -u password_fill')

choose_entry() {
    MENU_COMMAND=( dmenu -p pass -c pass )
    choose_entry_menu || true
}
Code Snippet 3: ~/.config/qutebrowser/password_fill_rc