branch: master
commit 27926047ff0220ff1e129b85b2350d6c41cbd746
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>

    counsel.el (counsel-linux-app): Add "d" action to open desktop file
    
    * counsel.el (counsel-linux-app-action-open-desktop): New defun.
    (ivy-set-actions): Update.
    
    Fixes #897
---
 counsel.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/counsel.el b/counsel.el
index e20106b..9747aa0 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2845,9 +2845,19 @@ Any desktop entries that fail to parse are recorded in 
`counsel-linux-apps-fault
         (call-process "gtk-launch" nil nil nil desktop-shortcut file)
       (user-error "cancelled"))))
 
+(defun counsel-linux-app-action-open-desktop (desktop-shortcut)
+  "Open DESKTOP-SHORTCUT"
+  (setq desktop-shortcut (cdr desktop-shortcut))
+  (let ((file
+         (cdr (assoc desktop-shortcut 
(counsel-linux-apps-list-desktop-files)))))
+    (if file
+        (find-file file)
+      (user-error "cancelled"))))
+
 (ivy-set-actions
  'counsel-linux-app
- '(("f" counsel-linux-app-action-file "run on a file")))
+ '(("f" counsel-linux-app-action-file "run on a file")
+   ("d" counsel-linux-app-action-open-desktop "open desktop file")))
 
 ;;;###autoload
 (defun counsel-linux-app ()

Reply via email to