├── logo.png ├── scratch ├── autostart ├── start.sh ├── menu.xml ├── Dockerfile.template └── rc.xml ├── docker-compose.yml ├── balena.yml └── README.md /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balena-io-experimental/scratch/HEAD/logo.png -------------------------------------------------------------------------------- /scratch/autostart: -------------------------------------------------------------------------------- 1 | # Disable display power management 2 | xset s off 3 | xset s noblank 4 | 5 | scratch3 & -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | volumes: 3 | settings: 4 | services: 5 | scratch: 6 | build: ./scratch 7 | restart: always 8 | network_mode: host 9 | privileged: true 10 | volumes: 11 | - 'settings:/data/scratch' 12 | shm_size: '2gb' -------------------------------------------------------------------------------- /scratch/start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | # Run balena base image entrypoint script 4 | /usr/bin/entry.sh echo "Running balena base image entrypoint..." 5 | 6 | export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket 7 | 8 | sed -i -e 's/console/anybody/g' /etc/X11/Xwrapper.config 9 | echo "needs_root_rights=yes" >> /etc/X11/Xwrapper.config 10 | dpkg-reconfigure xserver-xorg-legacy 11 | 12 | xset s off 13 | xset s noblank 14 | xset -dpms 15 | 16 | su -c "$1 && startx openbox-session" - scratch 17 | # read -p "Press [Enter] key to start backup..." 18 | 19 | -------------------------------------------------------------------------------- /balena.yml: -------------------------------------------------------------------------------- 1 | name: "Scratch" 2 | description: "An educational block-based visual programming language running on a Raspberry Pi 4." 3 | fleetcta: Scratch that itch 4 | post-provisioning: >- 5 | Attach your Pi to a HDMI TV or display, and add a keyboard and mouse. Allow a few minutes for your device to download the application. The Scratch desktop will appear on your screen. Happy coding! 6 | type: "sw.application" 7 | assets: 8 | repository: 9 | type: "blob.asset" 10 | data: 11 | url: "https://github.com/balenalabs-incubator/scratch" 12 | logo: 13 | type: "blob.asset" 14 | data: 15 | url: "https://raw.githubusercontent.com/balenalabs-incubator/scratch/main/logo.png" 16 | data: 17 | defaultDeviceType: "raspberrypi4-64" 18 | supportedDeviceTypes: 19 | - "raspberrypi4-64" 20 | - "raspberrypi400-64" 21 | -------------------------------------------------------------------------------- /scratch/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | scratch3 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | obconf 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /scratch/Dockerfile.template: -------------------------------------------------------------------------------- 1 | FROM balenalib/rpi-raspbian 2 | 3 | RUN install_packages wget \ 4 | xserver-xorg \ 5 | xserver-xorg-legacy \ 6 | x11-xserver-utils \ 7 | xterm x11-xserver-utils \ 8 | xterm \ 9 | xinit \ 10 | libgtk-3-dev \ 11 | libnss3-dev \ 12 | libxss1 \ 13 | libasound2-dev \ 14 | nano \ 15 | openbox \ 16 | scratch3 17 | 18 | # Setting working directory 19 | WORKDIR /usr/src/app 20 | 21 | COPY ./start.sh ./ 22 | 23 | ENV UDEV=1 24 | 25 | 26 | # Add scratch user 27 | RUN useradd scratch -m -s /bin/bash -G root && \ 28 | groupadd -r -f scratch && id -u scratch 29 | 30 | RUN mkdir /home/scratch/.config 31 | RUN mkdir /home/scratch/.config/openbox 32 | COPY ./autostart /home/scratch/.config/openbox/autostart 33 | COPY ./rc.xml /home/scratch/.config/openbox/rc.xml 34 | RUN mkdir '/home/scratch/.config/Scratch Desktop' 35 | RUN chown -R scratch:scratch /home/scratch 36 | RUN ln -s /data/scratch /home/scratch/projects 37 | 38 | COPY ./menu.xml /var/lib/openbox/debian-menu.xml 39 | 40 | 41 | # udev rule to set specific permissions 42 | RUN echo 'SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"' > /etc/udev/rules.d/10-vchiq-permissions.rules 43 | RUN usermod -a -G audio,video,tty scratch 44 | 45 | ENTRYPOINT ["bash", "start.sh"] 46 | CMD ["export DISPLAY=:0"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Build a Scratch server using a Raspberry Pi and balena 2 | 3 | Turn your Raspberry Pi 4 (2, 4 or 8Gb model) or [Pi400](https://www.raspberrypi.org/products/raspberry-pi-400/) into a Scratch3 coding rig! The fastest way to get going is to use the Deploy with balena button (after logging into your free balenaCloud account). 4 | 5 | [![](https://balena.io/deploy.svg)](https://dashboard.balena-cloud.com/deploy?repoUrl=https://github.com/balenalabs-incubator/scratch) 6 | 7 | ## Description 8 | This project will run [Scratch](https://scratch.mit.edu/) Desktop on your Raspberry Pi, allowing you to learn how to code using [blocks](https://en.wikipedia.org/wiki/Block_(programming)). If you add a [Sense Hat](https://www.raspberrypi.org/products/sense-hat/?resellerType=home) to your Pi, you can enable the Sense HAT blocks:
9 | ![sensehatblock](https://i.ibb.co/fnbnCQp/scratch-3-desktop-for-raspbian-on-raspberry-pi-2.png) 10 | 11 | ...and make use of the LEDs, joystick and on-board sensors. You can also enable the GPIO blocks (---^) and learn to interact with lots of other hardware you add. 12 | Have fun!! 13 | 14 | ## Hardware required 15 | * Raspberry Pi 4 (2, 4, or 8Gb model) 16 | * SD card (we recommend the 16Gb Sandisk Extreme) 17 | * HDMI TV or Monitor 18 | * Keyboard 19 | * Mouse 20 | * A Sense HAT(optional - but more fun!) 21 | 22 | ## Software required 23 | * A free [balenaCloud account](https://dashboard.balena-cloud.com/signup) (first ten devices are free and fully-featured, no credit card needed to start) 24 | * A tool to flash OS images to SD cards, like [balenaEtcher](https://www.balena.io/etcher/) 25 | 26 | ## Supported devices 27 | This project has been tested to work on the following devices: 28 | 29 | | Device Type | Status | 30 | | ------------- | ------------- | 31 | | Raspberry Pi 4 2Gb | ✔ | 32 | | Raspberry Pi 4 4Gb | ✔ | 33 | | Raspberry Pi 4 8Gb | ✔ | 34 | | Raspberry Pi 4 1Gb | :x: | 35 | | Raspberry Pi 400 | ✔ | 36 | | Raspberry Pi 3b+ | :x: | 37 | | Raspberry Pi 3b+ (64-bit OS) | :x: | 38 | | balena Fin | :x: | 39 | 40 | ## Use our project guide 41 | We've published a project guide and demo video on our blog. Check out the [post here](https://www.balena.io/blog/build-a-scratch-server-using-a-raspberry-pi-and-balena/). 42 | -------------------------------------------------------------------------------- /scratch/rc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 4 | 20 5 | 6 | 7 | yes 8 | 10 | no 11 | 12 | yes 13 | 15 | no 16 | 17 | 200 18 | 20 | no 21 | 23 | 24 | 25 | Smart 26 | 27 |
yes
28 | 30 | Primary 31 | 34 | 1 35 | 40 |
41 | 42 | Clearlooks 43 | NLIMC 44 | 54 | yes 55 | yes 56 | 57 | sans 58 | 8 59 | 60 | bold 61 | 62 | normal 63 | 64 | 65 | 66 | sans 67 | 8 68 | 69 | bold 70 | 71 | normal 72 | 73 | 74 | 75 | sans 76 | 9 77 | 78 | normal 79 | 80 | normal 81 | 82 | 83 | 84 | sans 85 | 9 86 | 87 | normal 88 | 89 | normal 90 | 91 | 92 | 93 | sans 94 | 9 95 | 96 | bold 97 | 98 | normal 99 | 100 | 101 | 102 | sans 103 | 9 104 | 105 | bold 106 | 107 | normal 108 | 109 | 110 | 111 | 112 | 120 | 4 121 | 1 122 | 123 | 127 | 128 | 875 129 | 131 | 132 | 133 | yes 134 | Nonpixel 135 | 136 | Center 137 | 138 | 139 | 140 | 10 141 | 143 | 10 144 | 146 | 147 | 148 | 152 | 153 | 0 154 | 0 155 | 0 156 | 0 157 | 158 | 159 | TopLeft 160 | 161 | 0 162 | 0 163 | no 164 | Above 165 | 166 | Vertical 167 | 168 | no 169 | 300 170 | 171 | 300 172 | 173 | Middle 174 | 175 | 176 | 177 | C-g 178 | 179 | 180 | 181 | left 182 | no 183 | 184 | 185 | 186 | 187 | right 188 | no 189 | 190 | 191 | 192 | 193 | up 194 | no 195 | 196 | 197 | 198 | 199 | down 200 | no 201 | 202 | 203 | 204 | 205 | left 206 | no 207 | 208 | 209 | 210 | 211 | right 212 | no 213 | 214 | 215 | 216 | 217 | up 218 | no 219 | 220 | 221 | 222 | 223 | down 224 | no 225 | 226 | 227 | 228 | 229 | 1 230 | 231 | 232 | 233 | 234 | 2 235 | 236 | 237 | 238 | 239 | 3 240 | 241 | 242 | 243 | 244 | 4 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | client-menu 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | yes 286 | yes 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | right 298 | 299 | 300 | 301 | 302 | left 303 | 304 | 305 | 306 | 307 | up 308 | 309 | 310 | 311 | 312 | down 313 | 314 | 315 | 316 | 317 | 318 | 319 | true 320 | Konqueror 321 | 322 | kfmclient openProfile filemanagement 323 | 324 | 325 | 326 | 327 | 1 328 | 329 | 500 330 | 331 | 400 332 | 335 | false 336 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | previous 365 | 366 | 367 | 368 | 369 | next 370 | 371 | 372 | 373 | 374 | previous 375 | 376 | 377 | 378 | 379 | next 380 | 381 | 382 | 383 | 384 | previous 385 | 386 | 387 | 388 | 389 | next 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | no 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | yes 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | client-menu 437 | 438 | 439 | 440 | 441 | 442 | 443 | top 444 | 445 | 446 | 447 | 448 | 449 | 450 | left 451 | 452 | 453 | 454 | 455 | 456 | 457 | right 458 | 459 | 460 | 461 | 462 | 463 | 464 | bottom 465 | 466 | 467 | 468 | 469 | 470 | 471 | client-menu 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | client-menu 506 | 507 | 508 | 509 | 510 | 511 | 512 | client-menu 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | vertical 566 | 567 | 568 | 569 | 570 | horizontal 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | previous 588 | 589 | 590 | 591 | 592 | next 593 | 594 | 595 | 596 | 597 | previous 598 | 599 | 600 | 601 | 602 | next 603 | 604 | 605 | 606 | 607 | previous 608 | 609 | 610 | 611 | 612 | next 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | client-list-combined-menu 629 | 630 | 631 | 632 | 633 | root-menu 634 | 635 | 636 | 637 | 638 | 639 | 640 | previous 641 | 642 | 643 | 644 | 645 | next 646 | 647 | 648 | 649 | 650 | previous 651 | 652 | 653 | 654 | 655 | next 656 | 657 | 658 | 659 | 660 | 661 | 663 | 664 | menu.xml 665 | 200 666 | 668 | no 669 | 670 | 100 671 | 675 | 400 676 | 680 | yes 681 | 682 | yes 683 | 684 | 685 | 686 | 687 | yes 688 | 689 | 690 |
--------------------------------------------------------------------------------