-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-extension.sh
180 lines (163 loc) · 4.06 KB
/
create-extension.sh
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
175
176
177
178
179
180
#!/bin/bash
echo GNOME Shell Extension Creator
echo by: ADeswanta
echo
echo Type your extension name:
read ext_name
echo
function name_notfound {
echo it\'s blank, try again
read ext_name
echo
if [ -z $ext_name ]; then
name_notfound
else
continue
fi
}
if [ -z "$ext_name" ]
then
name_notfound
fi
ext_name_uuid=${ext_name// /_}
ext_name_uuid=${ext_name_uuid,,}
echo Type your extension description:
read ext_desc
echo
echo Type your extension UUID:
read -p "$ext_name_uuid@" ext_uuid
echo
function uuid_notfound {
echo it\'s blank, try again
read -p "$ext_name_uuid@" ext_uuid
echo
if [ -z $ext_uuid ]; then
uuid_notfound
else
continue
fi
}
if [ -z $ext_uuid ]
then
uuid_notfound
fi
echo Type your extension version \(must be integer not double\):
read ext_ver
echo
function have_double {
echo must be integer not double, try again
read ext_ver
echo
CHAR_STOP='.'
if [[ $ext_ver == *$CHAR_STOP* ]]; then
have_double
else
continue
if [ -z $ext_ver ]; then
ver_notfound
fi
fi
}
function ver_notfound {
echo it\'s blank, try again
read ext_ver
echo
if [ -z $ext_ver ]; then
ver_notfound
else
continue
CHAR_STOP='.'
if [[ $ext_ver == *$CHAR_STOP* ]]; then
have_double
fi
fi
}
if [ -z $ext_ver ]; then
ver_notfound
fi
CHAR_STOP='.'
if [[ $ext_ver == *$CHAR_STOP* ]]; then
have_double
fi
ext_uuid=$ext_name_uuid@$ext_uuid
echo Collecting information...
echo
echo ============================================================
echo Extension information
echo ============================================================
echo Name : $ext_name
echo Description : $ext_desc
echo UUID : $ext_uuid
echo Version : $ext_ver
echo ============================================================
echo
function create_dir {
mkdir $HOME/.local/share/gnome-shell/extensions/$ext_uuid
}
function create_metadata {
if [ -z "$ext_desc" ]; then
ext_desc="The $ext_name Extension"
fi
ext_DIR_meta=$HOME/.local/share/gnome-shell/extensions/$ext_uuid/metadata.json
VER=$(gnome-shell --version | cut -d" " -f3-)
echo "{" > $ext_DIR_meta
echo " \"_generated\": \"Generated by GNOME Shell Extension Creator by ADeswanta\"," >> $ext_DIR_meta
echo " \"name\": \"$ext_name\"," >> $ext_DIR_meta
echo " \"description\": \"$ext_desc\"," >> $ext_DIR_meta
echo " \"uuid\": \"$ext_uuid\"," >> $ext_DIR_meta
echo " \"shell-version\": [" >> $ext_DIR_meta
echo " \"$VER\"" >> $ext_DIR_meta
echo " ]," >> $ext_DIR_meta
echo " \"version\": $ext_ver" >> $ext_DIR_meta
echo "}" >> $ext_DIR_meta
}
function create_extension {
ext_DIR_extension=$HOME/.local/share/gnome-shell/extensions/$ext_uuid/extension.js
echo "// Generated by GNOME Shell Extension Creator by ADeswanta" > $ext_DIR_extension
echo "" >> $ext_DIR_extension
echo "function init() {" >> $ext_DIR_extension
echo " " >> $ext_DIR_extension
echo "}" >> $ext_DIR_extension
echo "" >> $ext_DIR_extension
echo "function enable() {" >> $ext_DIR_extension
echo " " >> $ext_DIR_extension
echo "}" >> $ext_DIR_extension
echo "" >> $ext_DIR_extension
echo "function disable() {" >> $ext_DIR_extension
echo " " >> $ext_DIR_extension
echo "}" >> $ext_DIR_extension
}
function create_stylesheet {
ext_DIR_style=$HOME/.local/share/gnome-shell/extensions/$ext_uuid/stylesheet.css
echo "/* Generated by GNOME Shell Extension Creator by ADeswanta */" > $ext_DIR_style
echo "" >> $ext_DIR_style
}
echo Creating directory...
create_dir
echo
echo Creating metadata.json...
create_metadata
echo
echo Creating extension.js...
create_extension
echo
echo Creating stylesheet.css...
create_stylesheet
echo
echo Installing...
echo
echo Your extension is created!
echo
askopen=yes
while true; do
read -p "Do you want to open your extension file(y/n)?" yn
case $yn in
[Yy]* ) nautilus $HOME/.local/share/gnome-shell/extensions/$ext_uuid; askopen=no; break;;
[Nn]* ) continue; askopen=no ; break;;
* ) echo "Wrong prompt. ignoring..."; askopen=no; break;;
esac
done
echo
echo Restart GNOME Shell to apply changes.
echo Have fun!
echo