[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 7cf13a7 186/272: counsel.el (counsel-linux-app): New comma
From: |
Oleh Krehel |
Subject: |
[elpa] master 7cf13a7 186/272: counsel.el (counsel-linux-app): New command |
Date: |
Mon, 25 Apr 2016 10:13:24 +0000 |
branch: master
commit 7cf13a7199d9a231e02d5e496a40fe828140ab02
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-linux-app): New command
* counsel.el (counsel-linux-apps-alist):
(counsel-linux-apps-faulty): New defvar.
(counsel-linux-apps-list):
(counsel-linux-app-action): New defun.
---
counsel.el | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/counsel.el b/counsel.el
index ff0daa0..7d11eb4 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1815,7 +1815,59 @@ An extra action allows to switch to the process buffer."
("p" helm-rhythmbox-play-song "Play song")
("e" counsel-rhythmbox-enqueue-song "Enqueue song"))
:caller 'counsel-rhythmbox))
+;;** `counsel-linux-app'
+(defvar counsel-linux-apps-alist nil
+ "List of data located in /usr/share/applications.")
+
+(defvar counsel-linux-apps-faulty nil
+ "List of faulty data located in /usr/share/applications.")
+
+(defun counsel-linux-apps-list ()
+ (let ((files
+ (delete
+ ".." (delete
+ "." (file-expand-wildcards
"/usr/share/applications/*.desktop")))))
+ (dolist (file (cl-set-difference files (append (mapcar 'car
counsel-linux-apps-alist)
+ counsel-linux-apps-faulty)
+ :test 'equal))
+ (with-temp-buffer
+ (insert-file-contents (expand-file-name file
"/usr/share/applications"))
+ (let (name comment exec)
+ (goto-char (point-min))
+ (if (re-search-forward "^Name=\\(.*\\)$" nil t)
+ (setq name (match-string 1))
+ (error "File %s has no Name" file))
+ (goto-char (point-min))
+ (when (re-search-forward "^Comment=\\(.*\\)$" nil t)
+ (setq comment (match-string 1)))
+ (goto-char (point-min))
+ (when (re-search-forward "^Exec=\\(.*\\)$" nil t)
+ (setq exec (match-string 1)))
+ (if (and exec (not (equal exec "")))
+ (add-to-list
+ 'counsel-linux-apps-alist
+ (cons (format "% -45s: %s%s"
+ (propertize exec 'face 'font-lock-builtin-face)
+ name
+ (if comment
+ (concat " - " comment)
+ ""))
+ file))
+ (add-to-list 'counsel-linux-apps-faulty file))))))
+ counsel-linux-apps-alist)
+
+(defun counsel-linux-app-action (desktop-shortcut)
+ "Launch DESKTOP-SHORTCUT."
+ (call-process-shell-command
+ (format "gtk-launch %s" (file-name-nondirectory desktop-shortcut))))
+;;;###autoload
+(defun counsel-linux-app ()
+ "Launch a Linux desktop application, similar to Alt-<F2>."
+ (interactive)
+ (ivy-read "Run a command: " (counsel-linux-apps-list)
+ :action #'counsel-linux-app-action
+ :caller 'counsel-linux-app))
;;** `counsel-mode'
(defvar counsel-mode-map
(let ((map (make-sparse-keymap)))
- [elpa] master 299bc13 097/272: Fix initial-input not set to nil for 'read-file-name-internal, (continued)
- [elpa] master 299bc13 097/272: Fix initial-input not set to nil for 'read-file-name-internal, Oleh Krehel, 2016/04/25
- [elpa] master bab5aab 269/272: doc/Changelog.org: Prepare for the 0.8.0 release, Oleh Krehel, 2016/04/25
- [elpa] master 0efbf6e 055/272: Simplify the signature for :dynamic-collection functions, Oleh Krehel, 2016/04/25
- [elpa] master 6a5a688 201/272: counsel.el: Improve counsel-grep, Oleh Krehel, 2016/04/25
- [elpa] master 65cf724 247/272: Make ivy--regex work with "[^ ]", Oleh Krehel, 2016/04/25
- [elpa] master f72cea2 253/272: swiper.el (swiper-mc): Restore interactive, Oleh Krehel, 2016/04/25
- [elpa] master 08d5578 137/272: counsel.el (counsel-git-log): New command, Oleh Krehel, 2016/04/25
- [elpa] master 00f08f7 073/272: Improve Ivy documentation UI, Oleh Krehel, 2016/04/25
- [elpa] master 8f527d7 149/272: ivy.el (ivy-next-history-element): No "\\_<" for dynamic-collection, Oleh Krehel, 2016/04/25
- [elpa] master 265bf49 251/272: counsel.el: Fix compile warning, Oleh Krehel, 2016/04/25
- [elpa] master 7cf13a7 186/272: counsel.el (counsel-linux-app): New command,
Oleh Krehel <=
- [elpa] master 31a2f86 238/272: counsel.el (counsel-expression-history): enable-recursive-minibuffers, Oleh Krehel, 2016/04/25
- [elpa] master 5299c0a 099/272: doc/ivy.texi: Re-export from previous commit, Oleh Krehel, 2016/04/25
- [elpa] master a50f668 111/272: counsel.el (counsel-locate-options): Make obsolete, Oleh Krehel, 2016/04/25
- [elpa] master 327b85a 239/272: counsel.el (counsel-expression-history): Add docstring, Oleh Krehel, 2016/04/25
- [elpa] master b6f3e45 271/272: Rename swiper -> ivy, Oleh Krehel, 2016/04/25
- [elpa] master 9aa1f5c 156/272: counsel.el (counsel-mode-map): Add counsel-M-x, Oleh Krehel, 2016/04/25
- [elpa] master 6757030 225/272: counsel-grep now works with ivy-occur-revert-buffer, Oleh Krehel, 2016/04/25
- [elpa] master 6026caf 174/272: counsel.el (counsel-locate-cmd-es): Add, Oleh Krehel, 2016/04/25
- [elpa] master 7ed5b06 119/272: ivy.el (ivy--preselect-index): Don't use regexp-quote, Oleh Krehel, 2016/04/25
- [elpa] master dcf4957 123/272: counsel.el (counsel--async-command): Add sentinel and filter args, Oleh Krehel, 2016/04/25