File indexing completed on 2024-05-12 17:08:26
0001 #compdef plasmoidviewer 0002 0003 # SPDX-FileCopyrightText: 2022 ivan tkachenko <me@ratijas.tk> 0004 # 0005 # SPDX-License-Identifier: GPL-2.0-or-later 0006 0007 # keep this function in sync with plasmashell from plasma-workspace 0008 function _plasma_list_packages() { 0009 local expl global_dir descr="$1" purpose="$2" type="${3:-Plasma/Applet}" 0010 local -a packages containments 0011 # Then strip " -- " prefix and " *" suffix (i.e. everything after and including first whitespace). 0012 # (@) array Expansion Flags are needed because we need to operate on each element separately. 0013 packages=( ${(f)"$( 0014 _call_program plasma-list-packages \ 0015 kpackagetool5 --type "$type" --list --global 0016 )"} ) 0017 # First line is an output header, it contains path where plugins are probed. 0018 global_dir="${${${packages[1]}##* in }%/}" 0019 packages[1]=() 0020 0021 if [[ "$purpose" == "containment" ]]; then 0022 # No need to get jq involved. We simply look for a magic string, which 0023 # hopefully won't be named literally in any other irrelevant field. 0024 containments=( ${${${(f)"$( 0025 # Glob Qualifiers (.) and (@r) match plain files and readable symbolic links; 0026 # (N) sets the NULL_GLOB option for the current pattern, so it doesn't print 0027 # an error for non-existent and empty directories. 0028 grep --files-with-matches -R "Plasma/Containment" $global_dir/*/metadata.json(N.,@r) 0029 )"}#$global_dir/}%/metadata.json} ) # strip back prefix and suffix 0030 packages=( $containments ) # directory name is the package id 0031 else 0032 # Don't filter containments out in an 'else' branch: they might be perfectly 0033 # executable applets on their own, e.g. org.kde.plasma.folder view. 0034 fi 0035 0036 _wanted "$descr" expl "$purpose" \ 0037 compadd -a packages 0038 } 0039 0040 _arguments \ 0041 '(-c --containment)'{-c=,--containment=}'[override containment package id]::: _plasma_list_packages containments containment' \ 0042 '(-a --applet)'{-a=,--applet=}'[applet package id]::: _plasma_list_packages applets applet' \ 0043 '(-f --formfactor)'{-f=,--formfactor=}'[form factor]:form-factor:(horizontal vertical mediacenter planar application)' \ 0044 '(-l --location)'{-l=,--location=}'[location constraint]::location:(floating desktop fullscreen topedge bottomedge leftedge rightedge)' \ 0045 '(-x --xPosition)'{-x=,--xPosition=}'[set window x position on screen]:::_numbers' \ 0046 '(-y --yPosition)'{-y=,--yPosition=}'[set window y position on screen]:::_numbers' \ 0047 '(-s --size)'{-s=,--size=}'[set window size]:size widthXheight:' \ 0048 '(-p --pixmapcache)'{-p=,--pixmapcache=}'[size (in kB) of the pixmap cache]:size in kB::_numbers' \ 0049 '(-t --theme)'{-t=,--theme=}'[override theme which the shell will use]::: _plasma_list_packages themes theme Plasma/Theme' \ 0050 '(-)'{-h,--help}'[print usage information and exit]' \ 0051 '(-)'{-v,--version}'[displays version information]'