Welcome to mirror list, hosted at ThFree Co, Russian Federation.

makeappicons.sh « utils - github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 707a24b21e9c71a3d2ef5664621043e3b2de8c39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env bash
#
# Copy icon files from the Material Design icon set.
#
# Copyright (C) 2020 Wolfram Rösler
# Copyright (C) 2020 KeePassXC team <https://keepassxc.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 or (at your option)
# version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# How to use: (assuming you check out stuff in ~/src)
#
# 0. Make sure to have a clean working tree
#
# 1. Download the Material Design icon set:
#       $ cd ~/src
#       $ git clone https://github.com/Templarian/MaterialDesign.git
#
# 2. Go to the icon source directory:
#       $ cd ~/src/keepassxc/share/icons
#
# 3. Create the icons:
#       $ bash ../../utils/makeicons.sh ~/src/MaterialDesign
#
# 4. Re-build and run KeePassXC:
#       $ cd ~/keepassxc/build
#       $ make keepassxc && src/keepassxc
#
# Material icons: https://materialdesignicons.com/

NC='\033[0m'
RED='\033[0;31m'
YELLOW='\033[0;33m'

if [ $# != 1 ];then
    echo "Usage: $0 MATERIAL"
    echo "MATERIAL is the directory containing the material icons repository"
    echo "(git clone https://github.com/Templarian/MaterialDesign.git)".
    exit
fi

MATERIAL="$1"
if [ ! -d "$MATERIAL" ];then
    echo -e "${RED}Material Icons directory does not exist: ${MATERIAL}${NC}"
    exit 1
fi

# Check destination dir
DSTDIR=share/icons/application
if [ ! -d "$DSTDIR" ];then
    echo -e "${RED}Please invoke this script from the KeePassXC source root directory.${NC}"
    exit 1
fi

# Map KeePassXC icon names to Material icon names.
# $1 is the name of the icon file in the KeePassXC source (without
# path and without extension, e. g. "document-new").
# Writes the name of the Material icon (without path and without
# extension, e. g. "folder-plus") to stdout.
# If the icon name is unknown, outputs nothing.
map() {
    case "$1" in
        application-exit)                   echo exit-run                       ;;
        auto-type)                          echo keyboard-variant               ;;
        bugreport)                          echo bug-outline                    ;;
        chronometer)                        echo clock-outline                  ;;
        clipboard-text)                     echo clipboard-text-outline         ;;
        configure)                          echo cog-outline                    ;;
        database-change-key)                echo key                            ;;
        database-close)                     echo close                          ;;
        database-lock)                      echo lock-outline                   ;;
        database-merge)                     echo merge                          ;;
        dialog-close)                       echo close                          ;;
        dialog-error)                       echo alert-circle-outline           ;;
        dialog-information)                 echo information-outline            ;;
        dialog-ok)                          echo checkbox-marked-circle         ;;
        dialog-warning)                     echo alert-outline                  ;;
        document-close)                     echo close                          ;;
        document-edit)                      echo pencil                         ;;
        document-export)                    echo export                         ;;
        document-import)                    echo import                         ;;
        document-new)                       echo plus                           ;;
        document-open)                      echo folder-open-outline            ;;
        document-open-recent)               echo folder-clock-outline           ;;
        document-properties)                echo file-edit-outline              ;;
        document-save)                      echo content-save-outline           ;;
        document-save-as)                   echo content-save-all-outline       ;;
        document-save-copy)                 echo content-save-move-outline      ;;
        donate)                             echo gift-outline                   ;;
        edit-clear-locationbar-ltr)         echo backspace-reverse-outline      ;;
        edit-clear-locationbar-rtl)         echo backspace-outline              ;;
        entry-clone)                        echo plus-circle-multiple-outline   ;;
        entry-delete)                       echo close-circle-outline           ;;
        entry-edit)                         echo pencil-circle-outline          ;;
        entry-new)                          echo plus-circle-outline            ;;
        favicon-download)                   echo download                       ;;
        getting-started)                    echo lightbulb-on-outline           ;;
        group-delete)                       echo folder-remove-outline          ;;
        group-edit)                         echo folder-edit-outline            ;;
        group-empty-trash)                  echo trash-can-outline              ;;
        group-new)                          echo folder-plus-outline            ;;
        health)                             echo heart-pulse                    ;;
        help-about)                         echo information-outline            ;;
        internet-web-browser)               echo web                            ;;
        keyboard-shortcuts)                 echo apple-keyboard-command         ;;
        key-enter)                          echo keyboard-variant               ;;
        message-close)                      echo close                          ;;
        move-down)                          echo chevron-double-down            ;;
        move-up)                            echo chevron-double-up              ;;
        object-locked)                      echo lock-outline                   ;;
        object-unlocked)                    echo lock-open-variant-outline      ;;
        paperclip)                          echo paperclip                      ;;
        password-copy)                      echo key-arrow-right                ;;
        password-generate)                  echo dice-3-outline                 ;;
        password-generator)                 echo dice-3-outline                 ;;
        password-show-off)                  echo eye-off-outline                ;;
        password-show-on)                   echo eye-outline                    ;;
        preferences-desktop-icons)          echo emoticon-happy-outline         ;;
        preferences-other)                  echo file-document-edit-outline     ;;
        preferences-system-network-sharing) echo lan                            ;;
        refresh)                            echo refresh                        ;;
        reports)                            echo lightbulb-on-outline           ;;
        reports-exclude)                    echo lightbulb-off-outline          ;;
        security-high)                      echo shield-outline                 ;;
        sort-alphabetical-ascending)        echo sort-alphabetical-ascending    ;;
        sort-alphabetical-descending)       echo sort-alphabetical-descending   ;;
        statistics)                         echo chart-line                     ;;
        system-help)                        echo help                           ;;
        system-search)                      echo magnify                        ;;
        system-software-update)             echo cloud-download-outline         ;;
        url-copy)                           echo earth-arrow-right              ;;
        user-guide)                         echo book-open-outline              ;;
        username-copy)                      echo account-arrow-right-outline    ;;
        utilities-terminal)                 echo console-line                   ;;
        view-history)                       echo timer-sand-empty               ;;
        web)                                echo web                            ;;
    esac
}

# Now do the actual work
find $DSTDIR -type f -name "*.svg" | while read -r DST;do

    # Find the icon name (base name without extender)
    NAME=$(basename $DST .svg)

    # Find the base name of the svg file for this icon
    MAT=$(map $NAME)
    if [[ -z $MAT ]];then
        echo -e "${YELLOW}Warning: No MaterialDesign mapping for ${NAME}${NC}"
        continue
    fi

    # So the source file is:
    SRC="$MATERIAL/svg/$MAT.svg"
    if [ ! -f "$SRC" ];then
        echo -e "${RED}Error: Source for ${NAME} doesn't exist: ${SRC}${NC}"
        continue
    fi

    # Replace the icon file with the source file
    cp "$SRC" "$DST" || exit
    echo "Copied icon for ${NAME}"

done