aboutsummaryrefslogtreecommitdiffstats
path: root/src/_gtk-launch
diff options
context:
space:
mode:
authorShohei YOSHIDA <syohex@gmail.com>2023-09-04 12:45:12 +0900
committerShohei YOSHIDA <syohex@gmail.com>2023-09-05 08:45:14 +0900
commit9dfd82bc78d1964d28e75df604e7a16345194008 (patch)
tree0fb917f98e2f11d3da9dab72308696fb9d786bf3 /src/_gtk-launch
parentMerge pull request #1033 from zsh-users/add-supervisord (diff)
downloadzsh-completions-9dfd82bc78d1964d28e75df604e7a16345194008.tar
zsh-completions-9dfd82bc78d1964d28e75df604e7a16345194008.tar.gz
zsh-completions-9dfd82bc78d1964d28e75df604e7a16345194008.tar.bz2
zsh-completions-9dfd82bc78d1964d28e75df604e7a16345194008.tar.lz
zsh-completions-9dfd82bc78d1964d28e75df604e7a16345194008.tar.xz
zsh-completions-9dfd82bc78d1964d28e75df604e7a16345194008.tar.zst
zsh-completions-9dfd82bc78d1964d28e75df604e7a16345194008.zip
Fix broken gtk-launch completion and update
- Use zsh builtin functions instead of external commands - Stop parsing desktop file - Because it often causes error - It is difficult to extract the description that is in user's language - Support gtk4-launch
Diffstat (limited to 'src/_gtk-launch')
-rw-r--r--src/_gtk-launch67
1 files changed, 32 insertions, 35 deletions
diff --git a/src/_gtk-launch b/src/_gtk-launch
index 20b08e0..82f7119 100644
--- a/src/_gtk-launch
+++ b/src/_gtk-launch
@@ -1,4 +1,4 @@
-#compdef gtk-launch
+#compdef gtk-launch gtk4-launch
# ------------------------------------------------------------------------------
# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users
# All rights reserved.
@@ -28,55 +28,52 @@
# Description
# -----------
#
-# Completion script for gtk-launch on gtk+-3.14.8 (https://www.gtk.org/).
+# Completion script for gtk-launch on gtk+-3.24.37, gtk4-launch-4.10.4
+# (https://www.gtk.org/).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
-# * ncaq <ncaq@ncaq.net> (version 3.14.8)
+# * ncaq <ncaq@ncaq.net>
#
# ------------------------------------------------------------------------------
_gtk-launch() {
- _arguments \
- {-h,--help}'[Show help options]' \
- --help-all'[Show all help options]' \
- --help-gtk'[Show GTK+ Options]' \
- --display='[X display to use]' \
- '1: :_applications'
-}
-
-_applications() {
- local -a applications
+ local ret=1
- for file in /usr/share/applications/*.desktop; do
- applications+=`_format_entry $file`
- done
+ if [[ $service == "gtk-launch" ]]; then
+ _arguments -S -A "-*" \
+ '(- *)'{-h,--help}'[Show help options]' \
+ '(- *)'{-v,--version}'[Show program version]' \
+ '(- *)'--help-all'[Show all help options]' \
+ '(- *)'--help-gtk'[Show GTK+ Options]' \
+ '(- *)'--display='[X display to use]:display:_x_display' \
+ '--class=[Program class as used by the window manager]:class' \
+ '--name=[Program name as used by the window manager]:name' \
+ '--gtk-module=[Load additional GTK+ modules]:module' \
+ '--g-fatal-warnings[Make all warnings fatal]' \
+ '1: :_gtk-launch-apps' \
+ '*:: :_files' && ret=0
+ else
+ # gtk4-launch
+ _arguments -S -A "-*" \
+ '(- *)'{-h,--help}'[Show help options]' \
+ '(- *)'{-v,--version}'[Show program version]' \
+ '1: :_gtk-launch-apps' \
+ '*:: :_files' && ret=0
+ fi
- _values -w \
- 'applications' \
- $applications
+ return ret
}
-_format_entry() {
- echo "`_remove_path_extension $1`[`_get_description $1`]"
+(( $+functions[_gtk-launch-apps] )) ||
+_gtk-launch-apps() {
+ local -a apps=(/usr/share/applications/*.desktop(:r:t))
+ _values 'applications' $apps
}
-_remove_path_extension() {
- # echo arg
- # remove path string
- # remove extension string
- echo $1 | \
- sed 's/.*\///' | \
- sed 's/\.desktop//'
-}
-
-_get_description() {
- # grep --no-messages option is handling of not UTF-8 text
- grep --no-messages '^Comment=\|^Exec=' $1 | \
- tr '\n' ' '
-}
+_gtk-launch "$@"
# Local Variables:
# mode: Shell-Script