├── BETA-TMP ├── Korora-dir-list ├── LICENSE ├── ListDefaultPath.txt ├── README.md ├── lsdesktopf ├── lsdesktopf_NO_EVN_VARIABLES ├── man-page.test ├── man-page.zh_CN-Updated by Yuking.txt ├── man-page.zh_CN.txt └── man-page.zh_TW.txt /BETA-TMP: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Version 1.0.4-3 3 | # 4 | # License: GPL3 5 | # 6 | # Author: Andy Crowd 7 | # Tested in Arch Linux 8 | # Search in *.desktop for "Categories" and "Exec" 9 | # 10 | 11 | if [[ ! -z "$NO_COLOR" && "${NO_COLOR^^}" == "YES" ]];then 12 | DISABLE_COLORS="YES"; 13 | else 14 | DISABLE_COLORS="NO"; 15 | fi 16 | 17 | unset IFS 18 | IFS=" 19 | " 20 | One="$1" 21 | #Two="$2" 22 | AddCmd=($@); 23 | 24 | GlobalArray="/opt/share/ldf/sorted.test" 25 | LocalArray="$HOME/.ldf/sorted.test" 26 | 27 | ### The DefDskPath variable contains list of default folders 28 | if [[ ! -z "$DESKTOP_FILES" ]];then 29 | OLD_IFS="$IFS"; 30 | IFS=';'; 31 | tmp_DSK=($DESKTOP_FILES) 32 | DefDskPath=($DESKTOP_FILES); 33 | IFS="$OLD_IFS"; 34 | else 35 | DefDskPath+=("/etc/dynamic/launchers/scanner") 36 | DefDskPath+=("/etc/xdg/autostart") 37 | DefDskPath+=("/etc/xdg/xfce*/panel/launcher-*") 38 | DefDskPath+=("/lib/gnome-settings-daemon-*/gtk-modules") 39 | DefDskPath+=("/lib/libreoffice/share/xdg") 40 | DefDskPath+=("/usr/etc/xdg/autostart") 41 | DefDskPath+=("/usr/lib/gnome-settings-daemon-*/gtk-modules") 42 | DefDskPath+=("/usr/lib/libreoffice/share/xdg") 43 | DefDskPath+=("/usr/local/share/applications") 44 | DefDskPath+=("/usr/share/applications") 45 | DefDskPath+=("/usr/share/apps/kdm/programs") 46 | DefDskPath+=("/usr/share/apps/kdm/sessions") 47 | DefDskPath+=("/usr/share/apps/solid/actions") 48 | DefDskPath+=("/usr/share/autostart") 49 | DefDskPath+=("/usr/share/dist/desktop-files/default") 50 | DefDskPath+=("/usr/share/gdm/") 51 | #DefDskPath+=("/usr/share/gdm/autostart") 52 | #DefDskPath+=("/usr/share/gdm/autostart/LoginWindow") 53 | #DefDskPath+=("/usr/share/gdm/greeter/autostart") 54 | DefDskPath+=("/usr/share/gnome/autostart") 55 | DefDskPath+=("/usr/share/kde*") 56 | DefDskPath+=("/usr/share/mate/wm-properties") 57 | DefDskPath+=("/usr/share/mga/dm") 58 | DefDskPath+=("/usr/share/mimelnk/application") 59 | DefDskPath+=("/usr/share/mimelnk/chemical") 60 | DefDskPath+=("/usr/share/parole") 61 | #DefDskPath+=("/usr/share/parole/parole-plugins-*") 62 | DefDskPath+=("/usr/share/Thunar/sendto") 63 | DefDskPath+=("/usr/share/wayland-sessions") 64 | DefDskPath+=("/usr/share/xfce*/helpers") 65 | DefDskPath+=("/usr/share/xfce*/panel-plugins") 66 | DefDskPath+=("/usr/share/xfce*/panel/plugins") 67 | DefDskPath+=("/usr/share/xgreeters") 68 | DefDskPath+=("/usr/share/xsessions") 69 | DefDskPath+=("/etc/xdg/autostart") 70 | DefDskPath+=("/opt/teamviewer/tv_bin/desktop") 71 | DefDskPath+=("/opt/wine-staging/share/applications") 72 | DefDskPath+=("/usr/lib/gnome-settings-daemon-*.*/gtk-modules") 73 | DefDskPath+=("/usr/lib/libreoffice/share/xdg") 74 | DefDskPath+=("/usr/local/share/applications") 75 | DefDskPath+=("/usr/share/applications") 76 | DefDskPath+=("/usr/share/applications/inputmethods") 77 | DefDskPath+=("/usr/share/apps/solid/actions") 78 | DefDskPath+=("/usr/share/gnome/autostart") 79 | DefDskPath+=("/usr/share/hedgewars/Data/misc") 80 | DefDskPath+=("/usr/share/J*Z/Desktop/KDE") 81 | DefDskPath+=("/usr/share/J*Z/Desktop/Menu") 82 | DefDskPath+=("/usr/share/kde*/services") 83 | DefDskPath+=("/usr/share/kde*/services/phononbackends") 84 | DefDskPath+=("/usr/share/kde*/services/ServiceMenus") 85 | DefDskPath+=("/usr/share/kservices*") 86 | DefDskPath+=("/usr/share/kservices*/qimageioplugins") 87 | DefDskPath+=("/usr/share/kservicetypes*") 88 | DefDskPath+=("/usr/share/lirc/contrib") 89 | DefDskPath+=("/usr/share/mimelnk/application") 90 | DefDskPath+=("/usr/share/phoronix-test-suite/pts-core/static") 91 | DefDskPath+=("/usr/share/Quamachi/Desktop/Menu") 92 | DefDskPath+=("/usr/share/speech-dispatcher/conf/desktop") 93 | DefDskPath+=("/usr/share/themes/") 94 | DefDskPath+=("/usr/share/Thunar/sendto") 95 | DefDskPath+=("/usr/share/xfce*/helpers") 96 | DefDskPath+=("/usr/share/xfce*/panel-plugins") 97 | DefDskPath+=("/usr/share/xfce*/panel/plugins") 98 | DefDskPath+=("/usr/share/xsessions") 99 | fi 100 | ########################################## 101 | AddKorora(){ 102 | DefDskPath+=("/usr/lib64/gnome-settings-daemon-*/gtk-modules") 103 | DefDskPath+=("/usr/lib64/libreoffice/share/xdg") 104 | DefDskPath+=("/usr/share/akonadi/agents") 105 | DefDskPath+=("/usr/share/anaconda/gnome") 106 | DefDskPath+=("/usr/share/applications") 107 | DefDskPath+=("/usr/share/applications/kde*") 108 | DefDskPath+=("/usr/share/carddecks") 109 | # DefDskPath+=("/usr/share/doc") 110 | DefDskPath+=("/usr/share/gcompris") 111 | DefDskPath+=("/usr/share/gdm/autostart/LoginWindow") 112 | DefDskPath+=("/usr/share/kcm_componentchooser") 113 | DefDskPath+=("/usr/share/kcmsolidactions") 114 | DefDskPath+=("/usr/share/kf*/kmoretools/presets-kmoretools") 115 | DefDskPath+=("/usr/share/kf*/locale/countries") 116 | DefDskPath+=("/usr/share/kf*/locale/currency") 117 | DefDskPath+=("/usr/share/khelpcenter/plugins") 118 | DefDskPath+=("/usr/share/khelpcenter/searchhandlers") 119 | DefDskPath+=("/usr/share/kio_desktop") 120 | DefDskPath+=("/usr/share/kmines/themes") 121 | DefDskPath+=("/usr/share/konqsidebartng/virtual_folders/remote") 122 | DefDskPath+=("/usr/share/konqsidebartng/virtual_folders/services") 123 | DefDskPath+=("/usr/share/konqueror/dirtree/remote") 124 | DefDskPath+=("/usr/share/konversation/themes") 125 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_energyinfo") 126 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_fileindexermonitor") 127 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_lookandfeel") 128 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_splashscreen") 129 | DefDskPath+=("/usr/share/kpat/themes") 130 | DefDskPath+=("/usr/share/kservicetypes*") 131 | DefDskPath+=("/usr/share/ksmserver/screenlocker/org.kde.passworddialog") 132 | DefDskPath+=("/usr/share/ksmserver/themes") 133 | DefDskPath+=("/usr/share/ksmserver/windowmanagers") 134 | DefDskPath+=("/usr/share/ksysguard/scripts/smaps") 135 | DefDskPath+=("/usr/share/kwin/decorations/kwin*_decoration_qml_plastik") 136 | DefDskPath+=("/usr/share/kwin/desktoptabbox/previews") 137 | DefDskPath+=("/usr/share/kwin/effects") 138 | DefDskPath+=("/usr/share/kwin/scripts") 139 | DefDskPath+=("/usr/share/kwin/tabbox") 140 | DefDskPath+=("/usr/share/kxmlgui*/parley/themes") 141 | DefDskPath+=("/usr/share/lirc/contrib") 142 | DefDskPath+=("/usr/share/locale/") 143 | #DefDskPath+=("/usr/share/locale/l10n") 144 | DefDskPath+=("/usr/share/parley/plugins") 145 | DefDskPath+=("/usr/share/parley/themes") 146 | DefDskPath+=("/usr/share/plasma/desktoptheme") 147 | DefDskPath+=("/usr/share/plasma/kcms/screenlocker_kcm") 148 | DefDskPath+=("/usr/share/plasma/layout-templates") 149 | DefDskPath+=("/usr/share/plasma/look-and-feel") 150 | DefDskPath+=("/usr/share/plasma/packages") 151 | DefDskPath+=("/usr/share/plasma/plasmoids") 152 | DefDskPath+=("/usr/share/plasma/shareprovider") 153 | DefDskPath+=("/usr/share/plasma/shells") 154 | DefDskPath+=("/usr/share/plasma/wallpapers") 155 | DefDskPath+=("/usr/share/remoteview") 156 | DefDskPath+=("/usr/share/sddm/themes") 157 | DefDskPath+=("/usr/share/services") 158 | DefDskPath+=("/usr/share/solid/actions") 159 | DefDskPath+=("/usr/share/solid/devices") 160 | DefDskPath+=("/usr/share/soprano/plugins") 161 | DefDskPath+=("/usr/share/templates") 162 | DefDskPath+=("/usr/share/wallpapers") 163 | DefDskPath+=("/usr/share/yumex-dnf") 164 | } 165 | ########################################## 166 | ### Uncomment below to add directories found in Korora Linux 167 | #AddKorora 168 | ##### 169 | if [[ ! -f "$LocalArray" ]];then 170 | if [[ -f "$GlobalArray" ]];then 171 | FilePath="$GlobalArray" 172 | 173 | else 174 | ### ADskPath contains list of "decoded" path with command "file" 175 | ### command "file" can handle wildcards such as * that is useful when it is multiple or new path with versions number is available 176 | ### command "grep" is used to separate available from not existing path 177 | #for FromDDP in "${DefDskPath[@]}";do 178 | #if [[ ! -z "$FromDDP" ]];then 179 | # echo "$FromDDP" 180 | #fi 181 | #done; 182 | #exit 0 183 | ADskPath=($(for FromDDP in "${DefDskPath[@]}";do 184 | #echo '/usr/share/applications' 185 | if [[ ! -z "$(echo $FromDDP| grep -v "^\ ")" ]];then 186 | file "$FromDDP" 187 | fi 188 | done |\ 189 | sort -u |\ 190 | grep -v -e \)$ -e ^$ |\ 191 | grep ^/ |\ 192 | rev|\ 193 | cut -d: -f2- |\ 194 | rev)) 195 | #################### 196 | fi 197 | else 198 | FilePath="$LocalArray" 199 | fi 200 | if [[ "${#ADskPath[@]}" == 0 ]]; then 201 | ADskPath=($(sed -i -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' "$FilePath"; 202 | while read FromFile;do echo "$FromFile" ; 203 | done < "$FilePath"|\ 204 | xargs file|\ 205 | sort -u |\ 206 | grep -v \)$ |\ 207 | grep ^/ |\ 208 | rev|\ 209 | cut -d: -f2-|\ 210 | rev)); 211 | ### $BDskPath is used to add path that depends on such variables as $HOME and $XDG related 212 | BDskPath+=("$HOME/.local/share/applications") 213 | BDskPath+=("$HOME/.config/autostart") 214 | BDskPath+=("/home/$USER/.local/share/applications") 215 | BDskPath+=("/home/$USER/.config/autostart") 216 | 217 | # BDskPath+=("$XDG_CONFIG_DIRS/autostart") 218 | BDskPath+=("$XDG_CONFIG_HOME/autostart") 219 | BDskPath+=("$HOME/.local/share/xfce*/helpers") 220 | BDskPath+=("/home/$USER/.local/share/xfce*/helpers") 221 | BDskPath+=("$XDG_DATA_HOME/applications") 222 | ############# 223 | 224 | 225 | # BDskPath+=("$HOME/.local/share") 226 | # if [[ -f "$HOME/.config/user-dirs.dirs" ]];then 227 | # BPath="$(grep XDG_DESKTOP_DIR ./.config/user-dirs.dirs | cut -d= -f2- | sed -e 's/^\"//' -e 's/\"$//' )" 228 | # BDskPath+=("$BPath") 229 | # else 230 | # if [[ -f "$XDG_CONFIG_DIRS/user-dirs.dirs" ]];then 231 | # BDskPath+=("$(grep XDG_DESKTOP_DIR "$XDG_CONFIG_DIRS/user-dirs.dirs"|cut -d= -f2-|sed -e 's/^\"//' -e 's/\"$//' )") 232 | # [[ ! -z "$DesktopDir" ]] && BDskPath="$DesktopDir" 233 | # fi 234 | # fi 235 | 236 | fi 237 | #ADskPath+="$AddWithVariables"; 238 | 239 | for AddWithVariables in "${BDskPath[@]}"; do 240 | if [ -d "$AddWithVariables" ];then 241 | ADskPath+=("$AddWithVariables"); 242 | 243 | fi 244 | done 245 | #echo "${NoEmpty[@]}" 246 | #echo "${DefDskPath[@]}" 247 | #exit 1 248 | ### soring out only uniq path in case if $XDG related and $HOME are pointing on a similar destination. || $InDskPath, $ADskPath, NoEmpty 249 | NoEmpty=($(for InDskPath in "${ADskPath[@]}";do echo "$InDskPath";done|sort -u;)); 250 | 251 | ### used to find out path that can be used || scan-sys-path, $DskPath, NoEmpty 252 | ReCreateDskPath(){ 253 | case "$Opts" in 254 | OnlyNew1 ) 255 | DskPath=($(if [[ ! -z $2 ]]; then 256 | for StartCmdLine in "$@"; 257 | do 258 | if [[ -d "$StartCmdLine" ]]; then 259 | InPath="$StartCmdLine" 260 | fi 261 | find "$InPath" -type f -name "*\.desktop" -exec dirname "{}" \;|sort -u 262 | 263 | if [[ "$InPath" == "/" ]];then 264 | exit 0 265 | fi 266 | done 267 | else 268 | find / -type f -name "*\.desktop" -exec dirname "{}" \; |sort -u 269 | fi)) 270 | ;; 271 | scan-sys-path ) 272 | DskPath=($(find "/usr/" "/etc/" "/opt/" -type f -name "*\.desktop" -exec dirname "{}" \;|sort -u)) 273 | ;; 274 | *) 275 | DskPath=(${NoEmpty[@]}) 276 | ;; 277 | esac 278 | } 279 | ######################################## 280 | gdxstdalone(){ 281 | IFS=" 282 | " 283 | case $2 in 284 | g | glob ) 285 | List_XML=($(find "/usr/" "/etc/" "$HOME/.local/" "$HOME/.config" -type f -name "*\.xml")); 286 | ;; 287 | l | local ) 288 | List_XML=($(find "$HOME/.config" "$HOME/.local/" -type f -name "*\.xml")); 289 | ;; 290 | * ) 291 | List_XML=($(find "/usr/share/mime/packages/" "/usr/share/mime/application/" "$HOME/.local/share/" -type f -name "*\.xml")); 292 | ;; 293 | esac 294 | 295 | case $2 in 296 | 0 ) 297 | for In_XML_List in "${List_XML[@]}";do 298 | find "$In_XML_List" -type f -name "*\.xml" -exec grep -e "mime-type" -e "type=" "{}" \; 299 | done | awk -v CLR="$DISABLE_COLORS" -F"\"" '{ 300 | if(index($0,"mime-type")){ 301 | if(index($0,"type type=")){ 302 | ContentArray[$2]=1; 303 | }else{ 304 | if(index($0," type=")){ 305 | ContentArray[$4]=1}}}}END{for (I in ContentArray)print I}' 306 | ;; 307 | 1 ) 308 | for In_XML_List in "${List_XML[@]}";do 309 | find "$In_XML_List" -type f -name "*\.xml" -exec grep -e "mime-type" -e "type=" "{}" \; 310 | done | awk -v CLR="$DISABLE_COLORS" -F"\"" '{ 311 | if(index($0,"mime-type")){ 312 | if(index($0,"type type=")){ 313 | A=substr($2,0,index($2,"/")-1); 314 | ContentArray[A]=1; 315 | }else{ 316 | if(index($0," type=")){ 317 | B=substr($4,0,index($4,"/")-1); 318 | ContentArray[B]=1}}}}END{for (I in ContentArray)print I}' 319 | ;; 320 | 2 ) 321 | for In_XML_List in "${List_XML[@]}";do 322 | find "$In_XML_List" -type f -name "*\.xml" -exec grep -e "mime-type" -e "type=" "{}" \; 323 | done | awk - -v CLR="$DISABLE_COLORS" F"\"" '{ 324 | if(index($0,"mime-type")){ 325 | if(index($0,"type type=")){ 326 | A=substr($2,index($2,"/")+1); 327 | ContentArray[A]=1; 328 | }else{ 329 | if(index($0," type=")){ 330 | B=substr($4,index($4,"/")+1); 331 | ContentArray[B]=1}}}}END{for (I in ContentArray)print I}' 332 | ;; 333 | 3 ) 334 | for In_XML_List in "${List_XML[@]}";do 335 | find "$In_XML_List" -type f -name "*\.xml" -exec grep "pattern=" "{}" \; 336 | done | awk -v CLR="$DISABLE_COLORS" -F"\"" '{ 337 | if(index(tolower($0),"pattern="))ContentArray[$2]=1; 338 | }END{ 339 | for (I in ContentArray)print I 340 | }' 341 | ;; 342 | -gfx) 343 | for In_XML_List in "${List_XML[@]}";do 344 | find "$In_XML_List" -type f -name "*\.xml" -exec awk -v CLR="$DISABLE_COLORS" -v ShowItems="$3" '{ 345 | if(index($0,"") != 0){Astop=2;YES=0; 352 | ShowMIME=""; 353 | ShowSubClass=""; 354 | ShowGenericIcon=""; 355 | ShowAcronym=""; 356 | ShowEAcronym=""; 357 | ShowAlias=""; 358 | GAcal=0; 359 | }; 360 | if(Astop == 1) 361 | { 362 | if(index($0,"") == 0 && index($0,"") != 0) 372 | { 373 | Acomment=substr(SP,index(SP,"")+9); 374 | Bcomment=substr(Acomment,0,index(Acomment,"")-1); 375 | } 376 | else 377 | { 378 | Acomment=substr(SP,index(SP,"")-1); 380 | Bcomment=substr(TMPcomment,index(Acomment,">")+1); 381 | }; 382 | if(index(SP,"")-2); 386 | gsub(/ type=/,"Sub class of: ",EndTagSSC); 387 | ShowSubClass=EndTagSSC; 388 | } 389 | if(index(SP,"")-2); 393 | gsub(/ name=/,"Icon: ",EndTagGI); 394 | ShowGenericIcon=EndTagGI; 395 | } 396 | if(index(SP,"") != 0) 397 | { 398 | StartTagAcr=substr(SP,index(SP,"")+9) 399 | EndTagAcr=substr(StartTagAcr,0,index(StartTagAcr,"/")-2); 400 | ShowAcronym=EndTagAcr; 401 | } 402 | if(index(SP,"") != 0) 403 | { 404 | StartTagEAcr=substr(SP,index(SP,"")+18) 405 | EndTagEAcr=substr(StartTagEAcr,0,index(StartTagEAcr,"/")-2); 406 | ShowEAcronym=EndTagEAcr; 407 | } 408 | if(index(SP,"")-2); 412 | gsub(/ type=/,"Alias: ",EndTagAlias); 413 | ShowAlias=EndTagAlias; 414 | }; 415 | for(I=0; I <= NumPatt;I++) 416 | { 417 | GetStr=substr(GG[I],0,index(GG[I],"\"/>")); 418 | if(index(GetStr,"=") == 1 ){printf substr(GetStr,2); 419 | if(length(Bcomment) == 0){printf " ----- %s",ShowMIME}else{printf " ----- %s",Bcomment}; 420 | if(length(ShowMIME) == 0 && length(Bcomment) == 0) 421 | { 422 | AnewMIME=substr(AltFix,index(AltFix,"mime-type")+1); 423 | BnewMIME=substr(AnewMIME,0,index(AnewMIME,">")-1); 424 | CnewMIME=substr(BnewMIME,index(BnewMIME,"type=\"")+5); 425 | printf CnewMIME; 426 | }; 427 | NumberItems=split(ShowItems,ArrayItems,","); 428 | ShowFileName=FILENAME; 429 | for( getItem in ArrayItems){ 430 | if(ArrayItems[getItem] == "sf" && ShowFileName ){ 431 | if(CLR == "YES"){ 432 | if(CLR == "YES") 433 | { 434 | printf " @* %s",ShowFileName;ShowFileName=""; 435 | }else{ 436 | printf " @*\033[2;32m %s",ShowFileName"\033[0m";ShowFileName=""; 437 | } 438 | }else{ 439 | printf " @* %s",ShowFileName"";ShowFileName=""; 440 | } 441 | 442 | } 443 | if(ArrayItems[getItem] == "sm" && ShowMIME ) 444 | { 445 | if(CLR == "YES"){ 446 | printf " @* %s",ShowMIME; 447 | }else{ 448 | printf " @*\033[2;93m %s",ShowMIME"\033[0m"; 449 | } 450 | } 451 | if(ArrayItems[getItem] == "ssc" && ShowSubClass) 452 | { 453 | if(CLR == "YES"){ 454 | printf " @* " %s",ShowSubClass;ShowSubClass=""; 455 | }else{ 456 | printf " @*\033[2;53m %s",ShowSubClass"\033[0m";ShowSubClass=""; 457 | } 458 | } 459 | if(ArrayItems[getItem] == "sgi" && ShowGenericIcon) 460 | { 461 | if(CLR == "YES"){ 462 | printf " @* %s",ShowGenericIcon;ShowGenericIcon="" 463 | }else{ 464 | printf " @*\033[2;49m %s",ShowGenericIcon"\033[0m";ShowGenericIcon="" 465 | } 466 | } 467 | if(ArrayItems[getItem] == "sa" && ShowAcronym) 468 | { 469 | if(CLR == "YES"){ 470 | printf " @* %s",ShowAcronym;ShowAcronym="" 471 | }else{ 472 | printf " @*\033[2;49m %s",ShowAcronym"\033[0m";ShowAcronym="" 473 | } 474 | } 475 | if(ArrayItems[getItem] == "sea" && ShowEAcronym) 476 | { 477 | if(CLR == "YES"){ 478 | printf " @* %s",ShowEAcronym;ShowEAcronym="" 479 | }else{ 480 | printf " @*\033[2;49m %s",ShowEAcronym"\033[0m";ShowEAcronym="" 481 | } 482 | } 483 | if(ArrayItems[getItem] == "sal" && ShowAlias) 484 | { 485 | TotalAliases=split(SP,GetAliasStart,"")-2); 495 | }; 496 | if(TotalAliases >= 0)for (II in GetAls) 497 | if(index(GetAls[II],"<") <= index(GetAls[II],"/>") ) 498 | printf substr(GetAls[II],index(GetAls[II],"=")+1)";"; 499 | delete GetAls; 500 | if(CLR != "YES")printf "\033[0m" 501 | } 502 | } 503 | printf "\n";} 504 | } 505 | SP=1} 506 | }' "{}" \; 507 | done 508 | ;; 509 | -gx ) if [[ ! -z "$3" ]];then 510 | for In_XML_List in "${List_XML[@]}";do 511 | find "$In_XML_List" -type f -name "*\.xml" -exec grep -e "mime-type" -e "type=" "{}" \; 512 | done | awk -v CLR="$DISABLE_COLORS" -F"\"" -v FindForType="$3" '{ 513 | if(index($0,"mime-type")){ 514 | if(index($0,"type type=")){ 515 | A=substr($2,index($2,"/")+1); 516 | if(FindForType == substr($2,0,index($2,"/")-1)) 517 | ContentArray[A]=1; 518 | }else{ 519 | if(index($0," type=")){ 520 | B=substr($4,index($4,"/")+1); 521 | if(FindForType == substr($2,0,index($2,"/")-1)) 522 | ContentArray[B]=1 523 | }}}}END{for (I in ContentArray)print I}' 524 | else 525 | echo 'Missing options! Use first part of MIME-type,e.g. inode' 526 | fi 527 | ;; 528 | *) 529 | for In_XML_List in "${List_XML[@]}";do 530 | find "$In_XML_List" -type f -name "*\.xml" -print0 | xargs -0 awk -v CLR="$DISABLE_COLORS" -F"\"" '{YesM=0; 531 | if(index($0,"mime-type")){if(index($0,"type type=")){ContentArray[Count++]=$2" == ";YesM=1}else{if(index($0," type=")){ 532 | ContentArray[Count++]=$4" == "}}} 533 | if(index($0,"")){ 534 | GetString=substr($0,index($0,">")+1) 535 | GetTMP=" "substr(GetString,0,index(GetString,"= 1) Ctgr=substr($0,index($0,"=")+1); 582 | if(index($0,"Name=") == 1) inNm=substr($0,index($0,"=")+1); 583 | if(index($0,"Comment=") == 1) inComment=substr($0,index($0,"=")+1); 584 | if(index($0,"Command") == 1) inCmd=substr($0,index($0,"=")+1) ; 585 | if(index($0,"Module=") == 1) inExc=substr($0,index($0,"=")+1); 586 | if(index($0,"Exec=") == 1) inExc=substr($0,index($0,"=")+1); 587 | if(index($0,"Category=") >= 1) Ctgr=substr($0,index($0,"=")+1); 588 | if(index($0,"X-XFCE-Binaries=") >= 1) inExc=substr($0,index($0,"=")+1); 589 | }END{ 590 | if(! Ctgr ){E=inNm}else{E=Ctgr}; 591 | if(! inExc){CmdLine=inCmd}else{CmdLine=inExc}; 592 | if(! E)E=inComment; 593 | Z=CmdLine" # "E" # "Fil; 594 | if( index(tolower(Z),tolower(Seek)) && CmdLine ) print Z;}' "{}" \; 595 | else 596 | [[ -d "${fdPath}" || -f "${fdPath}" ]] && find "${fdPath}" -iname "*.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v Fil="{}" -F"=" '//{ 597 | if(index($0,"Categories") == 1) Ctgr=substr($0,index($0,"=")+1); 598 | if(index($0,"Name=") == 1) inNm=substr($0,index($0,"=")+1); 599 | if(index($0,"Exec=") == 1) inExc=substr($0,index($0,"=")+1); 600 | if(index($0,"Comment=") == 1) inComment=substr($0,index($0,"=")+1); 601 | if(index($0,"Command=") == 1) inCmd=substr($0,index($0,"=")+1) ; 602 | if(index($0,"Category=") >= 1) Ctgr=substr($0,index($0,"=")+1); 603 | if(index($0,"X-XFCE-Binaries=") >= 1) inExc=substr($0,index($0,"=")+1); 604 | }END{ 605 | if(! Ctgr ){E=inNm}else{E=Ctgr}; 606 | if(! inExc){CmdLine=inCmd}else{CmdLine=inExc}; 607 | if(! E)E=inComment; 608 | Z=CmdLine" # "E" # "Fil" # "XFCEb; 609 | if(CmdLine)print Z;}' "{}" \; 610 | fi; 611 | fi 612 | done 613 | } 614 | ################### Search specific #### 615 | OffPrint="no"; 616 | SearchContentOfVariable(){ 617 | for fdPath in "${DskPath[@]}";do 618 | if [[ -d "${DskPath[Count]}" || -f "${DskPath[Count]}" ]]; 619 | then 620 | if [[ "$OffPrint" == "no" ]]; then 621 | if [[ "$DISABLE_COLORS" == "YES" ]];then 622 | printf "# %s ${fdPath} \n"; 623 | else 624 | printf "#\e[1;36m %s ${fdPath} \e[0m \n"; 625 | fi 626 | fi 627 | if [ ! -z "$One" ] && [[ -d "${fdPath}" || -f "${fdPath}" ]] ; 628 | then 629 | case $Opts in 630 | ### "$var" is used to search for variable names with "grep" in *.desktop 631 | var ) 632 | grep -e ^"$Var" "${AddCmd[@]:2}" -H -E -R --include "*\.desktop" "${fdPath}" 633 | ;; 634 | ### "ddp" is used to raw dump cotent of all *.desktop found in default path. || grep 635 | ddp ) 636 | grep ^ -H -R --include "*\.desktop" "${fdPath}" 637 | ;; 638 | ### "sud" showing uniq variables found in default path. || grep, cut 639 | sud ) 640 | grep '=' -R -h --include "*\.desktop" "${fdPath}"|cut -d= -f 1|grep -v -e "\[" -e ^\# |sort -u 641 | ;; 642 | ### "no-var" showing all *.desktop except them that contains contains specified string. || grep, find 643 | no-var ) 644 | find "${fdPath}" -type f -iname "*\.desktop" -exec grep -H -L -e "$Var" "${AddCmd[@]:2}" "{}" \; 645 | ;; 646 | ### "sdsn" showing only uniq section names found in default path. || grep, sed 647 | sdsn ) 648 | grep '\[*\]'$ -R -h --include "*\.desktop" "${fdPath}" | sed 's/ * //m' |grep ^'\[' |grep -v -e ^'#' -e '\]=' |sort -u 649 | ;; 650 | upfd ) 651 | if [[ ! -z "$2" ]];then FLang="$2"; 652 | else 653 | FLang=""; 654 | fi 655 | 656 | find "${fdPath}" -type f -name "*\.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v GetLang="$FLang" -v ShowAvailableLanguages="$3" -F= '//{ 657 | if(index($1,"[") != 0 && index($1,"[") != 1 ){split($1,Lang,"[")UniqLang[Lang[2]]++}; 658 | if(index($1,"["GetLang"]") != 0 ){Item[cnt++]=$0}else { if(index($1,"]") == 0)Item[cnt++]=$0} 659 | }END{ 660 | if (CLR == "YES") 661 | { 662 | printf "* %s",FILENAME"\n"; 663 | }else{ 664 | printf "* \033[2;32m %s",FILENAME"\033[2;0m \n"; 665 | }; 666 | print "@ Total translations: "length(UniqLang); 667 | if(ShowAvailableLanguages)if(ShowAvailableLanguages == "all")if(length(UniqLang) != 0 ) 668 | { 669 | for(AllLang in UniqLang){sub("]","",AllLang); 670 | printf "%s",AllLang","};print "." 671 | }; 672 | for (ItemNumber in Item)print Item[ItemNumber]; 673 | }' "{}" \; | grep -v ^"\#" 674 | ;; 675 | more ) 676 | find "${fdPath}" -type f -name "*\.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v FindIt="$2" -F= '/^create/;{ 677 | ToLowerOne=tolower($1); 678 | ToLowerFindIt=tolower(FindIt); 679 | ToLowerTwo=tolower($2); 680 | if(index($1,"]") == 0 ) 681 | if( index(ToLowerOne,"exec") != 0 || index(ToLowerOne,"name") != 0 || index(ToLowerOne,"comment") != 0 || index(ToLowerOne,"categories") != 0 || index(ToLowerOne,"command") != 0 || index(ToLowerOne,"module") != 0 || index(ToLowerOne,"x-xfce-binaries") != 0 ) {Var[CountV++]=$1;InString[CountS++]=substr($0,index($0,$2)); 682 | if(FindIt)if( index($1,"Exec") != 0 || index($1,"Exec") != 0 || index($1,"Name") != 0 || index($1,"Comment") != 0 || index($1,"Categories") != 0 || index($1,"Command") != 0 || index($1,"Module") != 0 || index($1,"X-XFCE-Binaries") != 0 )if(index(ToLowerTwo,ToLowerFindIt) != 0 )YES="1"; }; 683 | }END{ 684 | if(YES == "1" ) 685 | { 686 | if(CLR == "YES") 687 | { 688 | printf "* "FILENAME"\n"; 689 | }else{ 690 | printf "* \033[2;32m"FILENAME"\033[2;0m \n"; 691 | }; 692 | for(I in InString)if(length(Var[I]) != 0)print Var[I]"="InString[I] 693 | }; 694 | if(length(FindIt) == 0) 695 | { 696 | if(CLR == "YES") 697 | { 698 | printf "* "FILENAME" \n"; 699 | }else{ 700 | printf "* \033[2;32m "FILENAME"\033[2;0m \n"; 701 | }; 702 | 703 | for(I in InString)if(length(Var[I]) != 0)print Var[I]"="InString[I] 704 | } 705 | }' "{}" \;|grep -v -e ^"#" -e ^$ 706 | ;; 707 | # more ) 708 | # find "${fdPath}" -type f -name "*\.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v FindIt="$2" -F= '/^create/;{ 709 | # if(index($1,"]") == 0 && index($1,"MimeType") == 0 && index($1,"Keywords") == 0){Var[CountV++]=$1;InString[CountS++]=substr($0,index($0,$2)); 710 | # if(FindIt)if(index($2,FindIt) != 0 && index($1,"MimeType") == 0 && index($1,"Keywords") == 0)YES="1"; };}END{ 711 | # if(YES == "1" ){print " "FILENAME; for(I in InString)if(length(Var[I]) != 0)print Var[I]"="InString[I]}; 712 | # if(length(FindIt) == 0){print " "FILENAME;for(I in InString)if(length(Var[I]) != 0)print Var[I]"="InString[I]}}' "{}" \;|grep -v -e ^"#" -e ^$ 713 | # ;; 714 | 715 | less ) 716 | find "${fdPath}" -type f -name "*\.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v FindIt="$2" -v Trans="$3" -F= '/^create/;{ 717 | ToLowerTwo=tolower($2); 718 | ToLowerFindIt=tolower(FindIt); 719 | if(Trans) 720 | { 721 | split(Trans,ArrayTransLang,","); 722 | for(ReLangArray in ArrayTransLang )NewArrTrans[ArrayTransLang[ReLangArray]]=1; 723 | } 724 | if(index($1,"]") == 0) 725 | { 726 | Var[CountV++]=$1; 727 | InString[CountS++]=substr($0,index($0,$2)); 728 | if(FindIt)if(index(ToLowerTwo,ToLowerFindIt) != 0)YES="1"; 729 | }; 730 | if(index($1,"[") != 0 && index($1,"[") != 1 ){ 731 | split($1,Lang,"["); 732 | TmpLang=Lang[2]; 733 | UniqLang[TmpLang]++; 734 | sub("]","",TmpLang); 735 | if(Trans) 736 | { 737 | if( NewArrTrans[TmpLang] == 1 ) 738 | { 739 | Var[CountV++]=$1; 740 | InString[CountS++]=substr($0,index($0,$2)) 741 | } 742 | } 743 | }; 744 | if(index($1,"[") == 1){ 745 | Var[CountV++]=$1; 746 | InString[CountS++]=$0} 747 | }END{ 748 | if(YES == "1" ) 749 | { 750 | if(CLR == "YES") 751 | { 752 | printf "* " FILENAME " @ Total translations: "length(UniqLang)": "; 753 | }else{ 754 | printf "* \033[2;32m" FILENAME "\033[0m\n @ Total translations: "length(UniqLang)": "; 755 | } 756 | if(length(UniqLang) != 0)for(AllLang in UniqLang){sub("]","",AllLang);printf "%s",AllLang",";} 757 | print " "; 758 | for (I in InString)if(index(Var[I],"[") != 1 && length(Var[I]) != 0 && index(Var[I],"#") != 1 ) 759 | { 760 | if(index(InString[I]"=",Var[I]"=") != 1 ) 761 | { 762 | print Var[I]"="InString[I] 763 | } 764 | else 765 | { 766 | print Var[I]"=" 767 | } 768 | } 769 | else 770 | { 771 | if(index(Var[I],"[") == 1) 772 | 773 | if(CLR == "YES") 774 | { 775 | printf Var[I]"\n" 776 | }else{ 777 | printf "\033[2;33m"Var[I]"\033[2;0m\n" 778 | } 779 | } 780 | } 781 | if(length(FindIt) == 0) 782 | { 783 | if(CLR == "YES") 784 | { 785 | printf "* " FILENAME " \n@ Total translations: "length(UniqLang)": "; 786 | }else{ 787 | printf "* \033[2;32m" FILENAME "\033[0m \n@ Total translations: "length(UniqLang)": "; 788 | } 789 | if(length(UniqLang) != 0)for(AllLang in UniqLang) 790 | { 791 | sub("]","",AllLang);printf "%s",AllLang","; 792 | } 793 | print " "; 794 | for (I in InString) 795 | if(index(Var[I],"[") != 1 && length(Var[I]) != 0 && index(Var[I],"#") != 1 ) 796 | { 797 | if(index(InString[I]"=",Var[I]"=") != 1 ) 798 | { 799 | print Var[I]"="InString[I] 800 | } 801 | else 802 | { 803 | print Var[I]"=" 804 | } 805 | } 806 | else 807 | { 808 | if(index(Var[I],"[") == 1) 809 | if(CLR == "YES") 810 | { 811 | printf Var[I]"\n" 812 | }else{ 813 | printf "\033[2;33m"Var[I]"\033[2;0m \n" 814 | } 815 | } 816 | } 817 | }' "{}" \; 818 | ;; 819 | iov ) 820 | find "${fdPath}" -type f -name "*\.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v FindIt="$2" -v Fname="$3" -F= '//{ 821 | if(FindIt){ 822 | SizeArray=split(FindIt,ArrayFindIt,","); 823 | if (index($0,"[") == 1 ) 824 | YesFoundIt[CountFinds++]=$0; 825 | for(CountFindItArray in ArrayFindIt ) 826 | NewArrFindIt[ArrayFindIt[CountFindItArray]]=1; 827 | if(NewArrFindIt[$1] == 1 ) 828 | { 829 | YesFoundIt[CountFinds++]=$0; 830 | UniqFound[$1]=1; 831 | } 832 | } 833 | }END{ 834 | if( length(UniqFound) == SizeArray ) 835 | { 836 | if(Fname == "filename" || Fname == "fn" || Fname == "sf" || Fname == "--sf" ) 837 | if(CLR == "YES") 838 | { 839 | printf "* "FILENAME" \n"; 840 | }else{ 841 | printf "* \033[2;32m"FILENAME"\033[0m \n"; 842 | } 843 | for (GotFound in YesFoundIt ) 844 | { 845 | if(index(YesFoundIt[GotFound],"[") == 1 ) 846 | { 847 | if(CLR == "YES") 848 | { 849 | printf YesFoundIt[GotFound]"\n" 850 | }else{ 851 | printf "\033[2;33m"YesFoundIt[GotFound]"\033[0m \n" 852 | } 853 | } 854 | else 855 | { 856 | print YesFoundIt[GotFound]; 857 | } 858 | }; 859 | } 860 | }' "{}" \; 861 | 862 | ;; 863 | 864 | esac 865 | 866 | fi; 867 | fi 868 | done 869 | 870 | case "$Opts" in 871 | ### "sys-uniq" showing uniq variable names found in /usr /etc /opt path. || find, cut, grep 872 | sys-uniq ) 873 | find "/usr" "/etc" "/opt" -type f -name "*\.desktop" -exec grep ^ "{}" \; | cut -d= -f1 | grep -v -e "\[" -e ^\# | sort -u 874 | ;; 875 | ### "var-sys" searching for variable name in system path /usr /etc /opt 876 | var-sys ) 877 | grep -e ^"$Var" "${AddCmd[@]:2}" -H -E -R --include "*\.desktop" /usr /etc /opt 878 | ;; 879 | esac 880 | } 881 | ######################################## 882 | 883 | RawView(){ 884 | for fdPath in "${DskPath[@]}";do 885 | if [[ -d "${DskPath[Count]}" || -f "${DskPath[Count]}" ]]; 886 | then 887 | if [[ "$OffPrint" == "no" ]];then 888 | if [[ "$DISABLE_COLORS" == "YES" ]];then 889 | printf "# %s ${fdPath} \e \n"; 890 | else 891 | printf "#\e[1;36m %s ${fdPath} \e[0m \n"; 892 | fi 893 | fi 894 | if [ ! -z "$One" ] && [[ -d "${fdPath}" || -f "${fdPath}" ]] ; 895 | then 896 | [[ "$Opts" == "suo" ]] && grep ^ -R -h --include "*\.desktop" "${fdPath}"; 897 | fi; 898 | fi 899 | done | case $Opts in 900 | suo ) 901 | grep = |cut -d= -f1 |grep -v -e "\[" -e ^\#|sort -u 902 | ;; 903 | esac 904 | } 905 | 906 | ShowOrStartXsession(){ 907 | for FileName in /usr/share/xsessions/*;do 908 | X_Sessions+=("$(grep ^'Exec=' $FileName| cut -d= -f2-)"); 909 | X_Names+=("$(grep ^'Name=' $FileName| cut -d= -f2-)"' '); 910 | X_Comment+=("$(grep ^'Comment=' $FileName| cut -d= -f2-)"' '); 911 | X_DesktopNames+=("$(grep ^'DesktopNames=' $FileName| cut -d= -f2-)"' '); 912 | done 913 | CC=0; 914 | 915 | case $ToShowPart in 916 | n | name ) 917 | for ReadSessions in "${X_Names[@]}";do 918 | echo $CC $ReadSessions 919 | ((CC++)) 920 | done 921 | ;; 922 | c | comment ) 923 | for ReadSessions in "${X_Comment[@]}";do 924 | echo $CC $ReadSessions 925 | ((CC++)) 926 | done 927 | ;; 928 | dn | desktopname ) 929 | for ReadSessions in "${X_DesktopNames[@]}";do 930 | echo $CC $ReadSessions 931 | ((CC++)) 932 | done 933 | ;; 934 | a | all ) 935 | echo 'Number Name # Comment # Exec'; 936 | for ReadSessions in "${X_Sessions[@]}";do 937 | echo $CC ${X_Names[CC]} '#' ${X_Comment[CC]} '#' $ReadSessions; 938 | ((CC++)) 939 | done 940 | ;; 941 | *) 942 | for ReadSessions in "${X_Sessions[@]}";do 943 | echo $CC $ReadSessions 944 | ((CC++)) 945 | done 946 | ;; 947 | esac 948 | 949 | if [[ "$StartIt" == "1" ]];then 950 | echo 'Enter a session number:'; 951 | read Session_Number; 952 | if [[ "$Session_Number" =~ [0-9]+$ && "$Session_Number" -le "${#X_Sessions[@]}" ]];then 953 | 954 | if [[ "${X_Sessions[Session_Number]/\//}" == "${X_Sessions[Session_Number]}" ]];then 955 | startx /usr/bin/${X_Sessions[Session_Number]} 956 | else 957 | startx ${X_Sessions[Session_Number]} 958 | fi 959 | fi 960 | fi 961 | } 962 | 963 | ################### 964 | # Disabled options 965 | ################### 966 | #By using option "all" as 3rd option will show all available translations in a *.desktop file, 967 | # without it will show only amount of translations or additional variables with a chosen translation. 968 | # --uniq-per-file-default (lang) ("all") | --upfd : list variables found in default path 969 | # --uniq-per-file-sys (lang) ("all") | --upfs : list variables found in /usr /etc /opt' 970 | # --uniq-per-file-default | --upfd : show uniq entries per file in default path 971 | # --uniq-per-file-sys | --upfs : show uniq entries per file found in /usr /etc /opt' 972 | ############################ 973 | # dump - dump content of *.desktop files 974 | # dump ) 975 | # echo ' 976 | # Dump RAW content of *.desktop files to stdout 977 | # --dump-all | --da : search in / (may need root rights) 978 | # --dump-default-path | --ddp : from default path 979 | # --dump-sys-path | --dsp : dump content from /usr /etc /opt' 980 | # ;; 981 | # Update a file that contains list of path 982 | # --upf filename 983 | # --update-path-file | --upf [file name] : replacing all numbers and spaces with * in a file then sorting and leaving only uniq path' 984 | 985 | help_def(){ 986 | echo 'Showing all basic searchable content in a single line per file. 987 | Without any options it will list from all default path. 988 | All extended supported options begins with -- 989 | Deafult output to search in: Name/Comment,Exec,Category, path to the file 990 | --all-sys-path | --asc (options) 991 | using system path /usr /etc /opt 992 | 993 | Vertical and more userfiendly output. Search text in all available variables 994 | --more | --m (text) 995 | using default path 996 | --more-sys | --ms (text) 997 | using system path 998 | 999 | Same as option --more but is less userfiendly by outputing much more information 1000 | --less | --l (text) (translation) 1001 | using default path 1002 | --less-sys | --ls (text) (translation) 1003 | using system path /usr /etc /opt' 1004 | } 1005 | help_debug(){ 1006 | echo '--show-me | --sm (options) 1007 | show or search content in this script' 1008 | } 1009 | help_var(){ 1010 | echo 'Search a value of the variables. Supporting grep syntax 1011 | --var [variable] 1012 | using default path 1013 | --var-sys | --vs [variable] 1014 | using system path /usr /etc /opt 1015 | 1016 | show file names that does not contain a string 1017 | --no-var-sys|--nvs [xx] 1018 | using system path /usr /etc /opt 1019 | --no-var | --nv [text] 1020 | using default path 1021 | 1022 | show all uniq base variable names 1023 | --show-uniq-def |--sud 1024 | using default path 1025 | --show-sys-uniq |--ssu 1026 | using system path /usr /etc /opt 1027 | 1028 | show RAW output of the uniq variables 1029 | --show-uniq-only |--suo 1030 | using default path 1031 | 1032 | --list-categories | --lc 1033 | Show all categories found in "/usr/share/applications/" and "$HOME/.local/share/applications/" 1034 | 1035 | Not supporting grep syntax, using awk 1036 | show content of choosen variables only if all them are present in the file. To show path to file use "sf" as last option. 1037 | --including-only-var | --iov [var1,var2] sf 1038 | using default path 1039 | --including-only-var-sys | --iovs [var1,var2] sf 1040 | using system path /usr /etc /opt' 1041 | } 1042 | help_sec(){ 1043 | echo 'Search section names in *.desktop files 1044 | 1045 | search for uniq section names 1046 | --sys-section-name | --ssn 1047 | using system path /usr /etc /opt 1048 | --default-section-name | --dsn 1049 | using default path' 1050 | 1051 | } 1052 | help_config(){ 1053 | echo 'Configuration 1054 | --create-global-list | --cgl 1055 | scan system and save dirs into /opt/share/ldf/sorted.test 1056 | --create-local-list | --cll 1057 | scan system and save dirs into $HOME/.ldf/sorted.test 1058 | 1059 | --show-local-defaults | --sld 1060 | show content of $HOME/.ldf/sorted.test 1061 | --show-global-defaults | --sgd 1062 | show content of /opt/share/ldf/sorted.test 1063 | 1064 | --show-default-directories | --sdd 1065 | show internal dirs defined in array DefDskPath 1066 | 1067 | --remove-local-config 1068 | removing $HOME/.ldf/sorted.test 1069 | --remove-global-config 1070 | removing /opt/share/ldf/sorted.test 1071 | 1072 | --find-path | --fp (path) 1073 | find path that contain *.desktop files, default starting path is / 1074 | as the third option can be used any symbol 1075 | that will be added in the end of each directory 1076 | --formated-path-output | --fpo 1077 | same as --fp but showing already formated path (replaced numbers,spaces with *) 1078 | as the third option can be used any symbol 1079 | that will be added in the end of each directory 1080 | 1081 | --format-path-file | --fpf [filename] 1082 | replace all spaces and numbers with *' 1083 | } 1084 | help_info(){ 1085 | echo 'https://specifications.freedesktop.org/desktop-entry-spec/latest/ 1086 | Short overview: 1087 | "f" - File name with full path 1088 | "u" - URL to website 1089 | "d" - Directory 1090 | "n" - Name of the file without path 1091 | Single source: 1092 | %f %u %d %n 1093 | Multiple sources: 1094 | %F %U %D %N 1095 | Other: 1096 | %k URI/location of desktop file 1097 | %v name of the device' 1098 | } 1099 | help_usage(){ 1100 | echo 'Usage examples 1101 | List content with default options: 1102 | lsdesktopf 1103 | Search only for specific text in default output: 1104 | lsdesktopf gtk 1105 | lsdesktopf game 1106 | lsdesktopf --more 1107 | lsdesktopf --more kde 1108 | lsdesktopf --less 1109 | lsdesktopf --less gnome 1110 | lsdesktopf --less gtk zh_CN,zh_TW 1111 | 1112 | Use --var option (supporting grep syntax): 1113 | --var-sys has same syntax as --var 1114 | --var Name= 1115 | --var "Name\[zn_CN\]" -e "^Exec=" 1116 | Reverse search (supporting grep syntax) 1117 | --no-var Exec= 1118 | --no-var-sys "Name\[en_GB\]" 1119 | 1120 | Use --including-only-var option to show content of choosen and optionaly show filename 1121 | NOTE: filename is an option and not path to existing file. 1122 | --iov Exec,MimeType filename 1123 | --iov Exec,MimeType | grep -v ^# 1124 | 1125 | Use --gm option that shows various information about MIME-types in *.desktop files 1126 | --gm 1 1127 | --gm 1128 | --gm 0 1129 | --gm -gx video 1130 | --gm -gx text 1131 | --gm -fm application/oxps,application/vnd.ms-xpsdocument,application/x-brasero 1132 | 1133 | Scan for all *.desktop files in /usr /etc /opt 1134 | has same syntax as without supported options 1135 | --asc 1136 | --asc gtk 1137 | Use --find-path or --fp 1138 | --fp 1139 | --fp /usr /etc' 1140 | } 1141 | help_tips(){ 1142 | echo 'The script is based around commands: "grep", "awk", "find" 1143 | and a loop: for Line in "${Array[@]}";do ..;done 1144 | command "rev" is used to reverse text that is useful to show or exclude last column 1145 | to show only specfic column can be used commands such as awk,cut. 1146 | The "awk" command can use more than one symbol as delimer but "cut" supports only one 1147 | awk -F"AB" "{print $1}" 1148 | awk "{print substr($0,0,index($0,"AB")-2) }" 1149 | cut -dA -f1 1150 | to show everything after specified column 1151 | cut -dA -f2- 1152 | awk "{print substr($0,index($0,"AB")+2) }" 1153 | to show amount columns in a string 1154 | awk -F"AB" "{print NF}" 1155 | awk "{print split($0,A,"AB") }" 1156 | command "basename" is used to show only the filename but cutting away path to it. 1157 | find / -type f -exec basename "{}" \; 1158 | find / -type f | xargs basename 1159 | command "dirname" is used to show only path to file. 1160 | find / -type f -exec dirname "{}" \; 1161 | find / -type f | xargs dirname 1162 | hide error messages from stderr, such as e.g. "permission denied" 1163 | find / -type f 2> /dev/null | grep desktop' 1164 | } 1165 | help_mimetypes(){ 1166 | echo 'Show list of mimetypes with associated *.desktop files. 1167 | --gen-mimeapps | --gm [options] 1168 | Output is similar that is used in "mimeapps.list" file under section [Added Associations] 1169 | Options: 1170 | 0 1171 | show only MIME-types 1172 | 1 1173 | show type of mime. First part of MIME-type 1174 | 2 1175 | show extension. Second part of MIME-type 1176 | 3 1177 | show only filenames that can open same MIME-type 1178 | -gx [type of MIME] 1179 | shows all extensions in your systems *.desktop files that belongs to type of MIME 1180 | -gdx [options] 1181 | shows MIME-types with their descriptions found in *.xml files 1182 | by default searching only in /usr/share/mime/packages/ $HOME/.local/share/mime/packages/ 1183 | g 1184 | search in /etc /usr $HOME/.local $HOME/.config 1185 | l 1186 | search in $HOME/.local $HOME/.config 1187 | -fm [options] 1188 | find .desktop files only for comma separated MIME types 1189 | 1190 | --gdx [options] 1191 | same as --gm -gdx [options] 1192 | search in *.xml configuration files 1193 | additional options 1194 | 0 1195 | show only MIME-types 1196 | 1 1197 | show type of mime. First part of MIME-type 1198 | 2 1199 | show extension. Second part of MIME-type 1200 | 3 1201 | show only filename extenstions 1202 | -gfx [options] 1203 | list available file name extensions with their description found in ".xml" configuration or database files. 1204 | additional comma separated options: 1205 | sf 1206 | show path to .xml file where was found file name extension. 1207 | sm 1208 | show MIME type 1209 | sa 1210 | show acronym 1211 | sea 1212 | show extended acronym 1213 | ssc 1214 | show sub class 1215 | sal 1216 | show alias 1217 | sgi 1218 | show general icon description 1219 | 1220 | --list-mimeapps | --lm 1221 | List available "*mimeapps.list" with colored path and their content 1222 | ' 1223 | } 1224 | 1225 | help_Sessions(){ 1226 | echo ' 1227 | --sxs 1228 | list numbered content of Exec in .desktop files located at /usr/share/xsessions/ 1229 | additional options: 1230 | n 1231 | name 1232 | show content of "Name=" 1233 | c 1234 | comment 1235 | show content of "Comment=" 1236 | dn 1237 | desktopname 1238 | show content of "DesktopName=" 1239 | a 1240 | all 1241 | show content by pattern "Number Name # Comment # Exec" 1242 | --rxs 1243 | as above but also asking to choose number of a session to start.' 1244 | } 1245 | 1246 | help_env(){ 1247 | echo 'Environment 1248 | NO_COLORS - if value is YES then no colors will be used 1249 | DESKTOP_FILES - must contain path to folders with 1250 | desktop files separated with ";" 1251 | overriding default preset path' 1252 | 1253 | } 1254 | 1255 | case "$1" in 1256 | --help ) 1257 | if [[ -z "$2" ]];then 1258 | echo 'use additional options with --help' 1259 | echo ' all - show all help sections 1260 | def - options that are using default output 1261 | var - list available variables or search a value 1262 | sec - list available sections 1263 | usage - show usage of commands 1264 | config - configuration 1265 | debug - view or search in content of this script 1266 | info - show short info about *.desktop specified Exec 1267 | tips - show some tips about commands used in this script 1268 | mime - list available mimetypes 1269 | ses - list or run sessions 1270 | env - enviroment variables' 1271 | else 1272 | case "$2" in 1273 | mime ) 1274 | help_mimetypes 1275 | ;; 1276 | def ) 1277 | help_def 1278 | ;; 1279 | debug ) 1280 | help_debug 1281 | ;; 1282 | var ) 1283 | help_var 1284 | ;; 1285 | sec ) 1286 | help_sec 1287 | ;; 1288 | config ) 1289 | help_config 1290 | ;; 1291 | info ) 1292 | help_info 1293 | ;; 1294 | usage ) 1295 | help_usage 1296 | ;; 1297 | tips ) 1298 | help_tips 1299 | ;; 1300 | ses ) 1301 | help_Sessions 1302 | ;; 1303 | env ) 1304 | help_env 1305 | ;; 1306 | all ) 1307 | help_def 1308 | help_var 1309 | help_sec 1310 | help_mimetypes 1311 | help_Sessions 1312 | help_env 1313 | help_usage 1314 | help_config 1315 | help_debug 1316 | help_info 1317 | help_tips 1318 | ;; 1319 | esac 1320 | fi 1321 | ;; 1322 | --var ) 1323 | ReCreateDskPath "$@" 1324 | 1325 | if [[ ! -z "$2" ]];then 1326 | Var="$2" 1327 | if [[ "$#" -gt 2 ]];then 1328 | AddCmd=($@); 1329 | # Additional="${AddCmd[@]:2}" ; 1330 | fi; 1331 | Opts="var" 1332 | echo "${AddCmd[@]:2}" 1333 | SearchContentOfVariable "$@" 1334 | else 1335 | echo "Error, parameter to --var is missing 1336 | example: --var MimeType" 1337 | fi 1338 | ;; 1339 | #--uniq-per-file-default | --upfd ) 1340 | # Opts="upfd" 1341 | # ReCreateDskPath "$@" 1342 | # SearchContentOfVariable "$@" 1343 | # ;; 1344 | #--uniq-per-file-sys | --upfs ) 1345 | 1346 | # find /usr /etc /opt -type f -name "*\.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v GetLang="ru" -F"=" '{if (index($1,"[") == 1) printf " "FILENAME"\n" $1"\n";if(index($1,"["GetLang"]")){print $0}else{if(index($1,"]") == 0) print $0}}' "{}" \; | grep -v ^"\#" 1347 | # find /usr /etc /opt -type f -name "*\.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v GetLang="$FLang" -v ShowAvailableLanguages="$3" -F= '//{ 1348 | # if(index($1,"[") != 0 && index($1,"[") != 1 ){split($1,Lang,"[")UniqLang[Lang[2]]++}; 1349 | # if(index($1,"["GetLang"]") != 0 ){Item[cnt++]=$0}else { if(index($1,"]") == 0)Item[cnt++]=$0} 1350 | # }END{ 1351 | # printf " %s",FILENAME"\n"; 1352 | # print " ** Total translations: "length(UniqLang); 1353 | # if(ShowAvailableLanguages)if(ShowAvailableLanguages == "all")if(length(UniqLang) != 0 ){ 1354 | # for(AllLang in UniqLang){sub("]","",AllLang);printf "%s",AllLang","};print "." 1355 | # }; 1356 | # for (ItemNumber in Item)print Item[ItemNumber]; 1357 | # }' "{}" \; | grep -v ^"\#" 1358 | # ;; 1359 | --more | --m ) 1360 | Opts="more" 1361 | ReCreateDskPath "$@" 1362 | SearchContentOfVariable "$@" 1363 | ;; 1364 | --more-sys | --ms ) 1365 | find /usr /etc /opt -type f -name "*\.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v FindIt="$2" -F= '/^create/;{ 1366 | if(index($1,"]") == 0) 1367 | { 1368 | Var[CountV++]=$1; 1369 | InString[CountS++]=substr($0,index($0,$2)); 1370 | if(FindIt)if(index($2,FindIt) != 0)YES="1"; }; 1371 | }END{ 1372 | if(YES == "1" ) 1373 | { 1374 | if(CLR == "YES"){ 1375 | printf "* "FILENAME" \n"; 1376 | }else{ 1377 | printf "* \033[2;32m"FILENAME" \033[2;0m\n"; 1378 | } 1379 | for (I in InString)print Var[I]"="InString[I]} 1380 | }; 1381 | if(length(FindIt) == 0) 1382 | { 1383 | if(CLR == "YES") 1384 | { 1385 | printf "* "FILENAME"\n"; 1386 | }else{ 1387 | printf "* \033[2;32m"FILENAME"\033[2;0m\n"; 1388 | } 1389 | for(I in InString)print Var[I]"="InString[I] 1390 | } 1391 | }' "{}" \;|grep -v ^"#" 1392 | ;; 1393 | --including-only-var | --iov ) 1394 | if [[ -z "$2" ]];then 1395 | echo 'Use options! 1396 | Example: --iov Exec,Type filename' 1397 | exit 1 1398 | fi 1399 | Opts="iov" 1400 | ReCreateDskPath "$@" 1401 | SearchContentOfVariable "$@" 1402 | ;; 1403 | --including-only-var-sys | --iovs) 1404 | if [[ -z "$2" ]];then 1405 | echo 'Use options! 1406 | Example: --iovs Exec,Type filename' 1407 | exit 1 1408 | fi 1409 | find /usr /etc /opt -type f -name "*\.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v FindIt="$2" -v Fname="$3" -F= '//{ 1410 | if(FindIt){ 1411 | SizeArray=split(FindIt,ArrayFindIt,","); 1412 | if (index($0,"[") == 1 ) YesFoundIt[CountFinds++]=$0; 1413 | for(CountFindItArray in ArrayFindIt )NewArrFindIt[ArrayFindIt[CountFindItArray]]=1; 1414 | if(NewArrFindIt[$1] == 1 ) 1415 | { 1416 | YesFoundIt[CountFinds++]=$0; 1417 | UniqFound[$1]=1; 1418 | } 1419 | }}END{ 1420 | if( length(UniqFound) == SizeArray ) 1421 | { if(Fname == "filename") 1422 | if(CLR == "YES") 1423 | { 1424 | printf "* %s"FILENAME"\n"; 1425 | }else{ 1426 | printf "* \033[2;32m %s"FILENAME"\033[2;32m\n"; 1427 | } 1428 | for (GotFound in YesFoundIt ) 1429 | { 1430 | print YesFoundIt[GotFound]; 1431 | }; 1432 | } 1433 | }' "{}" \; 1434 | ;; 1435 | --less | --l ) 1436 | Opts="less" 1437 | ReCreateDskPath "$@" 1438 | SearchContentOfVariable "$@" 1439 | ;; 1440 | --less-sys | --ls ) 1441 | find /usr /etc /opt -type f -name "*\.desktop" -exec awk -v CLR="$DISABLE_COLORS" -v FindIt="$2" -v Trans="$3" -F= '/^create/;{ 1442 | if(Trans) 1443 | { 1444 | split(Trans,ArrayTransLang,","); 1445 | for(ReLangArray in ArrayTransLang )NewArrTrans[ArrayTransLang[ReLangArray]]=1; 1446 | } 1447 | if(index($1,"]") == 0) 1448 | { 1449 | Var[CountV++]=$1; 1450 | InString[CountS++]=substr($0,index($0,$2)); 1451 | if(FindIt)if(index($2,FindIt) != 0)YES="1"; 1452 | }; 1453 | if(index($1,"[") != 0 && index($1,"[") != 1 ){ 1454 | split($1,Lang,"["); 1455 | TmpLang=Lang[2]; 1456 | UniqLang[TmpLang]++; 1457 | sub("]","",TmpLang); 1458 | if(Trans) 1459 | { 1460 | if( NewArrTrans[TmpLang] == 1 ) 1461 | { 1462 | Var[CountV++]=$1; 1463 | InString[CountS++]=substr($0,index($0,$2)) 1464 | } 1465 | } 1466 | }; 1467 | if(index($1,"[") == 1){ 1468 | Var[CountV++]=$1; 1469 | InString[CountS++]=$0} 1470 | }END{ 1471 | if(YES == "1" ) 1472 | { if(CLR == "YES") 1473 | { 1474 | printf "* "FILENAME"\n"; 1475 | printf "@ Total translations: "length(UniqLang)": "; 1476 | }else{ 1477 | printf "*\033[2;32m "FILENAME"\033[2;0m \n"; 1478 | printf "@ Total translations: "length(UniqLang)": "; 1479 | } 1480 | if(length(UniqLang) != 0)for(AllLang in UniqLang){sub("]","",AllLang);printf "%s",AllLang",";} 1481 | print " "; 1482 | for (I in InString) 1483 | if(index(Var[I],"[") != 1 && length(Var[I]) != 0 && index(Var[I],"#") != 1 ) 1484 | { 1485 | print Var[I]"="InString[I]; 1486 | } 1487 | else 1488 | { 1489 | if(index(Var[I],"[") == 1) 1490 | if(CLR == "YES") 1491 | { 1492 | printf Var[I]"\n"; 1493 | }else{ 1494 | printf "\033[2;33m" Var[I]"\033[0m\n"; 1495 | } 1496 | } 1497 | } 1498 | if(length(FindIt) == 0) 1499 | { 1500 | if(CLR == "YES") 1501 | { 1502 | printf "* "FILENAME"\n"; 1503 | }else{ 1504 | printf "* \033[2;32m "FILENAME"\033[2;0m \n"; 1505 | } 1506 | printf "@ Total translations: "length(UniqLang)": "; 1507 | if(length(UniqLang) != 0)for(AllLang in UniqLang){sub("]","",AllLang);printf "%s",AllLang",";} 1508 | print " "; 1509 | for (I in InString)if(index(Var[I],"[") != 1 && length(Var[I]) != 0 && index(Var[I],"#") != 1 ) 1510 | { 1511 | print Var[I]"="InString[I]; 1512 | } 1513 | else 1514 | { 1515 | if(index(Var[I],"[") == 1) 1516 | if(CLR == "YES") 1517 | { 1518 | printf Var[I]"\n" 1519 | }else{ 1520 | printf "\033[2;33m"Var[I]"\033[0m \n" 1521 | } 1522 | } 1523 | } 1524 | }' "{}" \; 1525 | ;; 1526 | --no-var | --nv ) 1527 | ReCreateDskPath "$@" 1528 | 1529 | if [[ ! -z "$2" ]];then 1530 | Var="$2" 1531 | Opts="no-var" 1532 | SearchContentOfVariable "$@" 1533 | else 1534 | echo "Error, parameter to --no-var is missing 1535 | example: --no-var MimeType" 1536 | fi 1537 | ;; 1538 | --var-sys | --vs) 1539 | # ReCreateDskPath 1540 | if [[ ! -z "$2" ]];then 1541 | Var="$2" 1542 | # if [[ "$#" -gt 2 ]];then 1543 | # Additional="${AddCmd[@]:2}" ; 1544 | # fi; 1545 | Opts="var-sys" 1546 | SearchContentOfVariable "$@" 1547 | else 1548 | echo "Error, parameter to --var-sys is missing 1549 | example: --var-sys MimeType" 1550 | fi 1551 | ;; 1552 | --no-var-sys | --nvs ) 1553 | if [[ ! -z "$2" ]];then 1554 | find /usr /etc /opt -type f -name "*\.desktop" -exec grep -i -H -L "$2" \; 1555 | else 1556 | echo 'No options are given.' 1557 | fi 1558 | ;; 1559 | #--dump-all | --da ) 1560 | # grep -i ^ -H -R --include \*.desktop "/" 1561 | # ;; 1562 | #--dump-sys-path | --dsp ) 1563 | # grep -i ^ -H -R --include \*.desktop "/usr /etc /opt" 1564 | # ;; 1565 | #--dump-default-path | --ddp ) 1566 | # Opts="ddp" 1567 | # ReCreateDskPath "$@" 1568 | # SearchContentOfVariable 1569 | # ;; 1570 | --show-uniq-def | --sud ) 1571 | OffPrint="no" 1572 | Opts="sud" 1573 | ReCreateDskPath "$@" 1574 | SearchContentOfVariable "$@" 1575 | ;; 1576 | --show-uniq-only | --suo ) 1577 | OffPrint="yes" 1578 | Opts=suo 1579 | ReCreateDskPath "$@" 1580 | RawView 1581 | ;; 1582 | --show-sys-uniq | --ssu ) 1583 | Opts="sys-uniq" 1584 | SearchContentOfVariable "$@" 1585 | ;; 1586 | --find-path | --fp ) 1587 | if [[ ! -z "$2" ]]; then 1588 | for StartCmdLine in "$@"; 1589 | do 1590 | if [[ -d "$StartCmdLine" ]]; then 1591 | InPath="$StartCmdLine" 1592 | fi 1593 | find "$InPath" -type f -name "*\.desktop" -exec dirname "{}" \; 2> /dev/null | sort -u | sed "s/$/$3/g" 1594 | if [[ "$InPath" == "/" ]];then 1595 | exit 0 1596 | fi 1597 | done 1598 | else 1599 | find / -type f -name "*\.desktop" -exec dirname "{}" \; 2> /dev/null | sort -u 1600 | fi 1601 | ;; 1602 | --formated-path-output | --fpo ) 1603 | if [[ ! -z "$2" ]]; then 1604 | for StartCmdLine in "$@"; 1605 | do 1606 | if [[ -d "$StartCmdLine" ]]; then 1607 | InPath="$StartCmdLine" 1608 | fi 1609 | find "$InPath" -type f -name "*\.desktop" -exec dirname "{}" \; 2> /dev/null |\ 1610 | sed -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' -e 's/[0-9]\.[0-9]*/*/g' -e 's/\.\*/*/g' -e 's/**\*/*/g' |\ 1611 | sort -u 1612 | if [[ "$InPath" == "/" ]];then 1613 | exit 0 1614 | fi 1615 | done 1616 | else 1617 | find / -type f -name "*\.desktop" -exec dirname "{}" \; 2> /dev/null |\ 1618 | sed -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' -e 's/[0-9]\.[0-9]*/*/g' -e 's/\.\*/*/g' -e 's/\*\**/*/g' |\ 1619 | sort -u 1620 | fi 1621 | ;; 1622 | --all-sys-path | --asc) 1623 | Opts="scan-sys-path" 1624 | ReCreateDskPath "$@" 1625 | ListDefault "$@" 1626 | ;; 1627 | --create-local-list | --cll) 1628 | mkdir -p "$(dirname "$LocalArray")" 1629 | find / -type f -name "*\.desktop" -exec dirname "{}" \; | sort -u > "$LocalArray" 1630 | ;; 1631 | #--update-path-file | --upf) 1632 | # if [[ "$UID" != 0 ]];then 1633 | # echo 'You must start it as user root' 1634 | # exit 1 1635 | # else 1636 | # if [[ -z "$2" ]];then 1637 | # echo 'path to file is missing' 1638 | # else 1639 | # if [[ -f "$2" ]];then 1640 | # mkdir -p "$(dirname $GlobalArray)" 1641 | # find /usr /etc /opt -type f -name "*\.desktop" -exec dirname "{}" \; | sort -u >> "$2"; 1642 | # sed -i -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' -e 's/[0-9]\.[0-9]*/*/g' -e 's/**\*/*/g' "$2"; 1643 | # uniq -u "$2" /tmp/uniq-tmp.txt 1644 | # cp "/tmp/uniq-tmp.txt" "$2" 1645 | # else 1646 | # echo "Destion is not a file" 1647 | # fi 1648 | # fi 1649 | # fi 1650 | # ;; 1651 | 1652 | --format-path-file | --fpf ) 1653 | if [[ ! -z "$2" ]];then 1654 | if [[ -f "$2" ]];then 1655 | if [[ $(grep -c -v ^/ "$2" ) != "0" ]];then 1656 | echo 'The file should contain only full path per line. ( all should begin with / )' 1657 | else 1658 | sed -i -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' -e 's/[0-9]\.[0-9]*/*/g' -e 's/\.\*/*/g' -e 's/\*\**/*/g' "$2" 1659 | sort -u -o "$2" "$2" 1660 | fi 1661 | else 1662 | echo 'Path to file is missing!' 1663 | fi 1664 | fi 1665 | ;; 1666 | --create-global-list | --cgl) 1667 | if [[ "$UID" != 0 ]];then 1668 | echo 'You must start it as user root' 1669 | exit 1 1670 | else 1671 | mkdir -p "$(dirname $GlobalArray)" 1672 | find / -type f -name "*\.desktop" -exec dirname "{}" \; | sort -u > "$GlobalArray" 1673 | fi 1674 | ;; 1675 | 1676 | --show-local-defaults | --sld) 1677 | if [[ -f "$HOME/.ldf/sorted.test" ]];then 1678 | cat "$HOME/.ldf/sorted.test" 1679 | else 1680 | echo 'Does not exist $HOME/.ldf/sorted.test' 1681 | fi 1682 | ;; 1683 | --show-global-defaults | --sgd) 1684 | if [[ -f "/opt/share/ldf/sorted.test" ]];then 1685 | cat "/opt/share/ldf/sorted.test" 1686 | else 1687 | echo 'Does not exist /opt/share/ldf/sorted.test' 1688 | fi 1689 | ;; 1690 | --show-default-directories | --sdd) 1691 | for SDD in "${DefDskPath[@]}"; do 1692 | echo "$SDD" 1693 | done 1694 | ;; 1695 | --remove-local-config) 1696 | rm -i "$HOME/.ldf/sorted.test" 1697 | ;; 1698 | --remove-global-config) 1699 | if [[ "$UID" -eq "0" ]];then 1700 | rm -i "/opt/share/ldf/sorted.test" 1701 | else 1702 | echo 'You must be root!' 1703 | fi 1704 | ;; 1705 | --show-me | --sm) 1706 | if [[ -z $2 ]];then 1707 | cat "$0" 1708 | echo '# my path: '" $0" 1709 | else 1710 | grep -n "$2" "$0" | grep -v -e "IGNORE" -e ^"# " 1711 | fi 1712 | ;; 1713 | --sys-section-name | --ssn) 1714 | grep -e ^"\[" -h -R --include "*\.desktop" /usr /etc /opt | sort -u 1715 | ;; 1716 | --default-section-name | --dsn) 1717 | OffPrint="no" 1718 | Opts='sdsn' 1719 | ReCreateDskPath "$@" 1720 | 1721 | SearchContentOfVariable 1722 | ;; 1723 | --generate-mimeapps.list | --gen-mimeapps | --gm ) 1724 | 1725 | if [[ -z "$XDG_CONFIG_HOME" ]]; then 1726 | PName="$HOME/.local/share/applications" 1727 | else 1728 | if [[ "${XDG_CONFIG_HOME/#\//}" == "$XDG_CONFIG_HOME" ]]; then 1729 | PName="$HOME/$XDG_CONFIG_HOME/.local/share/applications" 1730 | else 1731 | PName="$XDG_CONFIG_HOME/.local/share/applications" 1732 | fi 1733 | fi 1734 | 1735 | IFS=" 1736 | " 1737 | MimePathArray+=("$( 1738 | find "/usr/local/share/applications" "/usr/share/applications" "$PName" -type f -name "*\.desktop" -exec dirname "{}" \; | 1739 | sort -u | 1740 | sed "s/$/\/\*.desktop/" )") 1741 | 1742 | case $2 in 1743 | -gdx | -get-description-xdg ) 1744 | IFS=" 1745 | " 1746 | case $3 in 1747 | g | glob ) 1748 | List_XML=($(find "/usr/" "/etc/" "$HOME/.local/" "$HOME/.config" -type f -name "*\.xml")); 1749 | ;; 1750 | l | local ) 1751 | List_XML=($(find "$HOME/.config" "$HOME/.local/" -type f -name "*\.xml")); 1752 | ;; 1753 | * ) 1754 | List_XML=($(find "/usr/share/mime/packages/" "/usr/share/mime/application/" "$HOME/.local/share/" -type f -name "*\.xml")); 1755 | ;; 1756 | esac 1757 | for In_XML_List in "${List_XML[@]}";do 1758 | find "$In_XML_List" -type f -name "*\.xml" -print0 | xargs -0 awk -v CLR="$DISABLE_COLORS" -F"\"" '{YesM=0; 1759 | if(index($0,"mime-type")){if(index($0,"type type=")){ContentArray[Count++]=$2" == ";YesM=1}else{if(index($0," type=")){ 1760 | ContentArray[Count++]=$4" == "}}} 1761 | 1762 | if(index($0,"")){ 1763 | GetString=substr($0,index($0,">")+1) 1764 | GetTMP=" "substr(GetString,0,index(GetString,"") != 0) 1944 | { 1945 | C=substr($0,0,index($0,"/")-2); 1946 | GetContentList[CountItems++]=substr(C,index($0,">")+1); 1947 | YesFN=FILENAME 1948 | }; 1949 | if(index($0,"mime-type type=") != 0) 1950 | { 1951 | AA=substr($0,index($0,"\"")+1); 1952 | GetContentList[CountItems++]=substr(AA,0,index(AA,"\"")-1)" # "; 1953 | YesFN=FILENAME; 1954 | } 1955 | }; 1956 | }END{if(length(YesFN) != 0)print "* "YesFN ;for(GetList in GetContentList )print GetContentList[GetList]; 1957 | }' ; 1958 | 1959 | done; 1960 | 1961 | else 1962 | 1963 | for In_List in "${List_Dirs[@]}";do 1964 | 1965 | [[ -d "${In_List}" ]] && find "${In_List}" -type f \( -name "*mimeapps.list" -o -name "defaults.list" \) -exec awk -v CLR="$DISABLE_COLORS" '{ 1966 | CollectMIMEContent[count++]=$0 1967 | }END{ 1968 | if(CLR == "YES") 1969 | { 1970 | printf "# "FILENAME "\n"; 1971 | }else{ 1972 | printf "# \033[1;36m "FILENAME "\033[0m \n"; 1973 | } 1974 | for (GotMIME in CollectMIMEContent)print CollectMIMEContent[GotMIME] }' "{}" \; 1975 | done 1976 | fi 1977 | ;; 1978 | --list-categories | --lc ) 1979 | # grep ^Categories -h -R "/usr/share/applications/" "$HOME/.local/share/applications/" | awk -v CLR="$DISABLE_COLORS" -F= '//{A[$2]=1}END{for(E in A)ZZ=ZZ E;split(ZZ,YY,";");asort(YY);for(I in YY)HH[YY[I]];for(QQ in HH)print QQ}' 1980 | # #\ awk -v CLR="$DISABLE_COLORS" -F= '//{A[$2]=1}END{for(E in A){gsub(";","\n",E);printf E}}' | sort -u 1981 | List_Dirs=("/usr/share/applications/") 1982 | List_Dris+=("$HOME/.local/share/applications/") 1983 | List_Dris+=("/usr/local/share/applications/") 1984 | for In_List in "${List_Dirs[@]}" ;do 1985 | [[ -d "${In_List}" ]] && find "${In_List}" -exec grep ^Categories -h -R "{}" \; 1986 | done | awk -v CLR="$DISABLE_COLORS" -F= '//{A[$2]=1}END{for(E in A)ZZ=ZZ E;split(ZZ,YY,";");asort(YY);for(I in YY)HH[YY[I]];for(QQ in HH)print QQ}' 1987 | #\ awk -v CLR="$DISABLE_COLORS" -F= '//{A[$2]=1}END{for(E in A){gsub(";","\n",E);printf E}}' | sort -u 1988 | ;; 1989 | --gdx | --get-description-xdg ) 1990 | gdxstdalone "$@" 1991 | ;; 1992 | --sxs | --show-x-sessions ) 1993 | StartIt=0; 1994 | ToShowPart="$2"; 1995 | ShowOrStartXsession "$@" 1996 | ;; 1997 | --rxs | --run-x-session ) 1998 | StartIt=1; 1999 | ToShowPart="$2"; 2000 | ShowOrStartXsession "$@" 2001 | ;; 2002 | * ) 2003 | ReCreateDskPath "$@" 2004 | 2005 | ListDefault "$@" 2006 | ;; 2007 | esac 2008 | -------------------------------------------------------------------------------- /Korora-dir-list: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Version 1.0.0-4 3 | # 4 | # License: GPL3 5 | # 6 | # Author: Andy Crowd 7 | # Tested in Arch Linux 8 | # Search in *.desktop for "Categories" and "Exec" 9 | # 10 | 11 | unset IFS 12 | IFS=" 13 | " 14 | One="$1" 15 | #Two="$2" 16 | 17 | GlobalArray="/opt/share/list-desktop-files/sorted.test" 18 | LocalArray="$HOME/.list-desktop-path/custom-path/sorted.test" 19 | 20 | ### The DefDskPath variable contains list of default folders 21 | DefDskPath+=("/etc/dynamic/launchers/scanner") 22 | DefDskPath+=("/etc/xdg/autostart") 23 | DefDskPath+=("/etc/xdg/xfce*/panel/launcher-*") 24 | DefDskPath+=("/lib/gnome-settings-daemon-*/gtk-modules") 25 | DefDskPath+=("/lib/libreoffice/share/xdg") 26 | DefDskPath+=("/usr/etc/xdg/autostart") 27 | DefDskPath+=("/usr/lib/gnome-settings-daemon-*/gtk-modules") 28 | DefDskPath+=("/usr/lib/libreoffice/share/xdg") 29 | DefDskPath+=("/usr/local/share/applications") 30 | DefDskPath+=("/usr/share/applications") 31 | DefDskPath+=("/usr/share/apps/kdm/programs") 32 | DefDskPath+=("/usr/share/apps/kdm/sessions") 33 | DefDskPath+=("/usr/share/apps/solid/actions") 34 | DefDskPath+=("/usr/share/autostart") 35 | DefDskPath+=("/usr/share/dist/desktop-files/default") 36 | DefDskPath+=("/usr/share/gdm/autostart") 37 | DefDskPath+=("/usr/share/gdm/autostart/LoginWindow") 38 | DefDskPath+=("/usr/share/gdm/greeter/autostart") 39 | DefDskPath+=("/usr/share/gnome/autostart") 40 | DefDskPath+=("/usr/share/kde*") 41 | DefDskPath+=("/usr/share/mate/wm-properties") 42 | DefDskPath+=("/usr/share/mga/dm") 43 | DefDskPath+=("/usr/share/mimelnk/application") 44 | DefDskPath+=("/usr/share/mimelnk/chemical") 45 | DefDskPath+=("/usr/share/parole/parole-plugins-*") 46 | DefDskPath+=("/usr/share/Thunar/sendto") 47 | DefDskPath+=("/usr/share/wayland-sessions") 48 | DefDskPath+=("/usr/share/xfce*/helpers") 49 | DefDskPath+=("/usr/share/xfce*/panel-plugins") 50 | DefDskPath+=("/usr/share/xfce*/panel/plugins") 51 | DefDskPath+=("/usr/share/xgreeters") 52 | DefDskPath+=("/usr/share/xsessions") 53 | DefDskPath+=("/etc/xdg/autostart") 54 | DefDskPath+=("/opt/teamviewer/tv_bin/desktop") 55 | DefDskPath+=("/opt/wine-staging/share/applications") 56 | DefDskPath+=("/usr/lib/gnome-settings-daemon-*.*/gtk-modules") 57 | DefDskPath+=("/usr/lib/libreoffice/share/xdg") 58 | DefDskPath+=("/usr/local/share/applications") 59 | DefDskPath+=("/usr/share/applications") 60 | DefDskPath+=("/usr/share/applications/inputmethods") 61 | DefDskPath+=("/usr/share/apps/solid/actions") 62 | DefDskPath+=("/usr/share/gdm/autostart/LoginWindow") 63 | DefDskPath+=("/usr/share/gdm/greeter/autostart") 64 | DefDskPath+=("/usr/share/gnome/autostart") 65 | DefDskPath+=("/usr/share/hedgewars/Data/misc") 66 | DefDskPath+=("/usr/share/J*Z/Desktop/KDE") 67 | DefDskPath+=("/usr/share/J*Z/Desktop/Menu") 68 | DefDskPath+=("/usr/share/kde*/services") 69 | DefDskPath+=("/usr/share/kde*/services/phononbackends") 70 | DefDskPath+=("/usr/share/kde*/services/ServiceMenus") 71 | DefDskPath+=("/usr/share/kservices*") 72 | DefDskPath+=("/usr/share/kservices*/qimageioplugins") 73 | DefDskPath+=("/usr/share/kservicetypes*") 74 | DefDskPath+=("/usr/share/lirc/contrib") 75 | DefDskPath+=("/usr/share/mimelnk/application") 76 | DefDskPath+=("/usr/share/phoronix-test-suite/pts-core/static") 77 | DefDskPath+=("/usr/share/Quamachi/Desktop/Menu") 78 | DefDskPath+=("/usr/share/speech-dispatcher/conf/desktop") 79 | DefDskPath+=("/usr/share/themes/blondie/matchbox") 80 | DefDskPath+=("/usr/share/themes/Default/matchbox") 81 | DefDskPath+=("/usr/share/themes/MBOpus/matchbox") 82 | DefDskPath+=("/usr/share/Thunar/sendto") 83 | DefDskPath+=("/usr/share/xfce*/helpers") 84 | DefDskPath+=("/usr/share/xfce*/panel-plugins") 85 | DefDskPath+=("/usr/share/xfce*/panel/plugins") 86 | DefDskPath+=("/usr/share/xsessions") 87 | DefDskPath+=("$HOME/.local/share/applications") 88 | DefDskPath+=("$HOME/.local/share/xfce*/helpers") 89 | 90 | 91 | AddKorora(){ 92 | DefDskPath+=("/usr/lib64/gnome-settings-daemon-*/gtk-modules") 93 | DefDskPath+=("/usr/lib64/libreoffice/share/xdg") 94 | DefDskPath+=("/usr/share/akonadi/agents") 95 | DefDskPath+=("/usr/share/anaconda/gnome") 96 | DefDskPath+=("/usr/share/applications") 97 | DefDskPath+=("/usr/share/applications/kde*") 98 | DefDskPath+=("/usr/share/carddecks") 99 | DefDskPath+=("/usr/share/doc") 100 | DefDskPath+=("/usr/share/gcompris") 101 | DefDskPath+=("/usr/share/gdm/autostart/LoginWindow") 102 | DefDskPath+=("/usr/share/kcm_componentchooser") 103 | DefDskPath+=("/usr/share/kcmsolidactions") 104 | DefDskPath+=("/usr/share/kf*/kmoretools/presets-kmoretools") 105 | DefDskPath+=("/usr/share/kf*/locale/countries") 106 | DefDskPath+=("/usr/share/kf*/locale/currency") 107 | DefDskPath+=("/usr/share/khelpcenter/plugins") 108 | DefDskPath+=("/usr/share/khelpcenter/searchhandlers") 109 | DefDskPath+=("/usr/share/kio_desktop") 110 | DefDskPath+=("/usr/share/kmines/themes") 111 | DefDskPath+=("/usr/share/konqsidebartng/virtual_folders/remote") 112 | DefDskPath+=("/usr/share/konqsidebartng/virtual_folders/services") 113 | DefDskPath+=("/usr/share/konqueror/dirtree/remote") 114 | DefDskPath+=("/usr/share/konversation/themes") 115 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_energyinfo") 116 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_fileindexermonitor") 117 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_lookandfeel") 118 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_splashscreen") 119 | DefDskPath+=("/usr/share/kpat/themes") 120 | DefDskPath+=("/usr/share/kservicetypes*") 121 | DefDskPath+=("/usr/share/ksmserver/screenlocker/org.kde.passworddialog") 122 | DefDskPath+=("/usr/share/ksmserver/themes") 123 | DefDskPath+=("/usr/share/ksmserver/windowmanagers") 124 | DefDskPath+=("/usr/share/ksysguard/scripts/smaps") 125 | DefDskPath+=("/usr/share/kwin/decorations/kwin*_decoration_qml_plastik") 126 | DefDskPath+=("/usr/share/kwin/desktoptabbox/previews") 127 | DefDskPath+=("/usr/share/kwin/effects") 128 | DefDskPath+=("/usr/share/kwin/scripts") 129 | DefDskPath+=("/usr/share/kwin/tabbox") 130 | DefDskPath+=("/usr/share/kxmlgui*/parley/themes") 131 | DefDskPath+=("/usr/share/lirc/contrib") 132 | DefDskPath+=("/usr/share/locale/") 133 | #DefDskPath+=("/usr/share/locale/l10n") 134 | DefDskPath+=("/usr/share/parley/plugins") 135 | DefDskPath+=("/usr/share/parley/themes") 136 | DefDskPath+=("/usr/share/plasma/desktoptheme") 137 | DefDskPath+=("/usr/share/plasma/kcms/screenlocker_kcm") 138 | DefDskPath+=("/usr/share/plasma/layout-templates") 139 | DefDskPath+=("/usr/share/plasma/look-and-feel") 140 | DefDskPath+=("/usr/share/plasma/packages") 141 | DefDskPath+=("/usr/share/plasma/plasmoids") 142 | DefDskPath+=("/usr/share/plasma/shareprovider") 143 | DefDskPath+=("/usr/share/plasma/shells") 144 | DefDskPath+=("/usr/share/plasma/wallpapers") 145 | DefDskPath+=("/usr/share/remoteview") 146 | DefDskPath+=("/usr/share/sddm/themes") 147 | DefDskPath+=("/usr/share/services") 148 | DefDskPath+=("/usr/share/solid/actions") 149 | DefDskPath+=("/usr/share/solid/devices") 150 | DefDskPath+=("/usr/share/soprano/plugins") 151 | DefDskPath+=("/usr/share/templates") 152 | DefDskPath+=("/usr/share/wallpapers") 153 | DefDskPath+=("/usr/share/yumex-dnf") 154 | } 155 | 156 | ## Uncomment below to add path found in Korora ProjectLinux 157 | #AddKorora 158 | 159 | ########################################## 160 | ########################################## 161 | if [[ ! -f "$LocalArray" ]];then 162 | if [[ -f "$GlobalArray" ]];then 163 | FilePath="$GlobalArray" 164 | 165 | else 166 | ### ADskPath contains list of "decoded" path with command "file" 167 | ### command "file" can handle wildcards such as * that is useful when it is multiple or new path with versions number is available 168 | ### command "grep" is used to separate available from not existing path 169 | ### command combination "| rev | cut -d: -f2- | rev" make sure that only the last field will be removed by reversing output string 170 | ADskPath=($(for FromDDP in "${DefDskPath[@]}";do 171 | file "$FromDDP"; 172 | done |sort|uniq|grep -v \)$ | grep ^/ |rev|cut -d: -f2- |rev)) 173 | #################### 174 | fi 175 | else 176 | FilePath="$LocalArray" 177 | fi 178 | if [[ "${#ADskPath[@]}" == 0 ]]; then 179 | ADskPath=($(sed -i -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' "$FilePath"; 180 | while read FromFile;do echo "$FromFile" ; 181 | done < "$FilePath"|xargs file|sort|uniq|grep -v \)$ |grep ^/ |rev|cut -d: -f2-|rev)) 182 | ### $BDskPath is used to add path that depends on such variables as $HOME and $XDG related 183 | BDskPath+=("$HOME/.local/share/applications") 184 | BDskPath+=("$HOME/.config/autostart") 185 | BDskPath+=("$XDG_CONFIG_DIRS/autostart") 186 | BDskPath+=("$XDG_CONFIG_HOME/autostart") 187 | fi 188 | for AddWithVariables in "${BDskPath[@]}"; 189 | do 190 | if [ -d "$AddWithVariables" ];then 191 | ADskPath+="$AddWithVariables"; 192 | fi 193 | done 194 | 195 | ### soring out only uniq path in case if $XDG related and $HOME are pointing on a similar destination. || $InDskPath, $ADskPath, NoEmpty 196 | NoEmpty=($(for InDskPath in "${ADskPath[@]}";do echo "$InDskPath";done|sort|uniq;)); 197 | 198 | ### used to find out path that can be used || scan-sys-path, $DskPath, NoEmpty 199 | ReCreateDskPath(){ 200 | case "$Opts" in 201 | OnlyNew1 ) 202 | DskPath=($(if [[ ! -z $2 ]]; then 203 | for StartCmdLine in "$@"; 204 | do 205 | if [[ -d "$StartCmdLine" ]]; then 206 | InPath="$StartCmdLine" 207 | fi 208 | find "$InPath" -type f -name "*\.desktop" -exec dirname "{}" \;|sort|uniq 209 | 210 | if [[ "$InPath" == "/" ]];then 211 | exit 0 212 | fi 213 | done 214 | else 215 | find / -type f -name "*\.desktop" -exec dirname "{}" \; |sort|uniq 216 | fi)) 217 | ;; 218 | scan-sys-path ) 219 | DskPath=($(find "/usr/" "/etc/" "/opt/" -type f -name "*\.desktop" -exec dirname "{}" \;|sort|uniq)) 220 | ;; 221 | *) 222 | DskPath=(${NoEmpty[@]}) 223 | ;; 224 | esac 225 | } 226 | ######################################## 227 | ### ListDefault listing or searching in default output for content of Name, Exec, Comment. || awk, DskPath, fdPath 228 | ListDefault(){ 229 | for fdPath in "${DskPath[@]}";do 230 | if [[ ! -z "$1" ]];then 231 | if [[ "$One" == "--all-sys-path" || "$1" == --asc ]];then 232 | One="$2" 233 | fi 234 | fi 235 | if [[ -d "${DskPath[Count]}" || -f "${DskPath[Count]}" ]]; 236 | then 237 | printf "\e[1;36m %s ${fdPath} \e[0m \n"; 238 | if [ ! -z "$One" ] && [[ -d "${fdPath}" || -f "${fdPath}" ]] ; 239 | then 240 | find "${fdPath}" -iname "*\.desktop" -exec awk -v Fil="{}" -v Seek="$One" -F"=" '//{ 241 | if(index($0,"Categories=") >= 1) Ctgr=substr($0,index($0,"=")+1); 242 | if(index($0,"Name=") == 1) inNm=substr($0,index($0,"=")+1); 243 | if(index($0,"Comment=") == 1) inComment=substr($0,index($0,"=")+1); 244 | if(index($0,"Command") == 1) inCmd=substr($0,index($0,"=")+1) ; 245 | if(index($0,"Module=") == 1) inExc=substr($0,index($0,"=")+1); 246 | if(index($0,"Exec=") == 1) inExc=substr($0,index($0,"=")+1); 247 | if(index($0,"Category=") >= 1) Ctgr=substr($0,index($0,"=")+1); 248 | if(index($0,"X-XFCE-Binaries=") >= 1) inExc=substr($0,index($0,"=")+1); 249 | }END{ 250 | if(! Ctgr ){E=inNm}else{E=Ctgr}; 251 | if(! inExc){CmdLine=inCmd}else{CmdLine=inExc}; 252 | if(! E)E=inComment; 253 | Z=CmdLine" # "E" # "Fil; 254 | if( index(tolower(Z),tolower(Seek)) && CmdLine ) print Z;}' "{}" \; 255 | else 256 | [[ -d "${fdPath}" || -f "${fdPath}" ]] && find "${fdPath}" -iname "*.desktop" -exec awk -v Fil="{}" -F"=" '//{ 257 | if(index($0,"Categories") == 1) Ctgr=substr($0,index($0,"=")+1); 258 | if(index($0,"Name=") == 1) inNm=substr($0,index($0,"=")+1); 259 | if(index($0,"Exec=") == 1) inExc=substr($0,index($0,"=")+1); 260 | if(index($0,"Comment=") == 1) inComment=substr($0,index($0,"=")+1); 261 | if(index($0,"Command=") == 1) inCmd=substr($0,index($0,"=")+1) ; 262 | if(index($0,"Category=") >= 1) Ctgr=substr($0,index($0,"=")+1); 263 | if(index($0,"X-XFCE-Binaries=") >= 1) inExc=substr($0,index($0,"=")+1); 264 | }END{ 265 | if(! Ctgr ){E=inNm}else{E=Ctgr}; 266 | if(! inExc){CmdLine=inCmd}else{CmdLine=inExc}; 267 | if(! E)E=inComment; 268 | Z=CmdLine" # "E" # "Fil" # "XFCEb; 269 | if(CmdLine)print Z;}' "{}" \; 270 | fi; 271 | fi 272 | done 273 | } 274 | ################### Search specific #### 275 | OffPrint="no"; 276 | SearchContentOfVariable(){ 277 | for fdPath in "${DskPath[@]}";do 278 | if [[ -d "${DskPath[Count]}" || -f "${DskPath[Count]}" ]]; 279 | then 280 | [[ "$OffPrint" == "no" ]] && printf "\e[1;36m %s ${fdPath} \e[0m \n"; 281 | if [ ! -z "$One" ] && [[ -d "${fdPath}" || -f "${fdPath}" ]] ; 282 | then 283 | case $Opts in 284 | ### "$var" is used to search for variable names with "grep" in *.desktop 285 | var ) 286 | grep -e ^"$Var" "${OptionsToGrep[@]:2}" -H -E -R --include \*.desktop "${fdPath}" 287 | ;; 288 | ### "ddp" is used to raw dump cotent of all *.desktop found in default path. || grep 289 | ddp ) 290 | grep ^ -H -R --include \*.desktop "${fdPath}" 291 | ;; 292 | ### "sud" showing uniq variables found in default path. || grep, cut 293 | sud ) 294 | grep '=' -R -h --include \*.desktop "${fdPath}"|cut -d= -f 1|grep -v -e "\[" -e ^\# |sort|uniq 295 | ;; 296 | ### "no-var" showing all *.desktop except them that contains contains specified string. || grep, find 297 | no-var ) 298 | find "${fdPath}" -type f -iname "*\.desktop" -exec grep -H -L -e "$Var" "$Additional" "{}" \; 299 | ;; 300 | ### "sdsn" showing only uniq section names found in default path. || grep, sed 301 | sdsn ) 302 | grep '\[*\]'$ -R -h --include \*.desktop "${fdPath}" | sed 's/ * //m' |grep ^'\[' |grep -v -e ^'#' -e '\]=' |sort|uniq 303 | ;; 304 | esac 305 | 306 | fi; 307 | fi 308 | done 309 | 310 | case "$Opts" in 311 | ### "sys-uniq" showing uniq variable names found in /usr /etc /opt path. || find, cut, grep 312 | sys-uniq ) 313 | find "/usr" "/etc" "/opt" -type f -name "*\.desktop" -exec grep ^ "{}" \; | cut -d= -f1 | grep -v -e "\[" -e ^\# | sort | uniq 314 | ;; 315 | ### "var-sys" searching for variable name in system path /usr /etc /opt 316 | var-sys ) 317 | grep -e ^"$Var" "$Additional" -H -E -R --include \*.desktop /usr /etc /opt 318 | ;; 319 | esac 320 | } 321 | ######################################## 322 | 323 | RawView(){ 324 | for fdPath in "${DskPath[@]}";do 325 | if [[ -d "${DskPath[Count]}" || -f "${DskPath[Count]}" ]]; 326 | then 327 | [[ "$OffPrint" == "no" ]] && printf "\e[1;36m %s ${fdPath} \e[0m \n"; 328 | if [ ! -z "$One" ] && [[ -d "${fdPath}" || -f "${fdPath}" ]] ; 329 | then 330 | [[ "$Opts" == "suo" ]] && grep ^ -R -h --include "*\.desktop" "${fdPath}"; 331 | fi; 332 | fi 333 | done | case $Opts in 334 | suo ) 335 | grep = |cut -d= -f1 |grep -v -e "\[" -e ^\#|sort | uniq 336 | ;; 337 | esac 338 | } 339 | ################### 340 | case "$1" in 341 | --help ) 342 | if [[ -z "$2" ]];then 343 | echo ' 344 | use additional options with --help' 345 | echo ' 346 | usage - show usage of commands 347 | config - configuration 348 | dump - dump content of *.desktop files 349 | var - list available variables or search a value 350 | sec - list available sections 351 | def - options that are using default output 352 | debug - view or search in content of this script 353 | info - show short info about *.desktop specified Exec' 354 | else 355 | case "$2" in 356 | default ) 357 | echo '--help : show this help message' 358 | ;; 359 | def ) 360 | echo ' 361 | Search for content in 362 | Deafult output to search in: Name/Comment,Exec,Category, path to the file 363 | --all-sys-path | --asc (options): search only in /etc /usr /opt 364 | Without supported options (begins with --) will list or search in default output' 365 | ;; 366 | dump ) 367 | echo ' 368 | Dump RAW content of *.desktop files to stdout 369 | --dump-all | --da : search in / (may need root rights) 370 | --dump-default-path | --ddp : from default path 371 | --dump-sys-path | --dsp : dump content from /usr /etc /opt' 372 | ;; 373 | debug ) 374 | echo '--show-me | --sm (options): show content of this script' 375 | ;; 376 | var ) 377 | echo ' 378 | Search value of variables 379 | --var [variable] : search for variable in the *.desktop 380 | --show-uniq-def |--sud : show all uniq base variable names found in default path 381 | --var-sys | --vs : show all uniq base variable names found in /usr /etc /opt 382 | --show-sys-uniq |--ssu : show uniq variable names found in sys path /usr /etc /opt 383 | --no-var-sys|--nvs [xx]: show file names that does not contain string /usr /etc /opt 384 | --no-var | --nv [text] : show file names that does not contain string in default path' 385 | ;; 386 | sec ) 387 | echo ' 388 | Search section names in *.desktop files 389 | --sys-section-name | --ssn : search for uniq section names in /usr /etc /opt 390 | --default-section-name | --dsn : search for uniq section names in default path' 391 | ;; 392 | config ) 393 | echo ' 394 | Configuration 395 | --create-global-list | --cgl : scan system and save dirs into /opt/share/list-desktop-files/sorted.test 396 | --create-local-list | --cll : scan system and save dirs into $HOME/.list-desktop-path/custom-path/sorted.test 397 | 398 | --show-local-defaults | --sld : show content of $HOME/.list-desktop-path/custom-path/sorted.test 399 | --show-global-defaults | --sgd : show content of /opt/share/list-desktop-files/sorted.test 400 | 401 | --show-default-directories | --sdd : show internal dirs defined in array DefDskPath 402 | 403 | --remove-local-config : removing $HOME/.list-desktop-path/custom-path/sorted.test 404 | --remove-global-config : removing /opt/share/list-desktop-files/sorted.test 405 | 406 | --find-uniq-path | --fup (path) : find path that contain *.desktop files, default starting path is / 407 | --update-path-file | --upf [file name] : replacing all numbers and spaces with * in a file then sorting and leaving only uniq path' 408 | ;; 409 | info ) 410 | echo 'https://specifications.freedesktop.org/desktop-entry-spec/latest/ 411 | Short overview: 412 | "f" - File name with full path 413 | "u" - URL to website 414 | "d" - Directory 415 | "n" - Name of the file without path 416 | Single source: 417 | %f %u %d %n 418 | Multiple sources: 419 | %F %U %D %N 420 | Other: 421 | %k URI/location of desktop file 422 | %v name of the device' 423 | ;; 424 | usage ) 425 | echo 'Usage examples 426 | List content with default options: 427 | lsdesktopf 428 | Search only for specific text in default output: 429 | lsdesktopf gtk 430 | lsdesktopf game 431 | Use --var option (supporting grep syntax): 432 | --var-sys has same syntax as --var 433 | --var Name= 434 | --var "Name\[zn_CN\]" -e "Exec=" 435 | Reverse search 436 | --no-var Execute 437 | --no-var-sys "Name\[en_GB\]" 438 | Scan for all *.desktop files in /usr /etc /opt 439 | has same syntax as without supported options 440 | --asc 441 | --asc gtk 442 | Use --find-uniq-path or --fup 443 | --fup 444 | --fup /usr /etc 445 | Update a file that contains list of path 446 | --upf filename' 447 | ;; 448 | esac 449 | fi 450 | ;; 451 | --var ) 452 | ReCreateDskPath "$@" 453 | 454 | if [[ ! -z "$2" ]];then 455 | Var="$2" 456 | if [[ "$#" -gt 2 ]];then 457 | OptionsToGrep=($@); 458 | # Additional="${OptionsToGrep[@]:2}" ; 459 | fi; 460 | Opts="var" 461 | echo "${OptionsToGrep[@]:2}" 462 | SearchContentOfVariable "$@" 463 | else 464 | echo "Error, parameter to --var is missing 465 | example: --var MimeType" 466 | fi 467 | ;; 468 | --no-var | --nv ) 469 | ReCreateDskPath "$@" 470 | 471 | if [[ ! -z "$2" ]];then 472 | Var="$2" 473 | Opts="no-var" 474 | SearchContentOfVariable "$@" 475 | else 476 | echo "Error, parameter to --var is missing 477 | example: --no-var MimeType" 478 | fi 479 | ;; 480 | --var-sys | --vs) 481 | # ReCreateDskPath 482 | if [[ ! -z "$2" ]];then 483 | Var="$2" 484 | if [[ "$#" -gt 2 ]];then 485 | OptionsToGrep=($@); 486 | Additional="${OptionsToGrep[@]:2}" ; 487 | fi; 488 | Opts="var-sys" 489 | SearchContentOfVariable "$@" 490 | else 491 | echo "Error, parameter to --var-sys is missing 492 | example: --var MimeType" 493 | fi 494 | ;; 495 | --no-var-sys | --nvs ) 496 | if [[ ! -z "$2" ]];then 497 | find /usr /etc /opt -type f -name "*\.desktop" -exec grep -i -H -L "$2" \; 498 | else 499 | echo 'No options are given.' 500 | fi 501 | ;; 502 | --dump-all | --da ) 503 | grep -i ^ -H -R --include \*.desktop "/" 504 | ;; 505 | --dump-sys-path | --dsp ) 506 | grep -i ^ -H -R --include \*.desktop "/usr /etc /opt" 507 | ;; 508 | --dump-default-path | --ddp ) 509 | Opts="ddp" 510 | ReCreateDskPath "$@" 511 | SearchContentOfVariable 512 | ;; 513 | --show-uniq-def | --sud ) 514 | Opts="sud" 515 | ReCreateDskPath "$@" 516 | SearchContentOfVariable "$@" 517 | ;; 518 | --show-uniq-only | --suo ) 519 | OffPrint="yes" 520 | Opts=suo 521 | ReCreateDskPath "$@" 522 | RawView 523 | ;; 524 | --show-sys-uniq | --ssu ) 525 | Opts="sys-uniq" 526 | SearchContentOfVariable "$@" 527 | ;; 528 | --find-uniq-path | --fup ) 529 | if [[ ! -z "$2" ]]; then 530 | for StartCmdLine in "$@"; 531 | do 532 | if [[ -d "$StartCmdLine" ]]; then 533 | InPath="$StartCmdLine" 534 | fi 535 | find "$InPath" -type f -name "*\.desktop" -exec dirname "{}" \; | sort | uniq 536 | if [[ "$InPath" == "/" ]];then 537 | exit 0 538 | fi 539 | done 540 | else 541 | find / -type f -name "*\.desktop" -exec dirname "{}" \;| sort | uniq 542 | fi ;; 543 | --all-sys-path | --asc) 544 | Opts="scan-sys-path" 545 | ReCreateDskPath "$@" 546 | ListDefault "$@" 547 | ;; 548 | --create-local-list | --cll) 549 | mkdir -p "$(dirname $LocalArray)" 550 | find / -type f -name "*\.desktop" -exec dirname "{}" \; | sort | uniq > "$LocalArray" 551 | ;; 552 | --update-path-file | --upf) 553 | if [[ "$UID" != 0 ]];then 554 | echo 'You must start it as user root' 555 | exit 1 556 | else 557 | if [[ -z "$2" ]];then 558 | echo 'path to file is missing' 559 | else 560 | if [[ -f "$2" ]];then 561 | mkdir -p "$(dirname $GlobalArray)" 562 | find /usr /etc /opt -type f -name "*\.desktop" -exec dirname "{}" \; | sort | uniq >> "$2"; 563 | sed -i -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' -e 's/[0-9]\.[0-9]*/*/g' -e 's/**\*/*/g' "$2"; 564 | uniq -u "$2" /tmp/uniq-tmp.txt 565 | cp "/tmp/uniq-tmp.txt" "$2" 566 | else 567 | echo "Destion is not a file" 568 | fi 569 | fi 570 | fi 571 | ;; 572 | --create-global-list | --cgl) 573 | if [[ "$UID" != 0 ]];then 574 | echo 'You must start it as user root' 575 | exit 1 576 | else 577 | mkdir -p "$(dirname $GlobalArray)" 578 | find / -type f -name "*\.desktop" -exec dirname "{}" \; | sort | uniq > "$GlobalArray" 579 | fi 580 | ;; 581 | 582 | --show-local-defaults | --sld) 583 | if [[ -f "$HOME/.list-desktop-path/custom-path/sorted.test" ]];then 584 | cat "$HOME/.list-desktop-path/custom-path/sorted.test" 585 | else 586 | echo 'Does not exist $HOME/.list-desktop-path/custom-path/sorted.test' 587 | fi 588 | ;; 589 | --show-global-defaults | --sgd) 590 | if [[ -f "/opt/share/list-desktop-files/sorted.test" ]];then 591 | cat "/opt/share/list-desktop-files/sorted.test" 592 | else 593 | echo 'Does not exist /opt/share/list-desktop-files/sorted.test' 594 | fi 595 | ;; 596 | --show-default-directories | --sdd) 597 | for SDD in "${DefDskPath[@]}"; do 598 | echo "$SDD" 599 | done 600 | ;; 601 | --remove-local-config) 602 | rm -i "$HOME/.list-desktop-path/custom-path/sorted.test" 603 | ;; 604 | --remove-global-config) 605 | if [[ "$UID" -eq "0" ]];then 606 | rm -i "/opt/share/list-desktop-files/sorted.test" 607 | else 608 | echo You must be root! 609 | fi 610 | ;; 611 | --show-me | --sm) 612 | if [[ -z $2 ]];then 613 | cat "$0" 614 | echo '# my path: '" $0" 615 | else 616 | grep -n "$2" "$0" | grep -v -e "IGNORE" -e ^"# " 617 | fi 618 | ;; 619 | --sys-section-name | --ssn) 620 | grep -e ^"\[" -h -R --include *\.desktop /usr /etc /opt | sort | uniq 621 | ;; 622 | --default-section-name | --dsn) 623 | OffPrint="no" 624 | Opts='sdsn' 625 | ReCreateDskPath "$@" 626 | 627 | SearchContentOfVariable 628 | ;; 629 | * ) 630 | ReCreateDskPath "$@" 631 | 632 | ListDefault "$@" 633 | ;; 634 | esac 635 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /ListDefaultPath.txt: -------------------------------------------------------------------------------- 1 | /etc/dynamic/launchers/scanner 2 | /etc/xdg/autostart 3 | /etc/xdg/xfce*/panel/launcher-* 4 | /lib/gnome-settings-daemon-*/gtk-modules 5 | /lib/libreoffice/share/xdg 6 | /usr/etc/xdg/autostart 7 | /usr/lib/gnome-settings-daemon-*/gtk-modules 8 | /usr/lib/libreoffice/share/xdg 9 | /usr/local/share/applications 10 | /usr/share/applications 11 | /usr/share/apps/kdm/programs 12 | /usr/share/apps/kdm/sessions 13 | /usr/share/apps/solid/actions 14 | /usr/share/autostart 15 | /usr/share/dist/desktop-files/default 16 | /usr/share/gdm/autostart 17 | /usr/share/gdm/autostart/LoginWindow 18 | /usr/share/gdm/greeter/autostart 19 | /usr/share/gnome/autostart 20 | /usr/share/kde* 21 | /usr/share/mate/wm-properties 22 | /usr/share/mga/dm 23 | /usr/share/mimelnk/application 24 | /usr/share/mimelnk/chemical 25 | /usr/share/parole 26 | /usr/share/parole/parole-plugins-* 27 | /usr/share/Thunar/sendto 28 | /usr/share/wayland-sessions 29 | /usr/share/xfce*/helpers 30 | /usr/share/xfce*/panel-plugins 31 | /usr/share/xfce*/panel/plugins 32 | /usr/share/xgreeters 33 | /usr/share/xsessions 34 | /etc/xdg/autostart 35 | /opt/teamviewer/tv_bin/desktop 36 | /opt/wine-staging/share/applications 37 | /usr/lib/gnome-settings-daemon-*.*/gtk-modules 38 | /usr/lib/libreoffice/share/xdg 39 | /usr/local/share/applications 40 | /usr/share/applications 41 | /usr/share/applications/inputmethods 42 | /usr/share/apps/solid/actions 43 | /usr/share/gdm/autostart/LoginWindow 44 | /usr/share/gdm/greeter/autostart 45 | /usr/share/gnome/autostart 46 | /usr/share/hedgewars/Data/misc 47 | /usr/share/J*Z/Desktop/KDE 48 | /usr/share/J*Z/Desktop/Menu 49 | /usr/share/kde*/services 50 | /usr/share/kde*/services/phononbackends 51 | /usr/share/kde*/services/ServiceMenus 52 | /usr/share/kservices* 53 | /usr/share/kservices*/qimageioplugins 54 | /usr/share/kservicetypes* 55 | /usr/share/lirc/contrib 56 | /usr/share/mimelnk/application 57 | /usr/share/phoronix-test-suite/pts-core/static 58 | /usr/share/Quamachi/Desktop/Menu 59 | /usr/share/speech-dispatcher/conf/desktop 60 | /usr/share/themes/blondie/matchbox 61 | /usr/share/themes/Default/matchbox 62 | /usr/share/themes/MBOpus/matchbox 63 | /usr/share/Thunar/sendto 64 | /usr/share/xfce*/helpers 65 | /usr/share/xfce*/panel-plugins 66 | /usr/share/xfce*/panel/plugins 67 | /usr/share/xsessions 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # list-desktop-files 2 | list available *.desktop files and search in their content 3 | -------------------------------------------------------------------------------- /lsdesktopf_NO_EVN_VARIABLES: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Version 1.0.4-3 3 | # 4 | # License: GPL3 5 | # 6 | # Author: Andy Crowd 7 | # Tested in Arch Linux 8 | # Search in *.desktop for "Categories" and "Exec" 9 | # 10 | 11 | unset IFS 12 | IFS=" 13 | " 14 | One="$1" 15 | #Two="$2" 16 | AddCmd=($@); 17 | 18 | GlobalArray="/opt/share/ldf/sorted.test" 19 | LocalArray="$HOME/.ldf/sorted.test" 20 | 21 | ### The DefDskPath variable contains list of default folders 22 | DefDskPath+=("/etc/dynamic/launchers/scanner") 23 | DefDskPath+=("/etc/xdg/autostart") 24 | DefDskPath+=("/etc/xdg/xfce*/panel/launcher-*") 25 | DefDskPath+=("/lib/gnome-settings-daemon-*/gtk-modules") 26 | DefDskPath+=("/lib/libreoffice/share/xdg") 27 | DefDskPath+=("/usr/etc/xdg/autostart") 28 | DefDskPath+=("/usr/lib/gnome-settings-daemon-*/gtk-modules") 29 | DefDskPath+=("/usr/lib/libreoffice/share/xdg") 30 | DefDskPath+=("/usr/local/share/applications") 31 | DefDskPath+=("/usr/share/applications") 32 | DefDskPath+=("/usr/share/apps/kdm/programs") 33 | DefDskPath+=("/usr/share/apps/kdm/sessions") 34 | DefDskPath+=("/usr/share/apps/solid/actions") 35 | DefDskPath+=("/usr/share/autostart") 36 | DefDskPath+=("/usr/share/dist/desktop-files/default") 37 | DefDskPath+=("/usr/share/gdm/") 38 | #DefDskPath+=("/usr/share/gdm/autostart") 39 | #DefDskPath+=("/usr/share/gdm/autostart/LoginWindow") 40 | #DefDskPath+=("/usr/share/gdm/greeter/autostart") 41 | DefDskPath+=("/usr/share/gnome/autostart") 42 | DefDskPath+=("/usr/share/kde*") 43 | DefDskPath+=("/usr/share/mate/wm-properties") 44 | DefDskPath+=("/usr/share/mga/dm") 45 | DefDskPath+=("/usr/share/mimelnk/application") 46 | DefDskPath+=("/usr/share/mimelnk/chemical") 47 | DefDskPath+=("/usr/share/parole") 48 | #DefDskPath+=("/usr/share/parole/parole-plugins-*") 49 | DefDskPath+=("/usr/share/Thunar/sendto") 50 | DefDskPath+=("/usr/share/wayland-sessions") 51 | DefDskPath+=("/usr/share/xfce*/helpers") 52 | DefDskPath+=("/usr/share/xfce*/panel-plugins") 53 | DefDskPath+=("/usr/share/xfce*/panel/plugins") 54 | DefDskPath+=("/usr/share/xgreeters") 55 | DefDskPath+=("/usr/share/xsessions") 56 | DefDskPath+=("/etc/xdg/autostart") 57 | DefDskPath+=("/opt/teamviewer/tv_bin/desktop") 58 | DefDskPath+=("/opt/wine-staging/share/applications") 59 | DefDskPath+=("/usr/lib/gnome-settings-daemon-*.*/gtk-modules") 60 | DefDskPath+=("/usr/lib/libreoffice/share/xdg") 61 | DefDskPath+=("/usr/local/share/applications") 62 | DefDskPath+=("/usr/share/applications") 63 | DefDskPath+=("/usr/share/applications/inputmethods") 64 | DefDskPath+=("/usr/share/apps/solid/actions") 65 | DefDskPath+=("/usr/share/gnome/autostart") 66 | DefDskPath+=("/usr/share/hedgewars/Data/misc") 67 | DefDskPath+=("/usr/share/J*Z/Desktop/KDE") 68 | DefDskPath+=("/usr/share/J*Z/Desktop/Menu") 69 | DefDskPath+=("/usr/share/kde*/services") 70 | DefDskPath+=("/usr/share/kde*/services/phononbackends") 71 | DefDskPath+=("/usr/share/kde*/services/ServiceMenus") 72 | DefDskPath+=("/usr/share/kservices*") 73 | DefDskPath+=("/usr/share/kservices*/qimageioplugins") 74 | DefDskPath+=("/usr/share/kservicetypes*") 75 | DefDskPath+=("/usr/share/lirc/contrib") 76 | DefDskPath+=("/usr/share/mimelnk/application") 77 | DefDskPath+=("/usr/share/phoronix-test-suite/pts-core/static") 78 | DefDskPath+=("/usr/share/Quamachi/Desktop/Menu") 79 | DefDskPath+=("/usr/share/speech-dispatcher/conf/desktop") 80 | DefDskPath+=("/usr/share/themes/") 81 | DefDskPath+=("/usr/share/Thunar/sendto") 82 | DefDskPath+=("/usr/share/xfce*/helpers") 83 | DefDskPath+=("/usr/share/xfce*/panel-plugins") 84 | DefDskPath+=("/usr/share/xfce*/panel/plugins") 85 | DefDskPath+=("/usr/share/xsessions") 86 | 87 | ########################################## 88 | AddKorora(){ 89 | DefDskPath+=("/usr/lib64/gnome-settings-daemon-*/gtk-modules") 90 | DefDskPath+=("/usr/lib64/libreoffice/share/xdg") 91 | DefDskPath+=("/usr/share/akonadi/agents") 92 | DefDskPath+=("/usr/share/anaconda/gnome") 93 | DefDskPath+=("/usr/share/applications") 94 | DefDskPath+=("/usr/share/applications/kde*") 95 | DefDskPath+=("/usr/share/carddecks") 96 | # DefDskPath+=("/usr/share/doc") 97 | DefDskPath+=("/usr/share/gcompris") 98 | DefDskPath+=("/usr/share/gdm/autostart/LoginWindow") 99 | DefDskPath+=("/usr/share/kcm_componentchooser") 100 | DefDskPath+=("/usr/share/kcmsolidactions") 101 | DefDskPath+=("/usr/share/kf*/kmoretools/presets-kmoretools") 102 | DefDskPath+=("/usr/share/kf*/locale/countries") 103 | DefDskPath+=("/usr/share/kf*/locale/currency") 104 | DefDskPath+=("/usr/share/khelpcenter/plugins") 105 | DefDskPath+=("/usr/share/khelpcenter/searchhandlers") 106 | DefDskPath+=("/usr/share/kio_desktop") 107 | DefDskPath+=("/usr/share/kmines/themes") 108 | DefDskPath+=("/usr/share/konqsidebartng/virtual_folders/remote") 109 | DefDskPath+=("/usr/share/konqsidebartng/virtual_folders/services") 110 | DefDskPath+=("/usr/share/konqueror/dirtree/remote") 111 | DefDskPath+=("/usr/share/konversation/themes") 112 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_energyinfo") 113 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_fileindexermonitor") 114 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_lookandfeel") 115 | DefDskPath+=("/usr/share/kpackage/kcms/kcm_splashscreen") 116 | DefDskPath+=("/usr/share/kpat/themes") 117 | DefDskPath+=("/usr/share/kservicetypes*") 118 | DefDskPath+=("/usr/share/ksmserver/screenlocker/org.kde.passworddialog") 119 | DefDskPath+=("/usr/share/ksmserver/themes") 120 | DefDskPath+=("/usr/share/ksmserver/windowmanagers") 121 | DefDskPath+=("/usr/share/ksysguard/scripts/smaps") 122 | DefDskPath+=("/usr/share/kwin/decorations/kwin*_decoration_qml_plastik") 123 | DefDskPath+=("/usr/share/kwin/desktoptabbox/previews") 124 | DefDskPath+=("/usr/share/kwin/effects") 125 | DefDskPath+=("/usr/share/kwin/scripts") 126 | DefDskPath+=("/usr/share/kwin/tabbox") 127 | DefDskPath+=("/usr/share/kxmlgui*/parley/themes") 128 | DefDskPath+=("/usr/share/lirc/contrib") 129 | DefDskPath+=("/usr/share/locale/") 130 | #DefDskPath+=("/usr/share/locale/l10n") 131 | DefDskPath+=("/usr/share/parley/plugins") 132 | DefDskPath+=("/usr/share/parley/themes") 133 | DefDskPath+=("/usr/share/plasma/desktoptheme") 134 | DefDskPath+=("/usr/share/plasma/kcms/screenlocker_kcm") 135 | DefDskPath+=("/usr/share/plasma/layout-templates") 136 | DefDskPath+=("/usr/share/plasma/look-and-feel") 137 | DefDskPath+=("/usr/share/plasma/packages") 138 | DefDskPath+=("/usr/share/plasma/plasmoids") 139 | DefDskPath+=("/usr/share/plasma/shareprovider") 140 | DefDskPath+=("/usr/share/plasma/shells") 141 | DefDskPath+=("/usr/share/plasma/wallpapers") 142 | DefDskPath+=("/usr/share/remoteview") 143 | DefDskPath+=("/usr/share/sddm/themes") 144 | DefDskPath+=("/usr/share/services") 145 | DefDskPath+=("/usr/share/solid/actions") 146 | DefDskPath+=("/usr/share/solid/devices") 147 | DefDskPath+=("/usr/share/soprano/plugins") 148 | DefDskPath+=("/usr/share/templates") 149 | DefDskPath+=("/usr/share/wallpapers") 150 | DefDskPath+=("/usr/share/yumex-dnf") 151 | } 152 | ########################################## 153 | ### Uncomment below to add directories found in Korora Linux 154 | #AddKorora 155 | ##### 156 | if [[ ! -f "$LocalArray" ]];then 157 | if [[ -f "$GlobalArray" ]];then 158 | FilePath="$GlobalArray" 159 | 160 | else 161 | ### ADskPath contains list of "decoded" path with command "file" 162 | ### command "file" can handle wildcards such as * that is useful when it is multiple or new path with versions number is available 163 | ### command "grep" is used to separate available from not existing path 164 | ADskPath=($(for FromDDP in "${DefDskPath[@]}";do 165 | file "$FromDDP"; 166 | done |sort -u | grep -v \)$ | grep ^/ |rev|cut -d: -f2- |rev)) 167 | #################### 168 | fi 169 | else 170 | FilePath="$LocalArray" 171 | fi 172 | if [[ "${#ADskPath[@]}" == 0 ]]; then 173 | ADskPath=($(sed -i -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' "$FilePath"; 174 | while read FromFile;do echo "$FromFile" ; 175 | done < "$FilePath"|xargs file|sort -u | grep -v \)$ |grep ^/ |rev|cut -d: -f2-|rev)) 176 | ### $BDskPath is used to add path that depends on such variables as $HOME and $XDG related 177 | BDskPath+=("$HOME/.local/share/applications") 178 | BDskPath+=("$HOME/.config/autostart") 179 | BDskPath+=("/home/$USER/.local/share/applications") 180 | BDskPath+=("/home/$USER/.config/autostart") 181 | 182 | # BDskPath+=("$XDG_CONFIG_DIRS/autostart") 183 | BDskPath+=("$XDG_CONFIG_HOME/autostart") 184 | BDskPath+=("$HOME/.local/share/xfce*/helpers") 185 | BDskPath+=("/home/$USER/.local/share/xfce*/helpers") 186 | BDskPath+=("$XDG_DATA_HOME/applications") 187 | ############# 188 | 189 | 190 | # BDskPath+=("$HOME/.local/share") 191 | # if [[ -f "$HOME/.config/user-dirs.dirs" ]];then 192 | # BPath="$(grep XDG_DESKTOP_DIR ./.config/user-dirs.dirs | cut -d= -f2- | sed -e 's/^\"//' -e 's/\"$//' )" 193 | # BDskPath+=("$BPath") 194 | # else 195 | # if [[ -f "$XDG_CONFIG_DIRS/user-dirs.dirs" ]];then 196 | # BDskPath+=("$(grep XDG_DESKTOP_DIR "$XDG_CONFIG_DIRS/user-dirs.dirs"|cut -d= -f2-|sed -e 's/^\"//' -e 's/\"$//' )") 197 | # [[ ! -z "$DesktopDir" ]] && BDskPath="$DesktopDir" 198 | # fi 199 | # fi 200 | 201 | fi 202 | #ADskPath+="$AddWithVariables"; 203 | 204 | for AddWithVariables in "${BDskPath[@]}"; do 205 | if [ -d "$AddWithVariables" ];then 206 | ADskPath+=("$AddWithVariables"); 207 | 208 | fi 209 | done 210 | #echo "${NoEmpty[@]}" 211 | #echo "${DefDskPath[@]}" 212 | #exit 1 213 | ### soring out only uniq path in case if $XDG related and $HOME are pointing on a similar destination. || $InDskPath, $ADskPath, NoEmpty 214 | NoEmpty=($(for InDskPath in "${ADskPath[@]}";do echo "$InDskPath";done|sort -u;)); 215 | 216 | ### used to find out path that can be used || scan-sys-path, $DskPath, NoEmpty 217 | ReCreateDskPath(){ 218 | case "$Opts" in 219 | OnlyNew1 ) 220 | DskPath=($(if [[ ! -z $2 ]]; then 221 | for StartCmdLine in "$@"; 222 | do 223 | if [[ -d "$StartCmdLine" ]]; then 224 | InPath="$StartCmdLine" 225 | fi 226 | find "$InPath" -type f -name "*\.desktop" -exec dirname "{}" \;|sort -u 227 | 228 | if [[ "$InPath" == "/" ]];then 229 | exit 0 230 | fi 231 | done 232 | else 233 | find / -type f -name "*\.desktop" -exec dirname "{}" \; |sort -u 234 | fi)) 235 | ;; 236 | scan-sys-path ) 237 | DskPath=($(find "/usr/" "/etc/" "/opt/" -type f -name "*\.desktop" -exec dirname "{}" \;|sort -u)) 238 | ;; 239 | *) 240 | DskPath=(${NoEmpty[@]}) 241 | ;; 242 | esac 243 | } 244 | ######################################## 245 | gdxstdalone(){ 246 | IFS=" 247 | " 248 | case $2 in 249 | g | glob ) 250 | List_XML=($(find "/usr/" "/etc/" "$HOME/.local/" "$HOME/.config" -type f -name "*\.xml")); 251 | ;; 252 | l | local ) 253 | List_XML=($(find "$HOME/.config" "$HOME/.local/" -type f -name "*\.xml")); 254 | ;; 255 | * ) 256 | List_XML=($(find "/usr/share/mime/packages/" "/usr/share/mime/application/" "$HOME/.local/share/" -type f -name "*\.xml")); 257 | ;; 258 | esac 259 | 260 | case $2 in 261 | 0 ) 262 | for In_XML_List in "${List_XML[@]}";do 263 | find "$In_XML_List" -type f -name "*\.xml" -exec grep -e "mime-type" -e "type=" "{}" \; 264 | done | awk -F"\"" '{ 265 | if(index($0,"mime-type")){ 266 | if(index($0,"type type=")){ 267 | ContentArray[$2]=1; 268 | }else{ 269 | if(index($0," type=")){ 270 | ContentArray[$4]=1}}}}END{for (I in ContentArray)print I}' 271 | ;; 272 | 1 ) 273 | for In_XML_List in "${List_XML[@]}";do 274 | find "$In_XML_List" -type f -name "*\.xml" -exec grep -e "mime-type" -e "type=" "{}" \; 275 | done | awk -F"\"" '{ 276 | if(index($0,"mime-type")){ 277 | if(index($0,"type type=")){ 278 | A=substr($2,0,index($2,"/")-1); 279 | ContentArray[A]=1; 280 | }else{ 281 | if(index($0," type=")){ 282 | B=substr($4,0,index($4,"/")-1); 283 | ContentArray[B]=1}}}}END{for (I in ContentArray)print I}' 284 | ;; 285 | 2 ) 286 | for In_XML_List in "${List_XML[@]}";do 287 | find "$In_XML_List" -type f -name "*\.xml" -exec grep -e "mime-type" -e "type=" "{}" \; 288 | done | awk -F"\"" '{ 289 | if(index($0,"mime-type")){ 290 | if(index($0,"type type=")){ 291 | A=substr($2,index($2,"/")+1); 292 | ContentArray[A]=1; 293 | }else{ 294 | if(index($0," type=")){ 295 | B=substr($4,index($4,"/")+1); 296 | ContentArray[B]=1}}}}END{for (I in ContentArray)print I}' 297 | ;; 298 | 3 ) 299 | for In_XML_List in "${List_XML[@]}";do 300 | find "$In_XML_List" -type f -name "*\.xml" -exec grep "pattern=" "{}" \; 301 | done | awk -F"\"" '{ 302 | if(index(tolower($0),"pattern="))ContentArray[$2]=1; 303 | }END{ 304 | for (I in ContentArray)print I 305 | }' 306 | ;; 307 | -gfx) 308 | for In_XML_List in "${List_XML[@]}";do 309 | find "$In_XML_List" -type f -name "*\.xml" -exec awk -v ShowItems="$3" '{ 310 | if(index($0,"") != 0){Astop=2;YES=0; 317 | ShowMIME=""; 318 | ShowSubClass=""; 319 | ShowGenericIcon=""; 320 | ShowAcronym=""; 321 | ShowEAcronym=""; 322 | ShowAlias=""; 323 | GAcal=0; 324 | }; 325 | if(Astop == 1) 326 | { 327 | if(index($0,"") == 0 && index($0,"") != 0) 337 | { 338 | Acomment=substr(SP,index(SP,"")+9); 339 | Bcomment=substr(Acomment,0,index(Acomment,"")-1); 340 | } 341 | else 342 | { 343 | Acomment=substr(SP,index(SP,"")-1); 345 | Bcomment=substr(TMPcomment,index(Acomment,">")+1); 346 | }; 347 | if(index(SP,"")-2); 351 | gsub(/ type=/,"Sub class of: ",EndTagSSC); 352 | ShowSubClass=EndTagSSC; 353 | } 354 | if(index(SP,"")-2); 358 | gsub(/ name=/,"Icon: ",EndTagGI); 359 | ShowGenericIcon=EndTagGI; 360 | } 361 | if(index(SP,"") != 0) 362 | { 363 | StartTagAcr=substr(SP,index(SP,"")+9) 364 | EndTagAcr=substr(StartTagAcr,0,index(StartTagAcr,"/")-2); 365 | ShowAcronym=EndTagAcr; 366 | } 367 | if(index(SP,"") != 0) 368 | { 369 | StartTagEAcr=substr(SP,index(SP,"")+18) 370 | EndTagEAcr=substr(StartTagEAcr,0,index(StartTagEAcr,"/")-2); 371 | ShowEAcronym=EndTagEAcr; 372 | } 373 | if(index(SP,"")-2); 377 | gsub(/ type=/,"Alias: ",EndTagAlias); 378 | ShowAlias=EndTagAlias; 379 | }; 380 | for(I=0; I <= NumPatt;I++) 381 | { 382 | GetStr=substr(GG[I],0,index(GG[I],"\"/>")); 383 | if(index(GetStr,"=") == 1 ){printf substr(GetStr,2); 384 | if(length(Bcomment) == 0){printf " ----- %s",ShowMIME}else{printf " ----- %s",Bcomment}; 385 | if(length(ShowMIME) == 0 && length(Bcomment) == 0) 386 | { 387 | AnewMIME=substr(AltFix,index(AltFix,"mime-type")+1); 388 | BnewMIME=substr(AnewMIME,0,index(AnewMIME,">")-1); 389 | CnewMIME=substr(BnewMIME,index(BnewMIME,"type=\"")+5); 390 | printf CnewMIME; 391 | }; 392 | NumberItems=split(ShowItems,ArrayItems,","); 393 | ShowFileName=FILENAME; 394 | for( getItem in ArrayItems){ 395 | if(ArrayItems[getItem] == "sf" && ShowFileName ){printf " @*\033[2;32m %s",ShowFileName"\033[0m";ShowFileName=""} 396 | if(ArrayItems[getItem] == "sm" && ShowMIME ){printf " @*\033[2;93m %s",ShowMIME"\033[0m";} 397 | if(ArrayItems[getItem] == "ssc" && ShowSubClass){printf " @*\033[2;53m %s",ShowSubClass"\033[0m";ShowSubClass=""} 398 | if(ArrayItems[getItem] == "sgi" && ShowGenericIcon){printf " @*\033[2;49m %s",ShowGenericIcon"\033[0m";ShowGenericIcon=""} 399 | if(ArrayItems[getItem] == "sa" && ShowAcronym){printf " @*\033[2;49m %s",ShowAcronym"\033[0m";ShowAcronym=""} 400 | if(ArrayItems[getItem] == "sea" && ShowEAcronym){printf " @*\033[2;49m %s",ShowEAcronym"\033[0m";ShowEAcronym=""} 401 | if(ArrayItems[getItem] == "sal" && ShowAlias) 402 | { 403 | TotalAliases=split(SP,GetAliasStart,"")-2); 408 | }; 409 | if(TotalAliases >= 0)for (II in GetAls) 410 | if(index(GetAls[II],"<") <= index(GetAls[II],"/>") )printf substr(GetAls[II],index(GetAls[II],"=")+1)";"; 411 | delete GetAls; 412 | printf "\033[0m" 413 | } 414 | } 415 | printf "\n";} 416 | } 417 | SP=1} 418 | }' "{}" \; 419 | done 420 | ;; 421 | -gx ) if [[ ! -z "$3" ]];then 422 | for In_XML_List in "${List_XML[@]}";do 423 | find "$In_XML_List" -type f -name "*\.xml" -exec grep -e "mime-type" -e "type=" "{}" \; 424 | done | awk -F"\"" -v FindForType="$3" '{ 425 | if(index($0,"mime-type")){ 426 | if(index($0,"type type=")){ 427 | A=substr($2,index($2,"/")+1); 428 | if(FindForType == substr($2,0,index($2,"/")-1)) 429 | ContentArray[A]=1; 430 | }else{ 431 | if(index($0," type=")){ 432 | B=substr($4,index($4,"/")+1); 433 | if(FindForType == substr($2,0,index($2,"/")-1)) 434 | ContentArray[B]=1 435 | }}}}END{for (I in ContentArray)print I}' 436 | else 437 | echo 'Missing options! Use first part of MIME-type,e.g. inode' 438 | fi 439 | ;; 440 | *) 441 | for In_XML_List in "${List_XML[@]}";do 442 | find "$In_XML_List" -type f -name "*\.xml" -print0 | xargs -0 awk -F"\"" '{YesM=0; 443 | if(index($0,"mime-type")){if(index($0,"type type=")){ContentArray[Count++]=$2" == ";YesM=1}else{if(index($0," type=")){ 444 | ContentArray[Count++]=$4" == "}}} 445 | if(index($0,"")){ 446 | GetString=substr($0,index($0,">")+1) 447 | GetTMP=" "substr(GetString,0,index(GetString,"= 1) Ctgr=substr($0,index($0,"=")+1); 485 | if(index($0,"Name=") == 1) inNm=substr($0,index($0,"=")+1); 486 | if(index($0,"Comment=") == 1) inComment=substr($0,index($0,"=")+1); 487 | if(index($0,"Command") == 1) inCmd=substr($0,index($0,"=")+1) ; 488 | if(index($0,"Module=") == 1) inExc=substr($0,index($0,"=")+1); 489 | if(index($0,"Exec=") == 1) inExc=substr($0,index($0,"=")+1); 490 | if(index($0,"Category=") >= 1) Ctgr=substr($0,index($0,"=")+1); 491 | if(index($0,"X-XFCE-Binaries=") >= 1) inExc=substr($0,index($0,"=")+1); 492 | }END{ 493 | if(! Ctgr ){E=inNm}else{E=Ctgr}; 494 | if(! inExc){CmdLine=inCmd}else{CmdLine=inExc}; 495 | if(! E)E=inComment; 496 | Z=CmdLine" # "E" # "Fil; 497 | if( index(tolower(Z),tolower(Seek)) && CmdLine ) print Z;}' "{}" \; 498 | else 499 | [[ -d "${fdPath}" || -f "${fdPath}" ]] && find "${fdPath}" -iname "*.desktop" -exec awk -v Fil="{}" -F"=" '//{ 500 | if(index($0,"Categories") == 1) Ctgr=substr($0,index($0,"=")+1); 501 | if(index($0,"Name=") == 1) inNm=substr($0,index($0,"=")+1); 502 | if(index($0,"Exec=") == 1) inExc=substr($0,index($0,"=")+1); 503 | if(index($0,"Comment=") == 1) inComment=substr($0,index($0,"=")+1); 504 | if(index($0,"Command=") == 1) inCmd=substr($0,index($0,"=")+1) ; 505 | if(index($0,"Category=") >= 1) Ctgr=substr($0,index($0,"=")+1); 506 | if(index($0,"X-XFCE-Binaries=") >= 1) inExc=substr($0,index($0,"=")+1); 507 | }END{ 508 | if(! Ctgr ){E=inNm}else{E=Ctgr}; 509 | if(! inExc){CmdLine=inCmd}else{CmdLine=inExc}; 510 | if(! E)E=inComment; 511 | Z=CmdLine" # "E" # "Fil" # "XFCEb; 512 | if(CmdLine)print Z;}' "{}" \; 513 | fi; 514 | fi 515 | done 516 | } 517 | ################### Search specific #### 518 | OffPrint="no"; 519 | SearchContentOfVariable(){ 520 | for fdPath in "${DskPath[@]}";do 521 | if [[ -d "${DskPath[Count]}" || -f "${DskPath[Count]}" ]]; 522 | then 523 | [[ "$OffPrint" == "no" ]] && printf "#\e[1;36m %s ${fdPath} \e[0m \n"; 524 | if [ ! -z "$One" ] && [[ -d "${fdPath}" || -f "${fdPath}" ]] ; 525 | then 526 | case $Opts in 527 | ### "$var" is used to search for variable names with "grep" in *.desktop 528 | var ) 529 | grep -e ^"$Var" "${AddCmd[@]:2}" -H -E -R --include "*\.desktop" "${fdPath}" 530 | ;; 531 | ### "ddp" is used to raw dump cotent of all *.desktop found in default path. || grep 532 | ddp ) 533 | grep ^ -H -R --include "*\.desktop" "${fdPath}" 534 | ;; 535 | ### "sud" showing uniq variables found in default path. || grep, cut 536 | sud ) 537 | grep '=' -R -h --include "*\.desktop" "${fdPath}"|cut -d= -f 1|grep -v -e "\[" -e ^\# |sort -u 538 | ;; 539 | ### "no-var" showing all *.desktop except them that contains contains specified string. || grep, find 540 | no-var ) 541 | find "${fdPath}" -type f -iname "*\.desktop" -exec grep -H -L -e "$Var" "${AddCmd[@]:2}" "{}" \; 542 | ;; 543 | ### "sdsn" showing only uniq section names found in default path. || grep, sed 544 | sdsn ) 545 | grep '\[*\]'$ -R -h --include "*\.desktop" "${fdPath}" | sed 's/ * //m' |grep ^'\[' |grep -v -e ^'#' -e '\]=' |sort -u 546 | ;; 547 | upfd ) 548 | if [[ ! -z "$2" ]];then FLang="$2"; 549 | else 550 | FLang=""; 551 | fi 552 | 553 | find "${fdPath}" -type f -name "*\.desktop" -exec awk -v GetLang="$FLang" -v ShowAvailableLanguages="$3" -F= '//{ 554 | if(index($1,"[") != 0 && index($1,"[") != 1 ){split($1,Lang,"[")UniqLang[Lang[2]]++}; 555 | if(index($1,"["GetLang"]") != 0 ){Item[cnt++]=$0}else { if(index($1,"]") == 0)Item[cnt++]=$0} 556 | }END{ 557 | printf "* \033[2;32m %s",FILENAME"\033[2;0m \n"; 558 | print "@ Total translations: "length(UniqLang); 559 | if(ShowAvailableLanguages)if(ShowAvailableLanguages == "all")if(length(UniqLang) != 0 ){ 560 | for(AllLang in UniqLang){sub("]","",AllLang);printf "%s",AllLang","};print "." 561 | }; 562 | for (ItemNumber in Item)print Item[ItemNumber]; 563 | }' "{}" \; | grep -v ^"\#" 564 | ;; 565 | more ) 566 | find "${fdPath}" -type f -name "*\.desktop" -exec awk -v FindIt="$2" -F= '/^create/;{ 567 | ToLowerOne=tolower($1); 568 | ToLowerFindIt=tolower(FindIt); 569 | ToLowerTwo=tolower($2); 570 | if(index($1,"]") == 0 ) 571 | if( index(ToLowerOne,"exec") != 0 || index(ToLowerOne,"name") != 0 || index(ToLowerOne,"comment") != 0 || index(ToLowerOne,"categories") != 0 || index(ToLowerOne,"command") != 0 || index(ToLowerOne,"module") != 0 || index(ToLowerOne,"x-xfce-binaries") != 0 ) {Var[CountV++]=$1;InString[CountS++]=substr($0,index($0,$2)); 572 | if(FindIt)if( index($1,"Exec") != 0 || index($1,"Exec") != 0 || index($1,"Name") != 0 || index($1,"Comment") != 0 || index($1,"Categories") != 0 || index($1,"Command") != 0 || index($1,"Module") != 0 || index($1,"X-XFCE-Binaries") != 0 )if(index(ToLowerTwo,ToLowerFindIt) != 0 )YES="1"; };}END{ 573 | if(YES == "1" ){printf "* \033[2;32m"FILENAME"\033[2;0m \n"; for(I in InString)if(length(Var[I]) != 0)print Var[I]"="InString[I]}; 574 | if(length(FindIt) == 0){printf "* \033[2;32m "FILENAME"\033[2;0m \n";for(I in InString)if(length(Var[I]) != 0)print Var[I]"="InString[I]}}' "{}" \;|grep -v -e ^"#" -e ^$ 575 | ;; 576 | # more ) 577 | # find "${fdPath}" -type f -name "*\.desktop" -exec awk -v FindIt="$2" -F= '/^create/;{ 578 | # if(index($1,"]") == 0 && index($1,"MimeType") == 0 && index($1,"Keywords") == 0){Var[CountV++]=$1;InString[CountS++]=substr($0,index($0,$2)); 579 | # if(FindIt)if(index($2,FindIt) != 0 && index($1,"MimeType") == 0 && index($1,"Keywords") == 0)YES="1"; };}END{ 580 | # if(YES == "1" ){print " "FILENAME; for(I in InString)if(length(Var[I]) != 0)print Var[I]"="InString[I]}; 581 | # if(length(FindIt) == 0){print " "FILENAME;for(I in InString)if(length(Var[I]) != 0)print Var[I]"="InString[I]}}' "{}" \;|grep -v -e ^"#" -e ^$ 582 | # ;; 583 | 584 | less ) 585 | find "${fdPath}" -type f -name "*\.desktop" -exec awk -v FindIt="$2" -v Trans="$3" -F= '/^create/;{ 586 | ToLowerTwo=tolower($2); 587 | ToLowerFindIt=tolower(FindIt); 588 | if(Trans) 589 | { 590 | split(Trans,ArrayTransLang,","); 591 | for(ReLangArray in ArrayTransLang )NewArrTrans[ArrayTransLang[ReLangArray]]=1; 592 | } 593 | if(index($1,"]") == 0) 594 | { 595 | Var[CountV++]=$1; 596 | InString[CountS++]=substr($0,index($0,$2)); 597 | if(FindIt)if(index(ToLowerTwo,ToLowerFindIt) != 0)YES="1"; 598 | }; 599 | if(index($1,"[") != 0 && index($1,"[") != 1 ){ 600 | split($1,Lang,"["); 601 | TmpLang=Lang[2]; 602 | UniqLang[TmpLang]++; 603 | sub("]","",TmpLang); 604 | if(Trans) 605 | { 606 | if( NewArrTrans[TmpLang] == 1 ) 607 | { 608 | Var[CountV++]=$1; 609 | InString[CountS++]=substr($0,index($0,$2)) 610 | } 611 | } 612 | }; 613 | if(index($1,"[") == 1){ 614 | Var[CountV++]=$1; 615 | InString[CountS++]=$0} 616 | }END{ 617 | if(YES == "1" ) 618 | { 619 | printf "* \033[2;32m" FILENAME "\033[0m\n @ Total translations: "length(UniqLang)": "; 620 | if(length(UniqLang) != 0)for(AllLang in UniqLang){sub("]","",AllLang);printf "%s",AllLang",";} 621 | print " "; 622 | for (I in InString)if(index(Var[I],"[") != 1 && length(Var[I]) != 0 && index(Var[I],"#") != 1 ) 623 | { 624 | if(index(InString[I]"=",Var[I]"=") != 1 ) 625 | { 626 | print Var[I]"="InString[I] 627 | } 628 | else 629 | { 630 | print Var[I]"=" 631 | } 632 | } 633 | else 634 | { 635 | if(index(Var[I],"[") == 1) 636 | printf "\033[2;33m"Var[I]"\033[2;0m\n" 637 | } 638 | } 639 | if(length(FindIt) == 0) 640 | { 641 | printf "* \033[2;32m" FILENAME "\033[0m \n@ Total translations: "length(UniqLang)": "; 642 | if(length(UniqLang) != 0)for(AllLang in UniqLang) 643 | { 644 | sub("]","",AllLang);printf "%s",AllLang","; 645 | } 646 | print " "; 647 | for (I in InString) 648 | if(index(Var[I],"[") != 1 && length(Var[I]) != 0 && index(Var[I],"#") != 1 ) 649 | { 650 | if(index(InString[I]"=",Var[I]"=") != 1 ) 651 | { 652 | print Var[I]"="InString[I] 653 | } 654 | else 655 | { 656 | print Var[I]"=" 657 | } 658 | } 659 | else 660 | { 661 | if(index(Var[I],"[") == 1) 662 | printf "\033[2;33m"Var[I]"\033[2;0m \n"} 663 | } 664 | }' "{}" \; 665 | ;; 666 | iov ) 667 | find "${fdPath}" -type f -name "*\.desktop" -exec awk -v FindIt="$2" -v Fname="$3" -F= '//{ 668 | if(FindIt){ 669 | SizeArray=split(FindIt,ArrayFindIt,","); 670 | if (index($0,"[") == 1 ) 671 | YesFoundIt[CountFinds++]=$0; 672 | for(CountFindItArray in ArrayFindIt ) 673 | NewArrFindIt[ArrayFindIt[CountFindItArray]]=1; 674 | if(NewArrFindIt[$1] == 1 ) 675 | { 676 | YesFoundIt[CountFinds++]=$0; 677 | UniqFound[$1]=1; 678 | } 679 | } 680 | }END{ 681 | if( length(UniqFound) == SizeArray ) 682 | { 683 | if(Fname == "filename" || Fname == "fn" || Fname == "sf" || Fname == "--sf" ) 684 | printf "* \033[2;32m"FILENAME"\033[0m \n"; 685 | for (GotFound in YesFoundIt ) 686 | { 687 | if(index(YesFoundIt[GotFound],"[") == 1 ) 688 | { 689 | printf "\033[2;33m"YesFoundIt[GotFound]"\033[0m \n" 690 | } 691 | else 692 | { 693 | print YesFoundIt[GotFound]; 694 | } 695 | }; 696 | } 697 | }' "{}" \; 698 | 699 | ;; 700 | 701 | esac 702 | 703 | fi; 704 | fi 705 | done 706 | 707 | case "$Opts" in 708 | ### "sys-uniq" showing uniq variable names found in /usr /etc /opt path. || find, cut, grep 709 | sys-uniq ) 710 | find "/usr" "/etc" "/opt" -type f -name "*\.desktop" -exec grep ^ "{}" \; | cut -d= -f1 | grep -v -e "\[" -e ^\# | sort -u 711 | ;; 712 | ### "var-sys" searching for variable name in system path /usr /etc /opt 713 | var-sys ) 714 | grep -e ^"$Var" "${AddCmd[@]:2}" -H -E -R --include "*\.desktop" /usr /etc /opt 715 | ;; 716 | esac 717 | } 718 | ######################################## 719 | 720 | RawView(){ 721 | for fdPath in "${DskPath[@]}";do 722 | if [[ -d "${DskPath[Count]}" || -f "${DskPath[Count]}" ]]; 723 | then 724 | [[ "$OffPrint" == "no" ]] && printf "#\e[1;36m %s ${fdPath} \e[0m \n"; 725 | if [ ! -z "$One" ] && [[ -d "${fdPath}" || -f "${fdPath}" ]] ; 726 | then 727 | [[ "$Opts" == "suo" ]] && grep ^ -R -h --include "*\.desktop" "${fdPath}"; 728 | fi; 729 | fi 730 | done | case $Opts in 731 | suo ) 732 | grep = |cut -d= -f1 |grep -v -e "\[" -e ^\#|sort -u 733 | ;; 734 | esac 735 | } 736 | 737 | ShowOrStartXsession(){ 738 | for FileName in /usr/share/xsessions/*;do 739 | X_Sessions+=("$(grep ^'Exec=' $FileName| cut -d= -f2-)"); 740 | X_Names+=("$(grep ^'Name=' $FileName| cut -d= -f2-)"' '); 741 | X_Comment+=("$(grep ^'Comment=' $FileName| cut -d= -f2-)"' '); 742 | X_DesktopNames+=("$(grep ^'DesktopNames=' $FileName| cut -d= -f2-)"' '); 743 | done 744 | CC=0; 745 | 746 | case $ToShowPart in 747 | n | name ) 748 | for ReadSessions in "${X_Names[@]}";do 749 | echo $CC $ReadSessions 750 | ((CC++)) 751 | done 752 | ;; 753 | c | comment ) 754 | for ReadSessions in "${X_Comment[@]}";do 755 | echo $CC $ReadSessions 756 | ((CC++)) 757 | done 758 | ;; 759 | dn | desktopname ) 760 | for ReadSessions in "${X_DesktopNames[@]}";do 761 | echo $CC $ReadSessions 762 | ((CC++)) 763 | done 764 | ;; 765 | a | all ) 766 | echo 'Number Name # Comment # Exec'; 767 | for ReadSessions in "${X_Sessions[@]}";do 768 | echo $CC ${X_Names[CC]} '#' ${X_Comment[CC]} '#' $ReadSessions; 769 | ((CC++)) 770 | done 771 | ;; 772 | *) 773 | for ReadSessions in "${X_Sessions[@]}";do 774 | echo $CC $ReadSessions 775 | ((CC++)) 776 | done 777 | ;; 778 | esac 779 | 780 | if [[ "$StartIt" == "1" ]];then 781 | echo 'Enter a session number:'; 782 | read Session_Number; 783 | if [[ "$Session_Number" =~ [0-9]+$ && "$Session_Number" -le "${#X_Sessions[@]}" ]];then 784 | 785 | if [[ "${X_Sessions[Session_Number]/\//}" == "${X_Sessions[Session_Number]}" ]];then 786 | startx /usr/bin/${X_Sessions[Session_Number]} 787 | else 788 | startx ${X_Sessions[Session_Number]} 789 | fi 790 | fi 791 | fi 792 | } 793 | 794 | ################### 795 | # Disabled options 796 | ################### 797 | #By using option "all" as 3rd option will show all available translations in a *.desktop file, 798 | # without it will show only amount of translations or additional variables with a chosen translation. 799 | # --uniq-per-file-default (lang) ("all") | --upfd : list variables found in default path 800 | # --uniq-per-file-sys (lang) ("all") | --upfs : list variables found in /usr /etc /opt' 801 | # --uniq-per-file-default | --upfd : show uniq entries per file in default path 802 | # --uniq-per-file-sys | --upfs : show uniq entries per file found in /usr /etc /opt' 803 | ############################ 804 | # dump - dump content of *.desktop files 805 | # dump ) 806 | # echo ' 807 | # Dump RAW content of *.desktop files to stdout 808 | # --dump-all | --da : search in / (may need root rights) 809 | # --dump-default-path | --ddp : from default path 810 | # --dump-sys-path | --dsp : dump content from /usr /etc /opt' 811 | # ;; 812 | # Update a file that contains list of path 813 | # --upf filename 814 | # --update-path-file | --upf [file name] : replacing all numbers and spaces with * in a file then sorting and leaving only uniq path' 815 | 816 | help_def(){ 817 | echo 'Showing all basic searchable content in a single line per file. 818 | Without any options it will list from all default path. 819 | All extended supported options begins with -- 820 | Deafult output to search in: Name/Comment,Exec,Category, path to the file 821 | --all-sys-path | --asc (options) 822 | using system path /usr /etc /opt 823 | 824 | Vertical and more userfiendly output. Search text in all available variables 825 | --more | --m (text) 826 | using default path 827 | --more-sys | --ms (text) 828 | using system path 829 | 830 | Same as option --more but is less userfiendly by outputing much more information 831 | --less | --l (text) (translation) 832 | using default path 833 | --less-sys | --ls (text) (translation) 834 | using system path /usr /etc /opt' 835 | } 836 | help_debug(){ 837 | echo '--show-me | --sm (options) 838 | show or search content in this script' 839 | } 840 | help_var(){ 841 | echo 'Search a value of the variables. Supporting grep syntax 842 | --var [variable] 843 | using default path 844 | --var-sys | --vs [variable] 845 | using system path /usr /etc /opt 846 | 847 | show file names that does not contain a string 848 | --no-var-sys|--nvs [xx] 849 | using system path /usr /etc /opt 850 | --no-var | --nv [text] 851 | using default path 852 | 853 | show all uniq base variable names 854 | --show-uniq-def |--sud 855 | using default path 856 | --show-sys-uniq |--ssu 857 | using system path /usr /etc /opt 858 | 859 | show RAW output of the uniq variables 860 | --show-uniq-only |--suo 861 | using default path 862 | 863 | --list-categories | --lc 864 | Show all categories found in "/usr/share/applications/" and "$HOME/.local/share/applications/" 865 | 866 | Not supporting grep syntax, using awk 867 | show content of choosen variables only if all them are present in the file. To show path to file use "sf" as last option. 868 | --including-only-var | --iov [var1,var2] sf 869 | using default path 870 | --including-only-var-sys | --iovs [var1,var2] sf 871 | using system path /usr /etc /opt' 872 | } 873 | help_sec(){ 874 | echo 'Search section names in *.desktop files 875 | 876 | search for uniq section names 877 | --sys-section-name | --ssn 878 | using system path /usr /etc /opt 879 | --default-section-name | --dsn 880 | using default path' 881 | 882 | } 883 | help_config(){ 884 | echo 'Configuration 885 | --create-global-list | --cgl 886 | scan system and save dirs into /opt/share/ldf/sorted.test 887 | --create-local-list | --cll 888 | scan system and save dirs into $HOME/.ldf/sorted.test 889 | 890 | --show-local-defaults | --sld 891 | show content of $HOME/.ldf/sorted.test 892 | --show-global-defaults | --sgd 893 | show content of /opt/share/ldf/sorted.test 894 | 895 | --show-default-directories | --sdd 896 | show internal dirs defined in array DefDskPath 897 | 898 | --remove-local-config 899 | removing $HOME/.ldf/sorted.test 900 | --remove-global-config 901 | removing /opt/share/ldf/sorted.test 902 | 903 | --find-path | --fp (path) 904 | find path that contain *.desktop files, default starting path is / 905 | --formated-path-output | --fpo 906 | same as --fp but showing already formated path (replaced numbers,spaces with *) 907 | 908 | --format-path-file | --fpf [filename] 909 | replace all spaces and numbers with *' 910 | } 911 | help_info(){ 912 | echo 'https://specifications.freedesktop.org/desktop-entry-spec/latest/ 913 | Short overview: 914 | "f" - File name with full path 915 | "u" - URL to website 916 | "d" - Directory 917 | "n" - Name of the file without path 918 | Single source: 919 | %f %u %d %n 920 | Multiple sources: 921 | %F %U %D %N 922 | Other: 923 | %k URI/location of desktop file 924 | %v name of the device' 925 | } 926 | help_usage(){ 927 | echo 'Usage examples 928 | List content with default options: 929 | lsdesktopf 930 | Search only for specific text in default output: 931 | lsdesktopf gtk 932 | lsdesktopf game 933 | lsdesktopf --more 934 | lsdesktopf --more kde 935 | lsdesktopf --less 936 | lsdesktopf --less gnome 937 | lsdesktopf --less gtk zh_CN,zh_TW 938 | 939 | Use --var option (supporting grep syntax): 940 | --var-sys has same syntax as --var 941 | --var Name= 942 | --var "Name\[zn_CN\]" -e "^Exec=" 943 | Reverse search (supporting grep syntax) 944 | --no-var Exec= 945 | --no-var-sys "Name\[en_GB\]" 946 | 947 | Use --including-only-var option to show content of choosen and optionaly show filename 948 | NOTE: filename is an option and not path to existing file. 949 | --iov Exec,MimeType filename 950 | --iov Exec,MimeType | grep -v ^# 951 | 952 | Use --gm option that shows various information about MIME-types in *.desktop files 953 | --gm 1 954 | --gm 955 | --gm 0 956 | --gm -gx video 957 | --gm -gx text 958 | --gm -fm application/oxps,application/vnd.ms-xpsdocument,application/x-brasero 959 | 960 | Scan for all *.desktop files in /usr /etc /opt 961 | has same syntax as without supported options 962 | --asc 963 | --asc gtk 964 | Use --find-path or --fp 965 | --fp 966 | --fp /usr /etc' 967 | } 968 | help_tips(){ 969 | echo 'The script is based around commands: "grep", "awk", "find" 970 | and a loop: for Line in "${Array[@]}";do ..;done 971 | command "rev" is used to reverse text that is useful to show or exclude last column 972 | to show only specfic column can be used commands such as awk,cut. 973 | The "awk" command can use more than one symbol as delimer but "cut" supports only one 974 | awk -F"AB" "{print $1}" 975 | awk "{print substr($0,0,index($0,"AB")-2) }" 976 | cut -dA -f1 977 | to show everything after specified column 978 | cut -dA -f2- 979 | awk "{print substr($0,index($0,"AB")+2) }" 980 | to show amount columns in a string 981 | awk -F"AB" "{print NF}" 982 | awk "{print split($0,A,"AB") }" 983 | command "basename" is used to show only the filename but cutting away path to it. 984 | find / -type f -exec basename "{}" \; 985 | find / -type f | xargs basename 986 | command "dirname" is used to show only path to file. 987 | find / -type f -exec dirname "{}" \; 988 | find / -type f | xargs dirname 989 | hide error messages from stderr, such as e.g. "permission denied" 990 | find / -type f 2> /dev/null | grep desktop' 991 | } 992 | help_mimetypes(){ 993 | echo 'Show list of mimetypes with associated *.desktop files. 994 | --gen-mimeapps | --gm [options] 995 | Output is similar that is used in "mimeapps.list" file under section [Added Associations] 996 | Options: 997 | 0 998 | show only MIME-types 999 | 1 1000 | show type of mime. First part of MIME-type 1001 | 2 1002 | show extension. Second part of MIME-type 1003 | 3 1004 | show only filenames that can open same MIME-type 1005 | -gx [type of MIME] 1006 | shows all extensions in your systems *.desktop files that belongs to type of MIME 1007 | -gdx [options] 1008 | shows MIME-types with their descriptions found in *.xml files 1009 | by default searching only in /usr/share/mime/packages/ $HOME/.local/share/mime/packages/ 1010 | g 1011 | search in /etc /usr $HOME/.local $HOME/.config 1012 | l 1013 | search in $HOME/.local $HOME/.config 1014 | -fm [options] 1015 | find .desktop files only for comma separated MIME types 1016 | 1017 | --gdx [options] 1018 | same as --gm -gdx [options] 1019 | search in *.xml configuration files 1020 | additional options 1021 | 0 1022 | show only MIME-types 1023 | 1 1024 | show type of mime. First part of MIME-type 1025 | 2 1026 | show extension. Second part of MIME-type 1027 | 3 1028 | show only filename extenstions 1029 | -gfx [options] 1030 | list available file name extensions with their description found in ".xml" configuration or database files. 1031 | additional comma separated options: 1032 | sf 1033 | show path to .xml file where was found file name extension. 1034 | sm 1035 | show MIME type 1036 | sa 1037 | show acronym 1038 | sea 1039 | show extended acronym 1040 | ssc 1041 | show sub class 1042 | sal 1043 | show alias 1044 | sgi 1045 | show general icon description 1046 | 1047 | --list-mimeapps | --lm 1048 | List available "*mimeapps.list" with colored path and their content 1049 | ' 1050 | } 1051 | 1052 | help_Sessions(){ 1053 | echo ' 1054 | --sxs 1055 | list numbered content of Exec in .desktop files located at /usr/share/xsessions/ 1056 | additional options: 1057 | n 1058 | name 1059 | show content of "Name=" 1060 | c 1061 | comment 1062 | show content of "Comment=" 1063 | dn 1064 | desktopname 1065 | show content of "DesktopName=" 1066 | a 1067 | all 1068 | show content by pattern "Number Name # Comment # Exec" 1069 | --rxs 1070 | as above but also asking to choose number of a session to start.' 1071 | } 1072 | 1073 | case "$1" in 1074 | --help ) 1075 | if [[ -z "$2" ]];then 1076 | echo 'use additional options with --help' 1077 | echo ' all - show all help sections 1078 | def - options that are using default output 1079 | var - list available variables or search a value 1080 | sec - list available sections 1081 | usage - show usage of commands 1082 | config - configuration 1083 | debug - view or search in content of this script 1084 | info - show short info about *.desktop specified Exec 1085 | tips - show some tips about commands used in this script 1086 | mime - list available mimetypes 1087 | ses - list or run sessions' 1088 | else 1089 | case "$2" in 1090 | mime ) 1091 | help_mimetypes 1092 | ;; 1093 | def ) 1094 | help_def 1095 | ;; 1096 | debug ) 1097 | help_debug 1098 | ;; 1099 | var ) 1100 | help_var 1101 | ;; 1102 | sec ) 1103 | help_sec 1104 | ;; 1105 | config ) 1106 | help_config 1107 | ;; 1108 | info ) 1109 | help_info 1110 | ;; 1111 | usage ) 1112 | help_usage 1113 | ;; 1114 | tips ) 1115 | help_tips 1116 | ;; 1117 | ses ) 1118 | help_Sessions 1119 | ;; 1120 | all ) 1121 | help_def 1122 | help_var 1123 | help_sec 1124 | help_mimetypes 1125 | help_Sessions 1126 | help_usage 1127 | help_config 1128 | help_debug 1129 | help_info 1130 | help_tips 1131 | ;; 1132 | esac 1133 | fi 1134 | ;; 1135 | --var ) 1136 | ReCreateDskPath "$@" 1137 | 1138 | if [[ ! -z "$2" ]];then 1139 | Var="$2" 1140 | if [[ "$#" -gt 2 ]];then 1141 | AddCmd=($@); 1142 | # Additional="${AddCmd[@]:2}" ; 1143 | fi; 1144 | Opts="var" 1145 | echo "${AddCmd[@]:2}" 1146 | SearchContentOfVariable "$@" 1147 | else 1148 | echo "Error, parameter to --var is missing 1149 | example: --var MimeType" 1150 | fi 1151 | ;; 1152 | #--uniq-per-file-default | --upfd ) 1153 | # Opts="upfd" 1154 | # ReCreateDskPath "$@" 1155 | # SearchContentOfVariable "$@" 1156 | # ;; 1157 | #--uniq-per-file-sys | --upfs ) 1158 | 1159 | # find /usr /etc /opt -type f -name "*\.desktop" -exec awk -v GetLang="ru" -F"=" '{if (index($1,"[") == 1) printf " "FILENAME"\n" $1"\n";if(index($1,"["GetLang"]")){print $0}else{if(index($1,"]") == 0) print $0}}' "{}" \; | grep -v ^"\#" 1160 | # find /usr /etc /opt -type f -name "*\.desktop" -exec awk -v GetLang="$FLang" -v ShowAvailableLanguages="$3" -F= '//{ 1161 | # if(index($1,"[") != 0 && index($1,"[") != 1 ){split($1,Lang,"[")UniqLang[Lang[2]]++}; 1162 | # if(index($1,"["GetLang"]") != 0 ){Item[cnt++]=$0}else { if(index($1,"]") == 0)Item[cnt++]=$0} 1163 | # }END{ 1164 | # printf " %s",FILENAME"\n"; 1165 | # print " ** Total translations: "length(UniqLang); 1166 | # if(ShowAvailableLanguages)if(ShowAvailableLanguages == "all")if(length(UniqLang) != 0 ){ 1167 | # for(AllLang in UniqLang){sub("]","",AllLang);printf "%s",AllLang","};print "." 1168 | # }; 1169 | # for (ItemNumber in Item)print Item[ItemNumber]; 1170 | # }' "{}" \; | grep -v ^"\#" 1171 | # ;; 1172 | --more | --m ) 1173 | Opts="more" 1174 | ReCreateDskPath "$@" 1175 | SearchContentOfVariable "$@" 1176 | ;; 1177 | --more-sys | --ms ) 1178 | find /usr /etc /opt -type f -name "*\.desktop" -exec awk -v FindIt="$2" -F= '/^create/;{ 1179 | if(index($1,"]") == 0) 1180 | { 1181 | Var[CountV++]=$1; 1182 | InString[CountS++]=substr($0,index($0,$2)); 1183 | if(FindIt)if(index($2,FindIt) != 0)YES="1"; }; 1184 | }END{ 1185 | if(YES == "1" ) 1186 | { 1187 | printf "* \033[2;32m"FILENAME" \033[2;0m\n"; 1188 | for (I in InString)print Var[I]"="InString[I] 1189 | }; 1190 | if(length(FindIt) == 0) 1191 | { 1192 | printf "* \033[2;32m"FILENAME"\033[2;0m\n"; 1193 | for(I in InString)print Var[I]"="InString[I] 1194 | } 1195 | }' "{}" \;|grep -v ^"#" 1196 | ;; 1197 | --including-only-var | --iov ) 1198 | if [[ -z "$2" ]];then 1199 | echo 'Use options! 1200 | Example: --iov Exec,Type filename' 1201 | exit 1 1202 | fi 1203 | Opts="iov" 1204 | ReCreateDskPath "$@" 1205 | SearchContentOfVariable "$@" 1206 | ;; 1207 | --including-only-var-sys | --iovs) 1208 | if [[ -z "$2" ]];then 1209 | echo 'Use options! 1210 | Example: --iovs Exec,Type filename' 1211 | exit 1 1212 | fi 1213 | find /usr /etc /opt -type f -name "*\.desktop" -exec awk -v FindIt="$2" -v Fname="$3" -F= '//{ 1214 | if(FindIt){ 1215 | SizeArray=split(FindIt,ArrayFindIt,","); 1216 | if (index($0,"[") == 1 ) YesFoundIt[CountFinds++]=$0; 1217 | for(CountFindItArray in ArrayFindIt )NewArrFindIt[ArrayFindIt[CountFindItArray]]=1; 1218 | if(NewArrFindIt[$1] == 1 ) 1219 | { 1220 | YesFoundIt[CountFinds++]=$0; 1221 | UniqFound[$1]=1; 1222 | } 1223 | }}END{ 1224 | if( length(UniqFound) == SizeArray ) 1225 | { if(Fname == "filename")printf "* \033[2;32m %s"FILENAME"\033[2;32m\n"; 1226 | for (GotFound in YesFoundIt ) 1227 | { 1228 | print YesFoundIt[GotFound]; 1229 | }; 1230 | } 1231 | }' "{}" \; 1232 | ;; 1233 | --less | --l ) 1234 | Opts="less" 1235 | ReCreateDskPath "$@" 1236 | SearchContentOfVariable "$@" 1237 | ;; 1238 | --less-sys | --ls ) 1239 | find /usr /etc /opt -type f -name "*\.desktop" -exec awk -v FindIt="$2" -v Trans="$3" -F= '/^create/;{ 1240 | if(Trans) 1241 | { 1242 | split(Trans,ArrayTransLang,","); 1243 | for(ReLangArray in ArrayTransLang )NewArrTrans[ArrayTransLang[ReLangArray]]=1; 1244 | } 1245 | if(index($1,"]") == 0) 1246 | { 1247 | Var[CountV++]=$1; 1248 | InString[CountS++]=substr($0,index($0,$2)); 1249 | if(FindIt)if(index($2,FindIt) != 0)YES="1"; 1250 | }; 1251 | if(index($1,"[") != 0 && index($1,"[") != 1 ){ 1252 | split($1,Lang,"["); 1253 | TmpLang=Lang[2]; 1254 | UniqLang[TmpLang]++; 1255 | sub("]","",TmpLang); 1256 | if(Trans) 1257 | { 1258 | if( NewArrTrans[TmpLang] == 1 ) 1259 | { 1260 | Var[CountV++]=$1; 1261 | InString[CountS++]=substr($0,index($0,$2)) 1262 | } 1263 | } 1264 | }; 1265 | if(index($1,"[") == 1){ 1266 | Var[CountV++]=$1; 1267 | InString[CountS++]=$0} 1268 | }END{ 1269 | if(YES == "1" ) 1270 | { 1271 | printf "*\033[2;32m "FILENAME"\033[2;0m \n";printf "@ Total translations: "length(UniqLang)": "; 1272 | if(length(UniqLang) != 0)for(AllLang in UniqLang){sub("]","",AllLang);printf "%s",AllLang",";} 1273 | print " "; 1274 | for (I in InString) 1275 | if(index(Var[I],"[") != 1 && length(Var[I]) != 0 && index(Var[I],"#") != 1 ) 1276 | { 1277 | print Var[I]"="InString[I]; 1278 | } 1279 | else 1280 | { 1281 | if(index(Var[I],"[") == 1) 1282 | printf "\033[2;33m" Var[I]"\033[0m\n" 1283 | } 1284 | } 1285 | if(length(FindIt) == 0) 1286 | { 1287 | printf "* \033[2;32m "FILENAME"\033[2;0m \n";printf "@ Total translations: "length(UniqLang)": "; 1288 | if(length(UniqLang) != 0)for(AllLang in UniqLang){sub("]","",AllLang);printf "%s",AllLang",";} 1289 | print " "; 1290 | for (I in InString)if(index(Var[I],"[") != 1 && length(Var[I]) != 0 && index(Var[I],"#") != 1 ) 1291 | { 1292 | print Var[I]"="InString[I]; 1293 | } 1294 | else 1295 | { 1296 | if(index(Var[I],"[") == 1) 1297 | printf "\033[2;33m"Var[I]"\033[0m \n" 1298 | } 1299 | } 1300 | }' "{}" \; 1301 | ;; 1302 | --no-var | --nv ) 1303 | ReCreateDskPath "$@" 1304 | 1305 | if [[ ! -z "$2" ]];then 1306 | Var="$2" 1307 | Opts="no-var" 1308 | SearchContentOfVariable "$@" 1309 | else 1310 | echo "Error, parameter to --no-var is missing 1311 | example: --no-var MimeType" 1312 | fi 1313 | ;; 1314 | --var-sys | --vs) 1315 | # ReCreateDskPath 1316 | if [[ ! -z "$2" ]];then 1317 | Var="$2" 1318 | # if [[ "$#" -gt 2 ]];then 1319 | # Additional="${AddCmd[@]:2}" ; 1320 | # fi; 1321 | Opts="var-sys" 1322 | SearchContentOfVariable "$@" 1323 | else 1324 | echo "Error, parameter to --var-sys is missing 1325 | example: --var-sys MimeType" 1326 | fi 1327 | ;; 1328 | --no-var-sys | --nvs ) 1329 | if [[ ! -z "$2" ]];then 1330 | find /usr /etc /opt -type f -name "*\.desktop" -exec grep -i -H -L "$2" \; 1331 | else 1332 | echo 'No options are given.' 1333 | fi 1334 | ;; 1335 | #--dump-all | --da ) 1336 | # grep -i ^ -H -R --include \*.desktop "/" 1337 | # ;; 1338 | #--dump-sys-path | --dsp ) 1339 | # grep -i ^ -H -R --include \*.desktop "/usr /etc /opt" 1340 | # ;; 1341 | #--dump-default-path | --ddp ) 1342 | # Opts="ddp" 1343 | # ReCreateDskPath "$@" 1344 | # SearchContentOfVariable 1345 | # ;; 1346 | --show-uniq-def | --sud ) 1347 | OffPrint="no" 1348 | Opts="sud" 1349 | ReCreateDskPath "$@" 1350 | SearchContentOfVariable "$@" 1351 | ;; 1352 | --show-uniq-only | --suo ) 1353 | OffPrint="yes" 1354 | Opts=suo 1355 | ReCreateDskPath "$@" 1356 | RawView 1357 | ;; 1358 | --show-sys-uniq | --ssu ) 1359 | Opts="sys-uniq" 1360 | SearchContentOfVariable "$@" 1361 | ;; 1362 | --find-path | --fp ) 1363 | if [[ ! -z "$2" ]]; then 1364 | for StartCmdLine in "$@"; 1365 | do 1366 | if [[ -d "$StartCmdLine" ]]; then 1367 | InPath="$StartCmdLine" 1368 | fi 1369 | find "$InPath" -type f -name "*\.desktop" -exec dirname "{}" \; 2> /dev/null | sort -u 1370 | if [[ "$InPath" == "/" ]];then 1371 | exit 0 1372 | fi 1373 | done 1374 | else 1375 | find / -type f -name "*\.desktop" -exec dirname "{}" \; 2> /dev/null | sort -u 1376 | fi 1377 | ;; 1378 | --formated-path-output | --fpo ) 1379 | if [[ ! -z "$2" ]]; then 1380 | for StartCmdLine in "$@"; 1381 | do 1382 | if [[ -d "$StartCmdLine" ]]; then 1383 | InPath="$StartCmdLine" 1384 | fi 1385 | find "$InPath" -type f -name "*\.desktop" -exec dirname "{}" \; 2> /dev/null |\ 1386 | sed -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' -e 's/[0-9]\.[0-9]*/*/g' -e 's/\.\*/*/g' -e 's/**\*/*/g' |\ 1387 | sort -u 1388 | if [[ "$InPath" == "/" ]];then 1389 | exit 0 1390 | fi 1391 | done 1392 | else 1393 | find / -type f -name "*\.desktop" -exec dirname "{}" \; 2> /dev/null |\ 1394 | sed -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' -e 's/[0-9]\.[0-9]*/*/g' -e 's/\.\*/*/g' -e 's/\*\**/*/g' |\ 1395 | sort -u 1396 | fi 1397 | ;; 1398 | --all-sys-path | --asc) 1399 | Opts="scan-sys-path" 1400 | ReCreateDskPath "$@" 1401 | ListDefault "$@" 1402 | ;; 1403 | --create-local-list | --cll) 1404 | mkdir -p "$(dirname "$LocalArray")" 1405 | find / -type f -name "*\.desktop" -exec dirname "{}" \; | sort -u > "$LocalArray" 1406 | ;; 1407 | #--update-path-file | --upf) 1408 | # if [[ "$UID" != 0 ]];then 1409 | # echo 'You must start it as user root' 1410 | # exit 1 1411 | # else 1412 | # if [[ -z "$2" ]];then 1413 | # echo 'path to file is missing' 1414 | # else 1415 | # if [[ -f "$2" ]];then 1416 | # mkdir -p "$(dirname $GlobalArray)" 1417 | # find /usr /etc /opt -type f -name "*\.desktop" -exec dirname "{}" \; | sort -u >> "$2"; 1418 | # sed -i -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' -e 's/[0-9]\.[0-9]*/*/g' -e 's/**\*/*/g' "$2"; 1419 | # uniq -u "$2" /tmp/uniq-tmp.txt 1420 | # cp "/tmp/uniq-tmp.txt" "$2" 1421 | # else 1422 | # echo "Destion is not a file" 1423 | # fi 1424 | # fi 1425 | # fi 1426 | # ;; 1427 | 1428 | --format-path-file | --fpf ) 1429 | if [[ ! -z "$2" ]];then 1430 | if [[ -f "$2" ]];then 1431 | if [[ $(grep -c -v ^/ "$2" ) != "0" ]];then 1432 | echo 'The file should contain only full path per line. ( all should begin with / )' 1433 | else 1434 | sed -i -e 's/[0-9][0-9]*/*/g' -e 's/"//g' -e 's/\/$//g' -e 's/ /*/g' -e 's/[0-9]\.[0-9]*/*/g' -e 's/\.\*/*/g' -e 's/\*\**/*/g' "$2" 1435 | sort -u -o "$2" "$2" 1436 | fi 1437 | else 1438 | echo 'Path to file is missing!' 1439 | fi 1440 | fi 1441 | ;; 1442 | --create-global-list | --cgl) 1443 | if [[ "$UID" != 0 ]];then 1444 | echo 'You must start it as user root' 1445 | exit 1 1446 | else 1447 | mkdir -p "$(dirname $GlobalArray)" 1448 | find / -type f -name "*\.desktop" -exec dirname "{}" \; | sort -u > "$GlobalArray" 1449 | fi 1450 | ;; 1451 | 1452 | --show-local-defaults | --sld) 1453 | if [[ -f "$HOME/.ldf/sorted.test" ]];then 1454 | cat "$HOME/.ldf/sorted.test" 1455 | else 1456 | echo 'Does not exist $HOME/.ldf/sorted.test' 1457 | fi 1458 | ;; 1459 | --show-global-defaults | --sgd) 1460 | if [[ -f "/opt/share/ldf/sorted.test" ]];then 1461 | cat "/opt/share/ldf/sorted.test" 1462 | else 1463 | echo 'Does not exist /opt/share/ldf/sorted.test' 1464 | fi 1465 | ;; 1466 | --show-default-directories | --sdd) 1467 | for SDD in "${DefDskPath[@]}"; do 1468 | echo "$SDD" 1469 | done 1470 | ;; 1471 | --remove-local-config) 1472 | rm -i "$HOME/.ldf/sorted.test" 1473 | ;; 1474 | --remove-global-config) 1475 | if [[ "$UID" -eq "0" ]];then 1476 | rm -i "/opt/share/ldf/sorted.test" 1477 | else 1478 | echo 'You must be root!' 1479 | fi 1480 | ;; 1481 | --show-me | --sm) 1482 | if [[ -z $2 ]];then 1483 | cat "$0" 1484 | echo '# my path: '" $0" 1485 | else 1486 | grep -n "$2" "$0" | grep -v -e "IGNORE" -e ^"# " 1487 | fi 1488 | ;; 1489 | --sys-section-name | --ssn) 1490 | grep -e ^"\[" -h -R --include "*\.desktop" /usr /etc /opt | sort -u 1491 | ;; 1492 | --default-section-name | --dsn) 1493 | OffPrint="no" 1494 | Opts='sdsn' 1495 | ReCreateDskPath "$@" 1496 | 1497 | SearchContentOfVariable 1498 | ;; 1499 | --generate-mimeapps.list | --gen-mimeapps | --gm ) 1500 | 1501 | if [[ -z "$XDG_CONFIG_HOME" ]]; then 1502 | PName="$HOME/.local/share/applications" 1503 | else 1504 | if [[ "${XDG_CONFIG_HOME/#\//}" == "$XDG_CONFIG_HOME" ]]; then 1505 | PName="$HOME/$XDG_CONFIG_HOME/.local/share/applications" 1506 | else 1507 | PName="$XDG_CONFIG_HOME/.local/share/applications" 1508 | fi 1509 | fi 1510 | 1511 | IFS=" 1512 | " 1513 | MimePathArray+=("$( 1514 | find "/usr/local/share/applications" "/usr/share/applications" "$PName" -type f -name "*\.desktop" -exec dirname "{}" \; | 1515 | sort -u | 1516 | sed "s/$/\/\*.desktop/" )") 1517 | 1518 | case $2 in 1519 | -gdx | -get-description-xdg ) 1520 | IFS=" 1521 | " 1522 | case $3 in 1523 | g | glob ) 1524 | List_XML=($(find "/usr/" "/etc/" "$HOME/.local/" "$HOME/.config" -type f -name "*\.xml")); 1525 | ;; 1526 | l | local ) 1527 | List_XML=($(find "$HOME/.config" "$HOME/.local/" -type f -name "*\.xml")); 1528 | ;; 1529 | * ) 1530 | List_XML=($(find "/usr/share/mime/packages/" "/usr/share/mime/application/" "$HOME/.local/share/" -type f -name "*\.xml")); 1531 | ;; 1532 | esac 1533 | for In_XML_List in "${List_XML[@]}";do 1534 | find "$In_XML_List" -type f -name "*\.xml" -print0 | xargs -0 awk -F"\"" '{YesM=0; 1535 | if(index($0,"mime-type")){if(index($0,"type type=")){ContentArray[Count++]=$2" == ";YesM=1}else{if(index($0," type=")){ 1536 | ContentArray[Count++]=$4" == "}}} 1537 | 1538 | if(index($0,"")){ 1539 | GetString=substr($0,index($0,">")+1) 1540 | GetTMP=" "substr(GetString,0,index(GetString,"") != 0) 1714 | { 1715 | C=substr($0,0,index($0,"/")-2); 1716 | GetContentList[CountItems++]=substr(C,index($0,">")+1); 1717 | YesFN=FILENAME 1718 | }; 1719 | if(index($0,"mime-type type=") != 0) 1720 | { 1721 | AA=substr($0,index($0,"\"")+1); 1722 | GetContentList[CountItems++]=substr(AA,0,index(AA,"\"")-1)" # "; 1723 | YesFN=FILENAME; 1724 | } 1725 | }; 1726 | }END{if(length(YesFN) != 0)print "* "YesFN ;for(GetList in GetContentList )print GetContentList[GetList]; 1727 | }' ; 1728 | 1729 | done; 1730 | 1731 | else 1732 | 1733 | for In_List in "${List_Dirs[@]}";do 1734 | 1735 | [[ -d "${In_List}" ]] && find "${In_List}" -type f \( -name "*mimeapps.list" -o -name "defaults.list" \) -exec awk '{ 1736 | CollectMIMEContent[count++]=$0 1737 | }END{ 1738 | printf "# \033[1;36m "FILENAME "\033[0m \n"; 1739 | for (GotMIME in CollectMIMEContent)print CollectMIMEContent[GotMIME] }' "{}" \; 1740 | done 1741 | fi 1742 | ;; 1743 | --list-categories | --lc ) 1744 | # grep ^Categories -h -R "/usr/share/applications/" "$HOME/.local/share/applications/" | awk -F= '//{A[$2]=1}END{for(E in A)ZZ=ZZ E;split(ZZ,YY,";");asort(YY);for(I in YY)HH[YY[I]];for(QQ in HH)print QQ}' 1745 | # #\ awk -F= '//{A[$2]=1}END{for(E in A){gsub(";","\n",E);printf E}}' | sort -u 1746 | List_Dirs=("/usr/share/applications/") 1747 | List_Dris+=("$HOME/.local/share/applications/") 1748 | List_Dris+=("/usr/local/share/applications/") 1749 | for In_List in "${List_Dirs[@]}" ;do 1750 | [[ -d "${In_List}" ]] && find "${In_List}" -exec grep ^Categories -h -R "{}" \; 1751 | done | awk -F= '//{A[$2]=1}END{for(E in A)ZZ=ZZ E;split(ZZ,YY,";");asort(YY);for(I in YY)HH[YY[I]];for(QQ in HH)print QQ}' 1752 | #\ awk -F= '//{A[$2]=1}END{for(E in A){gsub(";","\n",E);printf E}}' | sort -u 1753 | 1754 | 1755 | ;; 1756 | --gdx | --get-description-xdg ) 1757 | gdxstdalone "$@" 1758 | ;; 1759 | --sxs | --show-x-sessions ) 1760 | StartIt=0; 1761 | ToShowPart="$2"; 1762 | ShowOrStartXsession "$@" 1763 | ;; 1764 | --rxs | --run-x-session ) 1765 | StartIt=1; 1766 | ToShowPart="$2"; 1767 | ShowOrStartXsession "$@" 1768 | ;; 1769 | * ) 1770 | ReCreateDskPath "$@" 1771 | 1772 | ListDefault "$@" 1773 | ;; 1774 | esac 1775 | -------------------------------------------------------------------------------- /man-page.test: -------------------------------------------------------------------------------- 1 | .\" Process this file with 2 | .\" groff -man -Tascii foo.1 3 | .\" 4 | .TH LSDESKTOPF 1 "APRIL 2016" LSDESKTOPF 1 5 | .SH NAME 6 | lsdesktopf \- list available *.desktop files and search in their content. 7 | .SH SYNOPSIS 8 | .br 9 | .B lsdesktopf 10 | .I [word] 11 | .br 12 | .B lsdesktopf 13 | .I [options] [word] 14 | .br 15 | .B lsdesktopf 16 | .I [options] [word] [language1,language2] 17 | .br 18 | .B lsdesktopf 19 | .I [options] [path] 20 | .SH DESCRIPTION 21 | .B lsdesktopf 22 | is a bash script with the main purpose to get a quick overview of programs with their command lines available in *.desktop files. 23 | It can also be used to search for specific content in them. 24 | .SH OPTIONS 25 | .IP --help\ [options] 26 | all - show all options to stdout 27 | def - options that are using default output 28 | var - list available variables or search a value 29 | sec - list available sections 30 | usage - show usage of commands 31 | config - configuration 32 | debug - view or search in content of this script 33 | info - show short info about an executable specified in a *.desktop file 34 | tips - show some tips about commands used in this script 35 | 36 | .P 37 | All supported options (short or long) begin with \-\- otherwise the input is interpreted as a text search pattern. 38 | Default paths are pre-defined in the script or in a configuration file. 39 | System paths that the script searches are /usr /etc /opt. 40 | .SH 41 | .IP DEFAULT\ OUTPUT 42 | Without options searchable content is listed in a single line. 43 | Likewise word search results are output in a single line (see usage). 44 | .IP "\fB\--m, \-\-more [word]" 45 | search results are output vertically for (more) user-friendly readability, including associated variable names. 46 | .IP "\fB\--l, \-\-less [word] [language,language]" 47 | search results are output vertically (same as --more), but including output for any found translations and an additional list of translations present in the *.desktop files. 48 | .IP "\fB\--ms, \-\-more-sys" 49 | same as --more but search limited to the system path. 50 | .IP "\fB\--ls, \-\-less-sys" 51 | same as --less but search limited to the system path. 52 | .SH 53 | .IP VARIABLES,\ RAW\ CONTENT 54 | Search for specific content or variables 55 | .IP "\fB\--var\ [variable]\ (additional\ grep\ pattern)" 56 | search for\ [variable] names or any other additional content in the default path. 57 | .IP "\fB\--nv, \-\-no-var\ [string]\ (additional\ grep\ pattern)" 58 | show file names that do not contain\ [string]\ in the default path. 59 | .IP "\fB\--nvs, \-\-no-var-sys" 60 | same as --no-var, but limiting the search to the system path. 61 | .IP "\fB\--vs, \-\-var-sys" 62 | same as --var, but search limited to the system path. 63 | .IP "\fB\--sud, \-\-show-uniq-def" 64 | show unique basename variables per directory found in the default path. 65 | .IP "\fB\--suo, \-\-show-uniq-only" 66 | show only unique variable names found in all default paths. 67 | .IP "\fB\--ssu, \-\-show-sys-uniq" 68 | show unique variable names found in the system path. 69 | .SH 70 | .IP SECTIONS 71 | .IP "\fB\--dsn, \-\-default-section-name" 72 | search for unique section names in the default path 73 | .IP "\fB\--ssn, \-\-sys-section-name" 74 | search for unique section names in the system path. 75 | .SH CONFIGURATION 76 | ./ What is saved? directories containing .desktop files? 77 | .IP "\fB\--cgl, \-\-create-global-list" 78 | scan system and save directories into /opt/share/ldf/sorted.test 79 | .IP "\fB\-cll, \-\-create-local-list" 80 | scan system and save directories into $HOME/.ldf/sorted.test 81 | .IP "\fB\--sld, \-\-show-local-defaults" 82 | show content of $HOME/.ldf/sorted.test 83 | .IP "\fB\--sgd, \-\-show-global-defaults" 84 | show content of /opt/share/ldf/sorted.test 85 | .IP "\fB\--sdd, \-\-show-default-directories" 86 | show internal dirs defined in array DefDskPath 87 | .IP "\fB\--remove-local-config" 88 | remove $HOME/.ldf/sorted.test 89 | .IP "\fB\--remove-global-config" 90 | remove /opt/share/ldf/sorted.test 91 | .IP "\fB\--fp, \-\-find-path\ (path)" 92 | find paths that contain *.desktop files, default starting path is / 93 | .IP "\fB\--fpo, \-\-formated-path-output" 94 | same as --fp but showing already formatted path (numbers and spaces replaced with *) 95 | .IP "\fB\--fpf, \-\-format-path-file\ [filename]" 96 | replaces all spaces and numbers with a * 97 | .SH FILES 98 | .IP "Configuration files should contain only full paths to directories." 99 | .IP "/opt/share/ldf/sorted.test" 100 | The system wide configuration file. 101 | .IP "$HOME/.ldf/sorted.test" 102 | The user configuration file. 103 | .SH BUGS 104 | Report all bugs or suggestions via 105 | .P 106 | https://aur.archlinux.org/packages/lsdesktopf/ 107 | .SH AUTHOR 108 | Andy Crowd (QQ 3188952872) 109 | Thanks to 110 | Indigo for the review and update of the man page. 111 | .SH "SEE ALSO" 112 | .BR desktop-file-validate(1) 113 | -------------------------------------------------------------------------------- /man-page.zh_CN-Updated by Yuking.txt: -------------------------------------------------------------------------------- 1 | .\" Process this file with 2 | .\" groff -man -Tascii foo.1 3 | .\" 4 | .TH LSDESKTOPF 1 "2016年4月" LSDESKTOPF 1 5 | .SH 名称 6 | lsdesktopf \- 列举出所有 *.desktop 文件,并在它们的内容中搜索。 7 | .SH 纲要 8 | .br 9 | .B lsdesktopf 10 | .I [word] 11 | .br 12 | .B lsdesktopf 13 | .I [options] [word] 14 | .br 15 | .B lsdesktopf 16 | .I [options] [word] [language1,language2] 17 | .br 18 | .B lsdesktopf 19 | .I [options] [path] 20 | .SH 描述 21 | .B lsdesktop 22 | 是一个bash脚本,主要目的是对\ *.desktop\ 文件中的程序及其命令行进行快速预览。 23 | 它也可以被用来搜索其中的特定内容。 24 | .SH 选项 25 | .IP --help\ [options] 26 | all - 在标准输出流中显示所有选项 27 | def - 使用默认输出的选项 28 | var - 列出可用的变量或者搜索一个值 29 | sec - 列出可用的段 30 | usage - 显示命令的用法 31 | config - 配置 32 | debug - 查看或搜索本脚本的内容 33 | info - 显示在 *.desktop 文件中指定的可执行文件的简要信息 34 | tips - 显示在本脚本中使用的命令的一些技巧 35 | 36 | .P 37 | 所有支持的选项(无论长或短)都以\-\-\ 开始,否则输入会按文本检索模式进行解释断。默认路径预先定义在脚本或配置文件中。脚本搜索的系统路径为/usr /etc /opt。 38 | 39 | .SH 40 | .IP 默认的输出 41 | 无选项可揵搜索内容在一行中列出。 42 | 同样地,搜索的结果也会输出到一行(详见用法)。 43 | .IP "\fB\--m, \-\-more [word]" 44 | 为了(更好的)用户可读性,包括附带变量名的搜索结果以竖直的方式输出。 45 | .IP "\fB\--l, \-\-less [word] [language,language]" 46 | 以竖直方式输出搜索结果(与\ --more\ 相同),但输出中也包含了所有能在\ *.desktop\ 文件中找到的文档翻译和额外的翻译清单。 47 | .IP "\fB\--ms, \-\-more-sys" 48 | 与--more相同,但是搜索限制在系统路径下。 49 | .IP "\fB\--ls, \-\-less-sys" 50 | 与\ --less\ 相同,但是搜索限制在系统路径下。 51 | .SH 52 | .IP 变量,\ 原始内容\ 53 | 搜索指定的内容或变量 54 | .IP "\fB\--var\ [变量]\ (附加\ grep\ 模式)" 55 | 在默认路径下搜索\ [变量] 名或任何其他内容。 56 | .IP "\fB\--nv, \-\-no-var\ [字符串]\ (附加\ grep\ 模式)" 57 | 显示在默认路径下不包含\ [字符串]\ 的文件名。 58 | .IP "\fB\--nvs, \-\-no-var-sys" 59 | 与\ --no-var\ 相同,但是搜索限制在系统路径下。 60 | .IP "\fB\--vs, \-\-var-sys" 61 | 与\ --var\ 相同,但是搜索限制在系统路径下。 62 | .IP "\fB\--sud, \-\-show-uniq-def" 63 | 显示在默认路径下找到的每个目录独有的变量名。 64 | .IP "\fB\--suo, \-\-show-uniq-only" 65 | 仅显示在所有默认路径下找到的独有变量名。 66 | .IP "\fB\--ssu, \-\-show-sys-uniq" 67 | 仅显示在系统路径下找到的独有变量名。 68 | .SH 69 | .IP 段 70 | .IP "\fB\--dsn, \-\-default-section-name" 71 | 搜索在默认路径下独有的段名。 72 | .IP "\fB\--ssn, \-\-sys-section-name" 73 | 搜索在系统路径下独有的段名。 74 | .SH CONFIGURATION 75 | ./ 保存了什么?包含 .desktop 文件的目录吗? 76 | .IP "\fB\--cgl, \-\-create-global-list" 77 | 扫描系统并将目录存放在 /opt/share/ldf/sorted.test 中。 78 | .IP "\fB\-cll, \-\-create-local-list" 79 | 扫描系统并将目录保存在 $HOME/.ldf/sorted.test 中。 80 | .IP "\fB\--sld, \-\-show-local-defaults" 81 | 显示 $HOME/.ldf/sorted.test 文件中的内容。 82 | .IP "\fB\--sgd, \-\-show-global-defaults" 83 | 显示 /opt/share/ldf/sorted.test 文件中的内容。 84 | .IP "\fB\--sdd, \-\-show-default-directories" 85 | 显示在 DefDskPath 数组中定义的目录。 86 | .IP "\fB\--remove-local-config" 87 | 删除 $HOME/.ldf/sorted.test 文件。 88 | .IP "\fB\--remove-global-config" 89 | 删除 remove /opt/share/ldf/sorted.test 文件。 90 | .IP "\fB\--fp, \-\-find-path\ (path)" 91 | 搜索包含 *.desktop 文件的路径,默认开始路径是 / 92 | .IP "\fB\--fpo, \-\-formated-path-output" 93 | 与 --fp 相同,但显示已经格式化的路径(数字和空格都用*代替)。 94 | .IP "\fB\--fpf, \-\-format-path-file\ [filename]" 95 | 将所有的数字和空格用*代替。 96 | .SH 文件 97 | .IP "配置文件应该仅包含目录的全路径。" 98 | .IP "/opt/share/ldf/sorted.test" 99 | 系统的通用配置文件。 100 | .IP "$HOME/.ldf/sorted.test" 101 | 用户的配置文件。 102 | .SH 漏洞 103 | 请通过以下方式报告漏洞或提供建议: 104 | .P 105 | https://aur.archlinux.org/packages/lsdesktopf/ 106 | .SH 作者 107 | Andy Crowd (QQ 3188952872) 108 | 感谢Indigo审阅和更新本帮助页面。 109 | .SH "参见" 110 | .BR desktop-file-validate(1) 111 | -------------------------------------------------------------------------------- /man-page.zh_CN.txt: -------------------------------------------------------------------------------- 1 | .\" Process this file with 2 | .\" groff -man -Tascii foo.1 3 | .\" 4 | .TH LSDESKTOPF 1 "2016年4月" LSDESKTOPF 1 5 | .SH 名称 6 | lsdesktopf \- 列举出所有存在的 *.desktop 文件,并在它们的目录搜索出来。 7 | .SH 语法 8 | .br 9 | .B lsdesktopf 10 | .I [word] 11 | .br 12 | .B lsdesktopf 13 | .I [options] [word] 14 | .br 15 | .B lsdesktopf 16 | .I [options] [word] [language1,language2] 17 | .br 18 | .B lsdesktopf 19 | .I [options] [path] 20 | .SH 描述 21 | \fBlsdesktopf\fR\ 是一个bash脚本,通过利用存在于\ *.desktop\ 文件的命令行来获得对程序的一个快速的预览。它也 22 | 可以被用来搜索程序中特定的内容。 23 | .SH 可选项 24 | .IP --help\ [options] 25 | all - 在标准输出流中显示所有的可选项 26 | def - 使用默认输出的可选项 27 | var - 列出可用的变量或者搜索一个值 28 | sec - 列出可用的段 29 | usage - 显示命令的用法 30 | config - 配置 31 | debug - 查看或搜索这个脚本的内容 32 | info - 显示在 *.desktop 文件中指定的可执行文件的简要信息 33 | tips - 显示在本脚本中使用命令的一些技巧 34 | 35 | .P 36 | 所有支持的可选项(无论长或是短都以\-\-\ 开始,否则输出会被当作检索文本的模式 37 | 打断。默认的路径都预先在脚本或配置文件中定义好了。这个脚本搜索的系统路径 38 | 在/usr/etc/opt。 39 | 40 | .SH 41 | .IP 默认的输出 42 | 如果没有可选项,可搜索的内容在一行列出。同样地,搜索的结果也会输出 43 | 到一行(详见用法)。 44 | .IP "\fB\--m, \-\-more [word]" 45 | 为了用户的可读性,搜索的结果包括附带的变量名以竖直的方式输出。 46 | .IP "\fB\--l, \-\-less [word] [language,language]" 47 | 搜索的结果竖直地输出(与\ --more\ 相同),但输出中也包含了所有能找到 48 | 的文档的翻译和在\ *.desktop\ 文件存在着的额外的一个翻译的清单。 49 | .IP "\fB\--ms, \-\-more-sys" 50 | 与--more相同,但是搜索限制在系统路径下。 51 | .IP "\fB\--ls, \-\-less-sys" 52 | 与\ --less\ 相同,但是搜索限制在系统路径下。 53 | .SH 54 | .IP 变量,\ 原始内容\ 55 | 搜索指定的内容或变量 56 | .IP "\fB\--var\ [variable]\ (附加\ grep\ 模式)" 57 | 显示\ [变量] 名称或在默认路径下任何其他的内容。 58 | .IP "\fB\--nv, \-\-no-var\ [string]\ (附加\ grep\ 模式)" 59 | 显示在默认路径下不包含\ [string]\ 的文件名。 60 | .IP "\fB\--nvs, \-\-no-var-sys" 61 | 与\ --no-var\ 相同,但是搜索限制在系统路径下。 62 | .IP "\fB\--vs, \-\-var-sys" 63 | 与\ --var\ 相同,但是搜索限制在系统路径下。 64 | .IP "\fB\--sud, \-\-show-uniq-def" 65 | 显示在默认路径下找到的每个目录独有的变量名。 66 | .IP "\fB\--suo, \-\-show-uniq-only" 67 | 仅显示在默认路径下找到的独有的变量名。 68 | .IP "\fB\--ssu, \-\-show-sys-uniq" 69 | 仅显示在系统路径下找到的独有的变量名。 70 | .SH 71 | .IP 段 72 | .IP "\fB\--dsn, \-\-default-section-name" 73 | 搜索在默认路径下独有的段名。 74 | .IP "\fB\--ssn, \-\-sys-section-name" 75 | 搜索在系统路径下独有的段名。 76 | .SH CONFIGURATION 77 | ./ 保存了什么?在目录下包含 .desktop 文件吗? 78 | .IP "\fB\--cgl, \-\-create-global-list" 79 | 扫描系统并将目录存放在 /opt/share/ldf/sorted.test 中。 80 | .IP "\fB\-cll, \-\-create-local-list" 81 | 扫描系统并将目录存放在 $HOME/.ldf/sorted.test 中。 82 | .IP "\fB\--sld, \-\-show-local-defaults" 83 | 显示 $HOME/.ldf/sorted.test 文件中的内容。 84 | .IP "\fB\--sgd, \-\-show-global-defaults" 85 | 显示 /opt/share/ldf/sorted.test 文件中的内容。 86 | .IP "\fB\--sdd, \-\-show-default-directories" 87 | 显示在 DefDskPath 数组中定义的目录。 88 | .IP "\fB\--remove-local-config" 89 | 删除 $HOME/.ldf/sorted.test 文件。 90 | .IP "\fB\--remove-global-config" 91 | 删除 remove /opt/share/ldf/sorted.test 文件。 92 | .IP "\fB\--fp, \-\-find-path\ (path)" 93 | 搜索包含 *.desktop 文件的路径,默认开始路径是 / 94 | .IP "\fB\--fpo, \-\-formated-path-output" 95 | 与 --fp 相同,但显示已经标准化的路径(数字和空格都用*代替)。 96 | .IP "\fB\--fpf, \-\-format-path-file\ [filename]" 97 | 将所有的数字和空格用*代替。 98 | .SH 文件 99 | .IP "配置文件应该包含到目录的全路径。 100 | .IP "/opt/share/ldf/sorted.test" 101 | 系统的通用配置文件。 102 | .IP "$HOME/.ldf/sorted.test" 103 | 用户的配置文件。 104 | .SH 漏洞 105 | 请通过一下方式报告漏洞或提供建议: 106 | .P 107 | https://aur.archlinux.org/packages/lsdesktopf/ 108 | .SH 作者 109 | Andy Crowd (QQ 3188952872) 110 | 感谢Indigo为本帮助页面的审阅和更新。 111 | .SH "参见" 112 | .BR desktop-file-validate(1) 113 | -------------------------------------------------------------------------------- /man-page.zh_TW.txt: -------------------------------------------------------------------------------- 1 | .\" Process this file with 2 | .\" groff -man -Tascii foo.1 3 | .\" 4 | .TH LSDESKTOPF 1 "2016年4月" LSDESKTOPF 1 5 | .SH 名稱 6 | lsdesktopf \- 列舉出所有存在的*.desktop檔案,並在它們的目錄檢索出來。 7 | .SH 語法 8 | .br 9 | .B lsdesktopf 10 | .I [word] 11 | .br 12 | .B lsdesktopf 13 | .I [options] [word] 14 | .br 15 | .B lsdesktopf 16 | .I [options] [word] [language1,language2] 17 | .br 18 | .B lsdesktopf 19 | .I [options] [path] 20 | .SH 描述 21 | \fBlsdesktopf\fR\ 是一個bash腳本,通過利用存在於 \ *.desktop\ 檔案的命令列來獲得對程式的一個快速的預覽。它也 22 | 可以被用來檢索程式中特定的內容。 23 | .SH 可選項 24 | .IP --help\ [options] 25 | all - 在標準輸出流中顯示所有的可選項 26 | def - 使用默認輸出的可選項 27 | var - 列出可用的變數或者檢索一個值 28 | sec - 列出可用的段 29 | usage - 顯示命令的用法 30 | config - 設定 31 | debug - 查看或檢索這個腳本的內容 32 | info - 顯示在*.desktop檔案中指定的可執行文件的簡要資訊 33 | tips - 顯示在本腳本中使用命令的一些技巧 34 | 35 | .P 36 | 所有支持的可選項(無論長或是短都以\-\-\開始,否則輸出會被當作檢索文字的模式 37 | 打斷。默認的路徑都預先在腳本或設定檔中定義好了。這個腳本蒐索的系統路徑 38 | 在/usr/etc/opt。 39 | 40 | .SH 41 | .IP 默認的輸出 42 | 如果沒有可選項,可檢索的內容在一行列出。同樣地,檢索的結果也會輸出 43 | 到一行(詳見用法)。 44 | .IP "\fB\--m, \-\-more [word]" 45 | 為了用戶的可讀性,檢索的結果包括附帶的變數名以豎直的形式輸出。 46 | .IP "\fB\--l, \-\-less [word] [language,language]" 47 | 檢索的結果豎直地輸出(與\ --more\相同),但輸出中也包含了所有能找到 48 | 的檔案的翻譯和在\ *.desktop\檔案存在著的額外的一個翻譯的清單。 49 | .IP "\fB\--ms, \-\-more-sys" 50 | 與--more相同,但是檢索限制在系統路徑下. 51 | .IP "\fB\--ls, \-\-less-sys" 52 | 與\ --less\相同,但是檢索限制在系統路徑下。 53 | .SH 54 | .IP 變數,\原始內容\ 55 | 檢索指定的內容或變數 56 | .IP "\fB\--var\ [variable]\ (附加\ grep\ 模式)" 57 | 顯示\ [變數]名稱或在默認路徑下任何其他的內容。 58 | .IP "\fB\--nv, \-\-no-var\ [string]\ (附加\ grep\ 模式)" 59 | 顯示在默認路徑下不包含\ [string]\的檔名。 60 | .IP "\fB\--nvs, \-\-no-var-sys" 61 | 與\ --no-var\相同,但是檢索限制在系統路徑下。 62 | .IP "\fB\--vs, \-\-var-sys" 63 | 與\ --var\相同,但是檢索限制在系統路徑下。 64 | .IP "\fB\--sud, \-\-show-uniq-def" 65 | 顯示在默認路徑下找到的每個目錄獨有的變數名。 66 | .IP "\fB\--suo, \-\-show-uniq-only" 67 | 僅顯示在默認路徑下找到的獨有的變數名。 68 | .IP "\fB\--ssu, \-\-show-sys-uniq" 69 | 僅顯示在系統路徑下找到的獨有的變數名。 70 | .SH 71 | .IP 段 72 | .IP "\fB\--dsn, \-\-default-section-name" 73 | 檢索在默認路徑下獨有的段名。 74 | .IP "\fB\--ssn, \-\-sys-section-name" 75 | 檢索在系統路徑下獨有的段名。 76 | .SH CONFIGURATION 77 | ./ 保存了什麼?在目錄下包含.desktop檔案嗎? 78 | .IP "\fB\--cgl, \-\-create-global-list" 79 | 掃描系統並將目錄存放在 /opt/share/ldf/sorted.test 中。 80 | .IP "\fB\-cll, \-\-create-local-list" 81 | 掃描系統並將目錄存放在 $HOME/.ldf/sorted.test 中。 82 | .IP "\fB\--sld, \-\-show-local-defaults" 83 | 顯示$HOME/.ldf/sorted.test檔案中的內容。 84 | .IP "\fB\--sgd, \-\-show-global-defaults" 85 | 顯示/opt/share/ldf/sorted.test檔案中的內容。 86 | .IP "\fB\--sdd, \-\-show-default-directories" 87 | 顯示在DefDskPath數組中定義的目錄。 88 | .IP "\fB\--remove-local-config" 89 | 删除$HOME/.ldf/sorted.test檔案。 90 | .IP "\fB\--remove-global-config" 91 | 删除 remove /opt/share/ldf/sorted.test 檔案。 92 | .IP "\fB\--fp, \-\-find-path\ (path)" 93 | 檢索包含*.desktop檔案的路徑,默認開始路徑是/ 94 | .IP "\fB\--fpo, \-\-formated-path-output" 95 | 與--fp相同,但顯示已經標準化的路徑(數位和空格都用*代替)。 96 | .IP "\fB\--fpf, \-\-format-path-file\ [filename]" 97 | 將所有的數位和空格用*代替。 98 | .SH 文件 99 | .IP "設定檔應該包含到目錄的全路徑。 100 | .IP "/opt/share/ldf/sorted.test" 101 | 系統的通用設定檔。 102 | .IP "$HOME/.ldf/sorted.test" 103 | 用戶的設定檔。 104 | .SH 漏洞 105 | 請通過一下途徑報告漏洞或提供建議 : 106 | .P 107 | https://aur.archlinux.org/packages/lsdesktopf/ 108 | .SH 作者 109 | Andy Crowd (QQ 3188952872) 110 | 感謝Indigo為本幫助頁面的審閱和更新。 111 | Glen (QQ 200802781) 112 | .SH "參見" 113 | .BR desktop-file-validate(1) 114 | --------------------------------------------------------------------------------