Skip to content

Commit

Permalink
new source: zaw-applications
Browse files Browse the repository at this point in the history
  • Loading branch information
nakamuray committed Aug 10, 2011
1 parent ca9cd0d commit 1ca1e74
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ sources

currently these sources are available:

- ack
- applications
- bookmark
- git-files
- git-showbranch
- history
- memo
- named-cmd
- open-file
- perldoc
- screens
Expand All @@ -60,10 +59,14 @@ you can get all available shortcut widgets' name using ``zaw-print-src``::
$ zaw-print-src
source name shortcut widget name
----------------------------------------
ack zaw-ack
applications zaw-applications
bookmark zaw-bookmark
git-files zaw-git-files
history zaw-history
open-file zaw-open-file
perldoc zaw-perldoc
screens zaw-screens


key binds and styles
Expand Down
57 changes: 57 additions & 0 deletions sources/applications.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#
# zaw-src-applications
#
# zaw source for desktop applications
#

function zaw-src-applications() {
emulate -L zsh
setopt local_options extended_glob null_glob

local d
local -a match mbegin mend
for d in /usr/share/applications/*.desktop; do
local name="" comment="" exec_="" terminal=0 no_display=0
while read line; do
case "${line}" in
Name=(#b)(*))
name="${match[1]}"
;;
Comment=(#b)(*))
comment="${match[1]}"
;;
Exec=(#b)(*))
exec_="${match[1]}"
;;
Terminal=true)
terminal=1
;;

NoDisplay=true)
no_display=1
;;
esac
done < "${d}"

if (( no_display )); then
continue
fi

# TODO: % expansion in $exec_
# remove args that match %* from $exec_
exec_="${(@m)${(z)exec_}:#%*}"

if ! (( terminal )); then
# disown
exec_="${exec_} &!"
fi

candidates+=( "${exec_}" )
cand_descriptions+=( "${name} - ${comment}" )
done

actions=("zaw-callback-execute" "zaw-callback-append-to-buffer")
act_descriptions=("execute application" "append to edit buffer")
}

zaw-register-src -n applications zaw-src-applications

0 comments on commit 1ca1e74

Please sign in to comment.