{"id":20316057,"url":"https://github.com/lupyuen/zig-pinephone-gui","last_synced_at":"2025-10-24T22:41:22.809Z","repository":{"id":37646688,"uuid":"506047562","full_name":"lupyuen/zig-pinephone-gui","owner":"lupyuen","description":"Zig GUI App for PinePhone","archived":false,"fork":false,"pushed_at":"2022-09-06T23:46:28.000Z","size":73,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T13:39:45.263Z","etag":null,"topics":["gtk","gui","linux","manjaro","mobian","phosh","pinebookpro","pinephone","xfce","zig"],"latest_commit_sha":null,"homepage":"https://lupyuen.github.io/articles/pinephone","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lupyuen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["lupyuen"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["paypal.me/lupyuen"]}},"created_at":"2022-06-22T00:39:19.000Z","updated_at":"2024-11-22T22:46:09.000Z","dependencies_parsed_at":"2023-01-17T16:47:22.007Z","dependency_job_id":null,"html_url":"https://github.com/lupyuen/zig-pinephone-gui","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fzig-pinephone-gui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fzig-pinephone-gui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fzig-pinephone-gui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fzig-pinephone-gui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lupyuen","download_url":"https://codeload.github.com/lupyuen/zig-pinephone-gui/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248451345,"owners_count":21105854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gtk","gui","linux","manjaro","mobian","phosh","pinebookpro","pinephone","xfce","zig"],"created_at":"2024-11-14T18:24:02.922Z","updated_at":"2025-10-24T22:41:17.778Z","avatar_url":"https://github.com/lupyuen.png","language":"Zig","funding_links":["https://github.com/sponsors/lupyuen","paypal.me/lupyuen"],"categories":[],"sub_categories":[],"readme":"![Zig GUI App for PinePhone](https://lupyuen.github.io/images/PXL_20220622_061922131~2.jpg)\n\n# Zig GUI App for PinePhone\n\nRead the article...\n\n-   [\"Build a PinePhone App with Zig and capy\"](https://lupyuen.github.io/articles/pinephone)\n\nCan we build a Zig GUI App for PinePhone with the capy library?\n\n-   [capy-ui/capy](https://github.com/capy-ui/capy)\n\nLet's find out!\n\n[(More about Zig)](https://ziglang.org)\n\n# Install Zig Compiler\n\nOn PinePhone, download the latest Zig Compiler `zig-linux-aarch64` from...\n\nhttps://ziglang.org/download/\n\n```bash\n## Download the Zig Compiler\ncurl -O -L https://ziglang.org/builds/zig-linux-aarch64-0.10.0-dev.2674+d980c6a38.tar.xz\n\n## Extract the Zig Compiler\ntar xf zig-linux-aarch64-0.10.0-dev.2674+d980c6a38.tar.xz\n\n## Add to PATH. TODO: Also add this line to ~/.bashrc\nexport PATH=\"$HOME/zig-linux-aarch64-0.10.0-dev.2674+d980c6a38:$PATH\"\n\n## Test the Zig Compiler, should show \"0.10.0-dev.2674+d980c6a38\"\nzig version\n```\n\n![Zig Compiler on PinePhone](https://lupyuen.github.io/images/GridArt_20220622_102635788~2.jpg)\n\n_Will Zig Compiler run on any PinePhone?_\n\nI tested the Zig Compiler with Manjaro Phosh on PinePhone (pic above), but it will probably work on any PinePhone distro since the Zig Compiler is a self-contained Arm64 Binary.\n\n[(Zig Compiler works with Mobian on PinePhone too)](https://twitter.com/techneo/status/1539510460726509568)\n\n# Install Zigmod\n\nDownload the latest [Zigmod Package Manager](https://nektro.github.io/zigmod/) `zigmod-aarch64-linux` from...\n\nhttps://github.com/nektro/zigmod/releases\n\n```bash\n## Download Zigmod Package Manager\ncurl -O -L https://github.com/nektro/zigmod/releases/download/r80/zigmod-aarch64-linux\n\n## Make it executable\nchmod +x zigmod-aarch64-linux \n\n## Move it to the Zig Compiler directory, rename as zigmod\nmv zigmod-aarch64-linux zig-linux-aarch64-0.10.0-dev.2674+d980c6a38/zigmod\n\n## Test Zigmod, should show \"zigmod r80 linux aarch64 musl\"\nzigmod\n```\n\n# Build The App\n\nTo build the app on PinePhone...\n\n```bash\n## Download the Source Code\ngit clone --recursive https://github.com/lupyuen/zig-pinephone-gui\ncd zig-pinephone-gui\n\n## Install the dependencies for capy library\npushd libs/zgt\nzigmod fetch\npopd\n\n## Build the app\nzig build\n```\n\n[(See the Build Log)](https://gist.github.com/lupyuen/a44bc3faaf6d674d2b227aeb992ccfb8)\n\nIf the build fails, check that the `gtk+-3.0` library is installed on PinePhone. [(Here's why)](https://github.com/zenith391/zgt/blob/master/build.zig#L9-L13)\n\n[(The app builds OK on Mobian after installing `gtk+-3.0`)](https://twitter.com/techneo/status/1539828828213616640)\n\n# Run The App\n\nTo run the app on PinePhone...\n\n```bash\nzig-out/bin/zig-pinephone-gui\n```\n\nWe should see the screen below.\n\nWhen we tap the `Run` and `Save` buttons, we should see...\n\n```text\ninfo: You clicked button with text Run\ninfo: You clicked button with text Save\n```\n\nYep we have successfully built a Zig GUI App for PinePhone with capy! 🎉\n\n_Is the app fast and responsive on PinePhone?_\n\nYep it feels as fast and responsive as a GTK app coded in C.\n\nRemember that Zig is a compiled language, and our compiled app is directly calling the GTK Library.\n\n![Zig GUI App for PinePhone](https://lupyuen.github.io/images/PXL_20220622_061922131~2.jpg)\n\n# Inside The App\n\nHere's the source code for the app: [`src/main.zig`](src/main.zig)\n\n```zig\n// Import the capy library and Zig Standard Library\nconst zgt = @import(\"zgt\");\nconst std = @import(\"std\");\n\n/// Main Function for our app\npub fn main() !void {\n    // Init the capy library\n    try zgt.backend.init();\n\n    // Fetch the Window\n    var window = try zgt.Window.init();\n\n    // Set the Window Contents\n    try window.set(\n        // One Column of Widgets\n        zgt.Column(.{}, .{\n            // Top Row of Widgets\n            zgt.Row(.{}, .{\n                // Save Button\n                zgt.Button(.{ .label = \"Save\", .onclick = buttonClicked }),\n                // Run Button\n                zgt.Button(.{ .label = \"Run\",  .onclick = buttonClicked }),\n            }),\n            // Expanded means the widget will take all the space it can\n            // in the parent container\n            zgt.Expanded(\n                // Editable Text Area\n                zgt.TextArea(.{ .text = \"Hello World!\\n\\nThis is a Zig GUI App...\\n\\nBuilt for PinePhone...\\n\\nWith zgt Library!\" })\n            )\n        })  // End of Column\n    );  // End of Window\n\n    // Resize the Window (might not be correct for PinePhone)\n    window.resize(800, 600);\n\n    // Show the Window\n    window.show();\n\n    // Run the Event Loop to handle Touch Events\n    zgt.runEventLoop();\n}\n\n/// This function is called when the Buttons are clicked\nfn buttonClicked(button: *zgt.Button_Impl) !void {\n    // Print the Button Label to console\n    std.log.info(\n        \"You clicked button with text {s}\",\n        .{ button.getLabel() }\n    );\n}\n```\n\nThis app is based on the capy demo...\n\nhttps://github.com/capy-ui/capy#usage\n\nFor comparison, here's a typical GTK app coded in C...\n\nhttps://www.gtk.org/docs/getting-started/hello-world/\n\nThough I think our Zig app looks more like Vala than C...\n\nhttps://www.gtk.org/docs/language-bindings/vala/\n\n# VSCode Remote\n\nFor convenience, we may use VSCode Remote to do Remote Development with PinePhone...\n\nhttps://code.visualstudio.com/docs/remote/remote-overview\n\nJust connect VSCode to PinePhone via SSH, as described here...\n\nhttps://code.visualstudio.com/docs/remote/ssh\n\nRemember to install the Zig Extension for VSCode...\n\nhttps://github.com/ziglang/vscode-zig\n\n![VSCode Remote on PinePhone](https://lupyuen.github.io/images/Screenshot%202022-06-22%20at%209.49.10%20AM~2.png)\n\n# Pinebook Pro\n\n_Will the Zig GUI App run on Arm64 laptops like Pinebook Pro?_\n\nYep! The same steps above will work on Pinebook Pro.\n\nHere's our Zig GUI App running with Manjaro Xfce on Pinebook Pro...\n\n![Our app running with Manjaro Xfce on Pinebook Pro](https://lupyuen.github.io/images/Screenshot_2022-06-22_18-13-31_061534.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flupyuen%2Fzig-pinephone-gui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flupyuen%2Fzig-pinephone-gui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flupyuen%2Fzig-pinephone-gui/lists"}