Skip to content

Commit

Permalink
Added create-plasmoid-package.sh for *.plasmoid file generation
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-harchenko committed Jun 11, 2024
1 parent 31174e4 commit f09ee21
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
25 changes: 25 additions & 0 deletions create-plasmoid-package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

DIR="$( dirname "${BASH_SOURCE[0]}" )"
CURRDIR=$PWD
cd $DIR
rm -r buildWidget
mkdir buildWidget

#compile translations used inside the plasmoid
pushd po
./build.sh
popd

cd package


VERSION=$(cat ./metadata.json | jq -r '.KPlugin.Version')
# )
#
# ( grep \"Version\" ./metadata.json | cut -d':' -f 2 )"
echo $VERSION

zip -r "../buildWidget/plasma6-redshift-control-$VERSION.plasmoid" * --exclude \.git\* --exclude *.bak

rm -dr contents/locale
54 changes: 54 additions & 0 deletions po/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
# Version: 6

# This script will convert the *.po files to *.mo files, rebuilding the package/contents/locale folder.
# Feature discussion: https://phabricator.kde.org/D5209
# Eg: contents/locale/fr_CA/LC_MESSAGES/plasma_applet_org.kde.plasma.eventcalendar.mo

DIR=`cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd`
plasmoidName=`jq -r .KPlugin.Id "$DIR/../package/metadata.json"`
website=`jq -r .KPlugin.Website "$DIR/../package/metadata.json"`

bugAddress="$website"
packageRoot=".." # Root of translatable sources
projectName="plasma_applet_${plasmoidName}" # project name

#---
if [ -z "$plasmoidName" ]; then
echo "[build] Error: Couldn't read plasmoidName."
exit
fi

if [ -z "$(which msgfmt)" ]; then
echo "[build] Error: msgfmt command not found. Need to install gettext"
echo "[build] Running 'sudo apt install gettext'"
sudo apt install gettext
echo "[build] gettext installation should be finished. Going back to installing translations."
fi

#---
echo "[build] Compiling messages"

catalogs=`find . -name '*.po' | sort`
for cat in $catalogs; do
echo "$cat"
catLocale=`basename ${cat%.*}`
msgfmt -o "${catLocale}.mo" "$cat"

installPath="$DIR/../package/contents/locale/$(echo $cat | cut -d/ -f2)/LC_MESSAGES/${projectName}.mo"

echo "[build] Install to ${installPath}"
mkdir -p "$(dirname "$installPath")"
mv "${catLocale}.mo" "${installPath}"
done

echo "[build] Done building messages"

if [ "$1" = "--restartplasma" ]; then
echo "[build] Restarting plasmashell"
killall plasmashell
kstart5 plasmashell
echo "[build] Done restarting plasmashell"
else
echo "[build] (re)install the plasmoid and restart plasmashell to test."
fi

0 comments on commit f09ee21

Please sign in to comment.