summary refs log tree commit diff stats
path: root/scripts/download.sh
blob: 097dbdece7e04792b319bcde1ec98d0fde9f4ed0 (plain) (blame)
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
#!/usr/bin/env sh

# Moonlander Layout
#
# Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# This file is part of Moonlander Layout.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/agpl.txt>.

LAYOUT_ID="KWBYA"
LAYOUT_GEOMETRY="moonlander"

data="$(mktemp)"
echo
cat << EOF > "$data"
{ "query": "query getLayout(\$hashId: String!, \$revisionId: String!, \$geometry: String) {layout(hashId: \$hashId, geometry: \$geometry, revisionId: \$revisionId) {  revision { hashId, qmkVersion, title }}}","variables":{"hashId":"$LAYOUT_ID","geometry":"$LAYOUT_GEOMETRY","revisionId":"latest"}}
EOF

response="$(curl --location 'https://oryx.zsa.io/graphql' --header 'Content-Type: application/json' --data "$(cat "$data")" | jq '.data.layout.revision | [.hashId, .qmkVersion, .title]')"

hash_id="$(echo "${response}" | jq -r '.[0]')"
firmware_version=$(printf "%.0f" "$(echo "${response}" | jq -r '.[1]')")
change_description=$(echo "${response}" | jq -r '.[2]')
if [ -z "${change_description}" ]; then
    change_description="latest layout modification made with Oryx"
fi

curl -L "https://oryx.zsa.io/source/${hash_id}" -o source.zip

echo "firmware_version=${firmware_version}"
echo "change_description=${change_description}"