🔧 Generate JS code for kwin

This commit is contained in:
Simon Schneegans
2022-06-09 14:03:00 +02:00
parent bf3aa0af93
commit ba9f1c91f5
5 changed files with 22 additions and 14 deletions
+13 -6
View File
@@ -26,19 +26,26 @@ mkdir -p "${BUILD_DIR}"
# $1: The nick of the effect (e.g. "tv")
# $2: The name of the effect (e.g. "TV Effect")
# $3: A short description of the effect
# $3: A short description of the effect (e.g. "Make windows close like turning off a TV")
generate() {
cp -r "kwin4_effect_$1" "${BUILD_DIR}"
# Create resource directories.
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/shaders"
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/code"
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/config"
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/ui"
sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
metadata.desktop.in > "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
cp "kwin4_effect_$1/main.xml" "${BUILD_DIR}/kwin4_effect_$1/contents/config"
cp "kwin4_effect_$1/config.ui" "${BUILD_DIR}/kwin4_effect_$1/contents/ui"
sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
main.js.in > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
perl -pe "s/%LOAD_CONFIG%/`cat kwin4_effect_$1/loadConfig.js | tr '/' '\f' `/g;" \
main.js.in | tr '\f' '/' > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
perl -pi -e "s/%NICK%/$1/g;" "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
perl -pe "s/%NICK%/$1/g;" metadata.desktop.in > "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
perl -pi -e "s/%NAME%/$2/g;" "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
perl -pi -e "s/%DESCRIPTION%/$3/g;" "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
{
echo "#version 140"
+7
View File
@@ -0,0 +1,7 @@
loadConfig() {
const defaultDuration = 400;
const duration = effect.readConfig('Duration', defaultDuration) || defaultDuration;
this.duration = animationTime(duration);
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
}
@@ -7,7 +7,7 @@
<default>0</default>
</entry>
<entry name="Color" type="Color">
<default>128,128,128</default>
<default>255,255,255</default>
</entry>
</group>
</kcfg>
+1 -7
View File
@@ -30,13 +30,7 @@ class BMW%NICK%Effect {
this.loadConfig();
}
loadConfig() {
const defaultDuration = 1000;
const duration = effect.readConfig("Duration", defaultDuration) || defaultDuration;
this.duration = animationTime(duration);
effect.setUniform(this.shader, "uColor", effect.readConfig("Color", "white"));
}
%LOAD_CONFIG%
static isScaleWindow(window) {
// We don't want to animate most of plasmashell's windows, yet, some