From 14665f3e9a5a753a6dde390bd202ce2cc5b5846e Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 29 Jun 2023 18:17:14 +0200 Subject: [PATCH] common/environment/setup/install.sh: add vicons --- Manual.md | 8 ++++++++ common/environment/setup/install.sh | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Manual.md b/Manual.md index 1670863cbe54..58c3613093a5 100644 --- a/Manual.md +++ b/Manual.md @@ -335,6 +335,14 @@ The following functions are defined by `xbps-src` and can be used on any templat it will default to `pkgname`. The `shell` argument can be one of `bash`, `fish` or `zsh`. +- *vicons()* ` []` + + Installs icons of all supported resolutions (e.g. 512px) in the correct + location and skips the ones that don't exist for the provided pattern. + Therefore it replaces all occurences of `%` in `icon_name_scheme` with the + resolution of the current iteration, for example `512`. By default icons are + stored by their package name with png as extension if no `name` is provided. + > Shell wildcards must be properly quoted, Example: `vmove "usr/lib/*.a"`. diff --git a/common/environment/setup/install.sh b/common/environment/setup/install.sh index ba0845bba5d1..20394b042ea8 100644 --- a/common/environment/setup/install.sh +++ b/common/environment/setup/install.sh @@ -13,7 +13,7 @@ _noglob_helper() { } # Apply _noglob to v* commands -for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv; do +for cmd in vinstall vcopy vcompletion vmove vmkdir vbin vman vdoc vconf vsconf vlicense vsv vicons; do alias ${cmd}="set -f; _noglob_helper _${cmd}" done @@ -274,3 +274,18 @@ _vcompletion() { ;; esac } + +_vicons() { + local icon_name_scheme="$1" name="$2" + + if [ -z "$icon_name_scheme" ]; then + msg_red "$pkgver: vicons: 1 argument expected: \n" + return 1 + fi + + _name="${name:-${pkgname}.png}" + for x in 16 32 64 128 256 512 1024; do + _file="${icon_name_scheme/\%/$x}" + [ -f "$_file" ] && vinstall "$_file" 644 "usr/share/icons/hicolor/${x}x${x}/apps/$_name" + done +}