Transmission: Advice the function to properly start the daemon on demand

master
Pierre Neidhardt 2017-12-27 11:38:24 +01:00
parent 562e65d66a
commit e796b4ec74
1 changed files with 11 additions and 2 deletions

View File

@ -336,8 +336,17 @@
;;; Torrent
(nconc package-selected-packages '(transmission))
(with-eval-after-load 'transmission
(call-process "transmission-daemon")
(sleep-for 1)
;; `transmission' will fail to start and will not run any hook if the daemon
;; is not up yet.
;; We need to advice the function :before to guarantee it starts.
(defun transmission-start-daemon ()
(unless (member "transmission-da"
(mapcar
(lambda (pid) (alist-get 'comm (process-attributes pid)))
(list-system-processes)))
(call-process "transmission-daemon")
(sleep-for 1)))
(advice-add 'transmission :before 'transmission-start-daemon)
(setq transmission-refresh-modes '(transmission-mode transmission-files-mode transmission-info-mode transmission-peers-mode)
transmission-refresh-interval 1))