├── .gitattributes ├── .github ├── Dockerfile └── workflows │ ├── alpine.yml │ ├── build-image.yml │ ├── build.yml │ ├── debian.yml │ └── release.yml ├── .gitignore ├── .gitmodules ├── .packit.yaml ├── APKBUILD ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── build.rs ├── data ├── mobi.phosh.Phrog.desktop ├── mobi.phosh.phrog.gschema.xml ├── phrog-greetd-session ├── phrog.session └── systemd-session.conf ├── debian ├── changelog ├── config │ ├── greetd │ │ └── phrog.toml │ ├── phoc.ini │ └── systemd │ │ └── phrog.conf ├── control ├── copyright ├── gbp.conf ├── patches │ └── series ├── phrog.install ├── phrog.postinst ├── phrog.postrm ├── rules ├── salsa-ci.yml ├── source │ └── format ├── upstream │ └── metadata └── watch ├── dist ├── alpine │ └── greetd-config.toml └── fedora │ ├── greetd-config.toml │ └── phrog.service ├── phrog.spec ├── resources ├── lockscreen-user-session.ui ├── phrog.css ├── phrog.gresources.xml └── shuffle-keypad-quick-setting.ui ├── src ├── dbus.rs ├── lib.rs ├── lockscreen.rs ├── main.rs ├── session_object.rs ├── sessions.rs ├── shell.rs ├── supervised_child.rs ├── user.rs └── user_session_page.rs └── tests ├── accent_colours.rs ├── common ├── dbus.rs ├── mod.rs ├── virtual_keyboard.rs └── virtual_pointer.rs ├── data └── keymap.txt ├── emergency_calls.rs ├── first_run.rs ├── fixtures ├── guido.png ├── phoshi.png └── samcday.jpeg ├── simple_flow.rs └── trivial_flow.rs /.gitattributes: -------------------------------------------------------------------------------- 1 | demo-video/ export-ignore 2 | -------------------------------------------------------------------------------- /.github/Dockerfile: -------------------------------------------------------------------------------- 1 | # This image is used as the build environment in Github Actions. 2 | 3 | FROM registry.gitlab.gnome.org/world/phosh/phosh/debian:v0.0.2025-02-07 4 | 5 | ARG PHOSH_REMOTE=https://gitlab.gnome.org/World/Phosh/phosh.git 6 | ARG PHOSH_REF=v0.45_rc1 7 | 8 | ARG PHOC_REMOTE=https://gitlab.gnome.org/World/Phosh/phoc.git 9 | ARG PHOC_REF=v0.45_rc1 10 | 11 | RUN export DEBIAN_FRONTEND=noninteractive \ 12 | && apt-get -y update \ 13 | && apt-get -y install --no-install-recommends \ 14 | dh-cargo \ 15 | foot \ 16 | rust-clippy \ 17 | wf-recorder \ 18 | && eatmydata git clone ${PHOC_REMOTE} \ 19 | && cd phoc \ 20 | && git checkout ${PHOC_REF} \ 21 | && DEB_BUILD_PROFILES=pkg.phoc.embedwlroots eatmydata apt-get --no-install-recommends -y build-dep . \ 22 | && eatmydata meson setup --prefix=/usr -Dembed-wlroots=enabled _build . \ 23 | && eatmydata meson compile -C _build \ 24 | && eatmydata meson install -C _build \ 25 | && cd .. \ 26 | && eatmydata git clone ${PHOSH_REMOTE} \ 27 | && cd phosh \ 28 | && git checkout ${PHOSH_REF} \ 29 | && eatmydata apt-get --no-install-recommends -y build-dep . \ 30 | && eatmydata meson setup --prefix=/usr -Dbindings-lib=true _build . \ 31 | && eatmydata meson compile -C _build \ 32 | && eatmydata meson install -C _build \ 33 | && eatmydata apt-get clean 34 | -------------------------------------------------------------------------------- /.github/workflows/alpine.yml: -------------------------------------------------------------------------------- 1 | name: alpine 2 | 3 | on: 4 | workflow_dispatch: {} 5 | release: 6 | types: [published] 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | permissions: 13 | contents: write 14 | 15 | jobs: 16 | alpine: 17 | runs-on: ubuntu-24.04${{ matrix.arch == 'aarch64' && '-arm' || '' }} 18 | strategy: 19 | matrix: 20 | arch: 21 | - x86_64 22 | - aarch64 23 | steps: 24 | - uses: actions/checkout@v4 25 | # Using fork (aarch64 branch from bgilbert/setup-alpine) until jirutka/setup-alpine#11 is resolved 26 | - uses: samcday/setup-alpine@main 27 | id: alpine 28 | with: 29 | arch: ${{ matrix.arch }} 30 | branch: edge 31 | packages: alpine-sdk 32 | - name: setup 33 | env: 34 | RSA_PRIV: ${{ secrets.RSA_PRIVATE_KEY }} 35 | RSA_PUB: ${{ secrets.RSA_PUBLIC_KEY }} 36 | run: | 37 | mkdir -p ~/.abuild 38 | echo "$RSA_PRIV" > ~/.abuild/key.rsa 39 | echo "$RSA_PUB" > ~/.abuild/key.rsa.pub 40 | cp ~/.abuild/key.rsa.pub /etc/apk/keys/key.rsa.pub 41 | abuild -F deps 42 | shell: alpine.sh --root {0} 43 | - name: update sha 44 | if: github.event_name != 'release' 45 | run: | 46 | sed -i -e "s/^_gitrev=main$/_gitrev=$GITHUB_SHA/" APKBUILD 47 | - name: release prep 48 | if: github.event_name == 'release' 49 | run: | 50 | # Remove _git suffix to indicate the stable release. 51 | # Assumes that the base (unsuffixed) pkgver was already updated to the new version in release commit. 52 | sed -i -e 's/^\(pkgver=.*\)_git$/\1/' APKBUILD 53 | # Delete _gitrev= var and rewrite usages to pkgver 54 | sed -i -e '/^_gitrev=/d' -e 's/_gitrev/pkgver/g' APKBUILD 55 | - name: build package 56 | run: | 57 | export PACKAGER_PRIVKEY=$HOME/.abuild/key.rsa 58 | abuild -F checksum 59 | abuild -F -P /packages 60 | mv APKBUILD /packages 61 | chmod -R 777 /packages 62 | for f in /packages/phrog/${{ matrix.arch }}/*.apk; do 63 | mv $f ${f%.apk}-${{ matrix.arch }}.apk 64 | done 65 | shell: alpine.sh --root {0} 66 | - uses: actions/upload-artifact@v4 67 | if: matrix.arch == 'x86_64' 68 | with: 69 | name: APKBUILD 70 | path: ${{ steps.alpine.outputs.root-path }}/packages/APKBUILD 71 | - uses: actions/upload-artifact@v4 72 | with: 73 | name: packages-${{ matrix.arch }} 74 | path: ${{ steps.alpine.outputs.root-path }}/packages/phrog/${{ matrix.arch }}/*.apk 75 | - name: upload .apk artifacts to release 76 | uses: softprops/action-gh-release@v2 77 | if: github.event_name == 'release' 78 | with: 79 | name: ${{ github.event.release.name }} 80 | files: | 81 | ${{ steps.alpine.outputs.root-path }}/packages/phrog/${{ matrix.arch }}/*.apk 82 | - name: upload APKBUILD artifact to release 83 | uses: softprops/action-gh-release@v2 84 | if: github.event_name == 'release' && matrix.arch == 'x86_64' 85 | with: 86 | name: ${{ github.event.release.name }} 87 | files: | 88 | ${{ steps.alpine.outputs.root-path }}/packages/APKBUILD 89 | -------------------------------------------------------------------------------- /.github/workflows/build-image.yml: -------------------------------------------------------------------------------- 1 | name: build-image 2 | 3 | on: 4 | workflow_dispatch: {} 5 | 6 | concurrency: 7 | group: ${{ github.workflow }}-${{ github.ref }} 8 | cancel-in-progress: true 9 | 10 | permissions: 11 | contents: write 12 | packages: write 13 | pull-requests: write 14 | 15 | jobs: 16 | build-image: 17 | runs-on: ubuntu-24.04 18 | steps: 19 | - uses: actions/checkout@v4 20 | - uses: docker/login-action@v3 21 | with: 22 | registry: ghcr.io 23 | username: ${{ github.actor }} 24 | password: ${{ secrets.GITHUB_TOKEN }} 25 | - name: Set up Docker Buildx 26 | uses: docker/setup-buildx-action@v3 27 | - name: get CI image hash 28 | id: hash 29 | run: | 30 | set -uexo pipefail 31 | echo "value=${{ hashFiles('.github/Dockerfile') }}" >> $GITHUB_OUTPUT 32 | - name: Build and push 33 | uses: docker/build-push-action@v6 34 | with: 35 | context: .github/ 36 | file: .github/Dockerfile 37 | push: true 38 | tags: ghcr.io/samcday/phrog-ci:${{ steps.hash.outputs.value }} 39 | cache-from: type=gha 40 | cache-to: type=gha,mode=max 41 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request_target: 7 | branches: [main] 8 | types: [labeled, opened, reopened, synchronize] 9 | release: 10 | types: [published] 11 | workflow_dispatch: {} 12 | 13 | concurrency: 14 | group: ${{ github.workflow }}-${{ github.ref }} 15 | cancel-in-progress: true 16 | 17 | env: 18 | CARGO_TERM_COLOR: always 19 | RUSTFLAGS: "-Dwarnings" 20 | 21 | permissions: 22 | contents: write 23 | packages: write 24 | pull-requests: write 25 | 26 | jobs: 27 | image-hash: 28 | runs-on: ubuntu-24.04 29 | outputs: 30 | hash: ${{ steps.hash.outputs.value }} 31 | steps: 32 | - uses: actions/checkout@v4 33 | - name: get CI image hash 34 | id: hash 35 | run: | 36 | set -uexo pipefail 37 | echo "value=${{ hashFiles('.github/Dockerfile') }}" >> $GITHUB_OUTPUT 38 | build: 39 | needs: image-hash 40 | runs-on: ubuntu-24.04 41 | container: ghcr.io/samcday/phrog-ci:${{ needs.image-hash.outputs.hash }} 42 | defaults: 43 | run: 44 | shell: bash 45 | steps: 46 | - if: | 47 | github.event_name == 'pull_request_target' && 48 | github.event.pull_request.author_association != 'COLLABORATOR' 49 | && github.event.pull_request.author_association != 'OWNER' 50 | && !contains(github.event.pull_request.labels.*.name, 'ci-ok') 51 | run: | 52 | echo This PR has not yet been marked as safe with a ci-ok label 53 | exit 1 54 | - uses: actions/checkout@v4 55 | with: 56 | ref: ${{ github.event.pull_request.head.sha }} 57 | - name: Build 58 | run: | 59 | set -uexo pipefail 60 | cargo build --all-targets --verbose 61 | - name: Lint 62 | run: | 63 | cargo clippy --all-targets --verbose 64 | - uses: actions/upload-artifact@v4 65 | with: 66 | name: x86-64-debug 67 | path: target/debug/phrog 68 | - name: Test 69 | run: | 70 | set -uexo pipefail 71 | 72 | export XDG_RUNTIME_DIR=/tmp 73 | 74 | # run tests 75 | export RECORD_TESTS=`pwd`/demo-video/recordings/ 76 | export G_MESSAGES_DEBUG=all 77 | cat > phoc.ini < comment.txt <Demo video (shown on README and release notes) 132 |

133 | 134 | 135 | 136 |

137 | 138 | 139 | HERE 140 | for f in demo-video/recordings/*.webp; do 141 | name="${f%.webp}" 142 | name="${name#demo-video/recordings/}" 143 | cat >> comment.txt <${name} 145 |

146 | 147 | 148 | 149 |

150 | 151 | 152 | HERE 153 | done 154 | - uses: jakejarvis/s3-sync-action@master 155 | with: 156 | args: --content-type=b2/x-auto 157 | env: 158 | AWS_S3_BUCKET: samcday-phrog-videos 159 | AWS_ACCESS_KEY_ID: ${{ secrets.B2_APPLICATION_ID }} 160 | AWS_SECRET_ACCESS_KEY: ${{ secrets.B2_APPLICATION_KEY }} 161 | AWS_S3_ENDPOINT: https://s3.eu-central-003.backblazeb2.com 162 | SOURCE_DIR: 'blob-upload' 163 | DEST_DIR: ${{ github.run_id }} 164 | - uses: marocchino/sticky-pull-request-comment@v2 165 | if: github.event_name == 'pull_request_target' 166 | with: 167 | header: ci-recordings 168 | hide_and_recreate: true 169 | hide_classify: OUTDATED 170 | path: comment.txt 171 | -------------------------------------------------------------------------------- /.github/workflows/debian.yml: -------------------------------------------------------------------------------- 1 | # Currently broken, no idea why. Fuckin' thing sucks! 2 | # It dies immediately on running `dpkg-buildpackage`. Cargo complains it has 3 | # no valid certs to talk to crates.io, or something. The kicker is it's running 4 | # in a debian:trixie container and I don't see the same behaviour locally using 5 | # the same image and running the same commands. So. 6 | 7 | name: debian 8 | 9 | on: 10 | workflow_dispatch: {} 11 | release: 12 | types: [published] 13 | 14 | concurrency: 15 | group: ${{ github.workflow }}-${{ github.ref }} 16 | cancel-in-progress: true 17 | 18 | permissions: 19 | contents: write 20 | 21 | jobs: 22 | debian: 23 | runs-on: ubuntu-24.04 24 | container: debian:trixie 25 | steps: 26 | - uses: actions/checkout@v4 27 | - name: setup Phosh nightly repo 28 | run: | 29 | cat </etc/apt/sources.list.d/phosh-nightly.sources 30 | Types: deb 31 | URIs: http://deb.phosh.mobi/nightly/ 32 | Suites: trixie-nightly 33 | Components: main 34 | Signed-By: 35 | -----BEGIN PGP PUBLIC KEY BLOCK----- 36 | 37 | mQINBGXoHOYBEAC/893ifemxPCa3l+46Vtpjiew4Eu+c3kXEj6sEOQZS8+ZvJ93O 38 | So3cEe7tqPM8AjqPjO6GsBjqr86swk5bbZ70GIqo1H2p9JdBaiQWqTDXxXRDvel5 39 | 0SaxbUQvLm880pjS/gcsBezRv8vb9dxDsPMzap6GuJnF5QqagfOX8B1aQKCywJNo 40 | QoFc3RL7c3j2hLRpI4kdfcjo2j3GtjKb+ojWja9dng/gsMlrHYEqS+aWg+eVFnLM 41 | XkwJXS/4AQjooH9qC+swtVNYYzt7wQdCm1mNFfrXDHSLse0ugyESqZ8AN5d9bUlB 42 | fAae7xv/lV3QfozSolFODvXlBjNaCDYb1r8Rag01eM83b1Wv/R23enFO18p/UW9k 43 | +/wk+kOqUfEd+0NBkXdRQiCrvwxHs51IqMFH5aAhM9lHmaHYmdPjETdeYPeKlA22 44 | CYLCkApEazGNPZGt6Kv7XeBwiI+6DScbHxr+j9S/j9+7BuMs6MItE4J9EtavkFtr 45 | aw/ijGsifCKJWpkD28uZ3h83qi8diUwRde0zrX4SJAUi/T2UXPywep1z6bQ70Vaf 46 | YrciSOndw5zWiTYMUDl6q7iZR6vloiZMoGf7psLx1y0Vg4Sq8DPldXAMpaNPh8+Z 47 | UhqD94pBGg+iVaYII8MeWHaqtHc0ewQAKAq121rulOuZgaRbl/5LuQp8rQARAQAB 48 | tD1QaG9zaCBEZWJpYW4gUGFja2FnZXMgKEFyY2hpdmUgU2lnbmluZyBLZXkpIDxk 49 | ZWJzQHBob3NoLm1vYmk+iQJUBBMBCgA+AhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4B 50 | AheAFiEEeHJPmfZ/wlY1lpbHLf0ViOUfQ7IFAmXoV34FCQlmPBgACgkQLf0ViOUf 51 | Q7JWNxAApMQeEKSto6LGZkdqoKXCZgaXg//2UeAnkhK9+Z1hZ2Do7RYhoOW994yi 52 | FqtZ92WVMqzbK0EqfEnFX8yVzM1cXo3PgouCDCgTy060YmH0OV2XxThr8fJ4uZfW 53 | vib9HE+W4o/dgoMSy3BlPtpB1y/gevgJGoHAtQbV6Ex4bRL89i8pOQJYPYRx5Xj0 54 | 4SADUWWjOnY9AZbykUlMuRFSOMBWITn8yqUCYPpw8bGbtFignfvK1iRcW5LIkrtY 55 | XsOlQCK5+ttNAMUkCeI93LGYhSZUqbpt87tdkbCP5qfV7o7Vkv8iObKw8fxKh2o1 56 | oijY8S6ZqEl/CZjDtKcdvsQrEvY3Z1KX0xUNn01PFrHGzRiTn7eieXF4O3PCM2zJ 57 | 1TGva0gliKUgdN4y8W6Ul1H74T3rhZWpNO10rotfnvyX6AP/bLlkdMdSpL85mcqt 58 | PfSROQGcKOU6WmF1G2MvwzBY6sjP3IN95qqnaBKa1IJGBPFt5IsY8eoqdNuNkeRT 59 | W3OFcBQas+1RQdDzOZ7svJIX9fNBubebtnB20mRYIwESkhQMO2VpjyrBPzUP+bum 60 | kg/7Lx/Gr+OdH2SzNfeTr+28foyKExf2wdhbICErm+eRq1Bh4dFe6ljN/YBUVdEq 61 | MHjCZ4GQaiw5Uq+5sQTUWYkFeb/j3NeRadmSTshinPgTISGNYBo= 62 | =lIij 63 | -----END PGP PUBLIC KEY BLOCK----- 64 | EOF 65 | DEBIAN_FRONTEND=noninteractive apt-get update 66 | - name: apt-get build-dep 67 | run: | 68 | DEBIAN_FRONTEND=noninteractive apt-get -y --no-install-recommends -t trixie-nightly build-dep . 69 | - name: build package 70 | run: | 71 | dpkg-buildpackage -uc -us -rfakeroot -B 72 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Create release from tag 2 | on: 3 | push: 4 | tags: ['*'] 5 | permissions: 6 | contents: write 7 | jobs: 8 | release: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v4 12 | - run: | 13 | cat > body.md < 15 | HERE 16 | - uses: softprops/action-gh-release@v2 17 | with: 18 | body_path: body.md 19 | generate_release_notes: true 20 | token: ${{ secrets.RELEASE_GITHUB_TOKEN }} 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | *.tar.gz 3 | *.src.rpm 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samcday/phrog/3d0dda9022a6708475734419393ba7274da068a8/.gitmodules -------------------------------------------------------------------------------- /.packit.yaml: -------------------------------------------------------------------------------- 1 | # https://packit.dev/docs/configuration/ 2 | specfile_path: phrog.spec 3 | files_to_sync: 4 | - phrog.spec 5 | - .packit.yaml 6 | upstream_package_name: phrog 7 | downstream_package_name: phrog 8 | jobs: 9 | # Build PRs 10 | - job: copr_build 11 | manual_trigger: true 12 | trigger: pull_request 13 | additional_repos: 14 | - copr://samcday/phosh-nightly 15 | - copr://samcday/phrog-nightly 16 | targets: 17 | - fedora-41-aarch64 18 | - fedora-41-x86_64 19 | - fedora-rawhide-aarch64 20 | - fedora-rawhide-x86_64 21 | 22 | # Build main commits in samcday/phrog-nightly COPR 23 | - job: copr_build 24 | trigger: commit 25 | branch: main 26 | owner: samcday 27 | project: phrog-nightly 28 | additional_repos: 29 | - copr://samcday/phosh-nightly 30 | 31 | # Build tagged releases in samcday/phrog COPR 32 | - job: copr_build 33 | trigger: release 34 | owner: samcday 35 | project: phrog 36 | -------------------------------------------------------------------------------- /APKBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: Sam Day 2 | pkgname=greetd-phrog 3 | pkgver=0.46.0_git 4 | pkgrel=0 5 | pkgdesc="Mobile device greeter" 6 | url=https://github.com/samcday/phrog 7 | # s390x: blocked by greetd 8 | # armhf: blocked by phosh 9 | arch="all !s390x !armhf" 10 | license="GPL-3.0-only" 11 | depends=" 12 | phosh 13 | greetd 14 | greetd-phrog-schemas 15 | libphosh" 16 | makedepends=" 17 | cargo 18 | cargo-auditable 19 | foot 20 | libphosh-dev" 21 | checkdepends="xvfb-run" 22 | 23 | _gitrev=main 24 | source="https://github.com/samcday/phrog/archive/$_gitrev/phrog-$_gitrev.tar.gz" 25 | subpackages="$pkgname-schemas::noarch" 26 | builddir="$srcdir/phrog-$_gitrev" 27 | # net: cargo fetch 28 | options="net" 29 | 30 | # Tests are flaky on loongarch64 + armv7 31 | if [ "$CARCH" = "loongarch64" ] || [ "$CARCH" = "armv7" ]; then 32 | options="$options !check" 33 | fi 34 | 35 | export RUSTFLAGS="$RUSTFLAGS --remap-path-prefix=$builddir=/build/" 36 | 37 | prepare() { 38 | default_prepare 39 | cargo fetch --target="$CTARGET" --locked 40 | } 41 | 42 | build() { 43 | cargo auditable build --release --frozen 44 | } 45 | 46 | package() { 47 | install -Dm644 data/mobi.phosh.phrog.gschema.xml -t "$pkgdir"/usr/share/glib-2.0/schemas/ 48 | install -Dm644 data/phrog.session -t "$pkgdir"/usr/share/gnome-session/sessions/ 49 | install -Dm644 data/mobi.phosh.Phrog.desktop -t "$pkgdir"/usr/share/applications/ 50 | install -Dm644 dist/alpine/greetd-config.toml -t "$pkgdir"/etc/phrog/ 51 | install -d "$pkgdir"/usr/share/phrog/autostart 52 | install -d "$pkgdir"/etc/phrog/autostart 53 | install -Dm755 target/release/phrog -t "$pkgdir"/usr/bin/ 54 | install -Dm755 data/phrog-greetd-session -t "$pkgdir"/usr/libexec/ 55 | } 56 | 57 | check() { 58 | export XDG_RUNTIME_DIR="$builddir" 59 | dbus-run-session xvfb-run -a phoc -E "cargo test --frozen" 60 | } 61 | 62 | schemas() { 63 | pkgdesc="Phrog schema files" 64 | depends="" 65 | amove usr/share/glib-2.0/schemas 66 | } 67 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "phrog" 3 | version = "0.46.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | glob = "0.3.1" 8 | greetd_ipc = { version = "0.10.0", features = ["sync-codec"] } 9 | async-channel = "2.2.1" 10 | anyhow = "1.0.82" 11 | libphosh = "0.0.6" 12 | clap = { version = "4.5.4", features = ["derive"] } 13 | wayland-client = "0.31" 14 | zbus = { version = "5", default-features = false, features = ["blocking", "async-io"] } 15 | nix = { version = "0.29", features = ["signal"] } 16 | async-global-executor = "2.4.1" 17 | futures-util = "0.3.30" 18 | log = "0.4.22" 19 | 20 | [dependencies.glib] 21 | version = "0.18" 22 | features = ["log_macros"] 23 | 24 | [dependencies.gtk] 25 | version = "0.18" 26 | features = ["v3_24"] 27 | 28 | [dependencies.libhandy] 29 | version = "0.11" 30 | features = ["v1_6"] 31 | 32 | [build-dependencies] 33 | glib-build-tools = "0" 34 | 35 | [dev-dependencies] 36 | input-event-codes = "6.2.0" 37 | wayland-client = "0.31" 38 | wayland-protocols = { version = "0.32", features = ["client"] } 39 | wayland-protocols-misc = { version = "0.3", features = ["client"] } 40 | wayland-protocols-wlr = { version = "0.3", features = ["client"] } 41 | tempfile = "3" 42 | serde = "1.0.217" 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 🐸 (phrog) 2 | 3 | 4 | 5 |
6 |
7 |
8 | 9 | A greeter that works on mobile devices and also other kinds of computers. 10 | 11 | 🤓 `phrog` uses [Phosh][] to conduct a [greetd][] conversation. 12 | 13 | It is the spiritual successor of [phog][]. 14 | 15 |
16 | 17 | ## Usage 18 | 19 | ### Alpine/postmarketOS 20 | 21 | ``` 22 | sudo apk add greetd-phrog 23 | 24 | # Configure greetd to run phrog: 25 | cat < 2 | 3 | 4 | 5 | "" 6 | The last user that successfully launched a session 7 | 8 | 9 | "" 10 | The name of the last session that successfully launched 11 | 12 | 13 | "" 14 | A path to a binary that should be executed when phrog starts up, before displaying the main login screen. 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /data/phrog-greetd-session: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This simple wrapper script is intended to be used directly by greetd to 4 | # start up the phrog greeter session. 5 | # Your distribution packaging should have already set something up for you, 6 | # but if you're doing this manually you can make use of this script by 7 | # adding something like this to your config.toml: 8 | # [default_session] 9 | # command = "/usr/libexec/phrog-greetd-session" 10 | 11 | # We prefer phoc.ini from phrog, falling back to Phosh otherwise 12 | PHOC_INI=/etc/phrog/phoc.ini 13 | [ ! -f $PHOC_INI ] && PHOC_INI=/usr/share/phrog/phoc.ini 14 | [ ! -f $PHOC_INI ] && PHOC_INI=/etc/phosh/phoc.ini 15 | [ ! -f $PHOC_INI ] && PHOC_INI=/usr/share/phosh/phoc.ini 16 | 17 | # Need to set XDG_CURRENT_DESKTOP now, otherwise gnome-session defaults it to 18 | # "GNOME", which is a problem because default desktop files for Squeekboard and 19 | # phosh-osk-stub specify "OnlyShowIn=Phosh;" 20 | export XDG_CURRENT_DESKTOP=Phosh:GNOME 21 | 22 | export GNOME_SESSION_AUTOSTART_DIR=/usr/share/phrog/autostart:/etc/phrog/autostart 23 | 24 | # greetd swallows all output from the greeters it spawns. We don't want that. 25 | # Redirect all output to journald or syslog. 26 | if command -v systemd-cat >/dev/null 2>&1; then 27 | exec > >(systemd-cat --identifier=phrog) 2>&1 28 | elif command -v logger >/dev/null 2>&1; then 29 | exec > >(logger -s -t phrog) 2>&1 30 | fi 31 | 32 | # phoc needs a dbus session bus present or it fails to initialize. Since a 33 | # healthy greeter session needs one anyway, let's ensure it's started now. 34 | dbus_command="" 35 | if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then 36 | dbus_command=dbus-run-session 37 | fi 38 | 39 | exec $dbus_command phoc -S -C "${PHOC_INI}" -E 'gnome-session --session=phrog' 40 | -------------------------------------------------------------------------------- /data/phrog.session: -------------------------------------------------------------------------------- 1 | [GNOME Session] 2 | Name=phrog 3 | # Keep this in sync with systemd/user/gnome-session@phrog.target.d/session.conf 4 | RequiredComponents=mobi.phosh.Phrog;org.gnome.SettingsDaemon.MediaKeys;org.gnome.SettingsDaemon.Power;sm.puri.OSK0; 5 | -------------------------------------------------------------------------------- /data/systemd-session.conf: -------------------------------------------------------------------------------- 1 | [Unit] 2 | # Keep this in sync with phrog.session 3 | Wants=org.gnome.SettingsDaemon.MediaKeys.target 4 | Wants=org.gnome.SettingsDaemon.Power.target 5 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | phrog (0.46.0-1) unstable; urgency=medium 2 | 3 | * See https://github.com/samcday/phrog/releases/tag/0.46.0 4 | 5 | -- Sam Day Sat, 22 Mar 2025 16:40:21 +0100 6 | 7 | phrog (0.45.0-1) unstable; urgency=medium 8 | 9 | * See https://github.com/samcday/phrog/releases/tag/0.45.0 10 | 11 | -- Sam Day Sun, 02 Mar 2025 15:52:06 +0100 12 | 13 | phrog (0.44.1-1) unstable; urgency=medium 14 | 15 | * New upstream version 16 | * d/patches: update for new upstream release 17 | * d/control: update build dependencies for current Debian packages. 18 | Also add some more packages needed only for running tests, now that we 19 | can re-enable them. 20 | * d/rules: re-enable build tests. 21 | Those were previously relying on downstream libphosh-rs features, which 22 | have now been upstreamed. We can therefore re-enable those, adding the 23 | corresponding build-dependencies. 24 | * debian: install new files provided by phrog. 25 | Upstream now provides a wrapper script making use of `systemd-cat` so we 26 | can both drop our own wrapper and make our `greetd` config a bit 27 | simpler. 28 | Also install the new files found under `data/` such as the `.desktop` 29 | file and session configurations. 30 | * debian: acknowledge repacking is no longer needed. 31 | Upstream no longer ships the problematics files nor do they vendor 32 | `libphosh-rs` anymore. While at it, update `d/copyright` for the new 33 | release. 34 | * d/patches: require bash for wrapper script. 35 | It isn't POSIX-compliant, potentially leading to runtime problems if the 36 | default shell doesn't implement the corresponding bashisms. 37 | * debian: reload systemd on installation/removal. 38 | Otherwise the systemd config, especially for `greetd.service`, might be 39 | out-of-sync. 40 | 41 | -- Arnaud Ferraris Tue, 11 Feb 2025 11:58:40 +0100 42 | 43 | phrog (0.10.0+ds1-1) unstable; urgency=medium 44 | 45 | * Initial Debian packaging (Closes: #1082766) 46 | 47 | -- Arnaud Ferraris Wed, 18 Dec 2024 09:12:27 +0100 48 | -------------------------------------------------------------------------------- /debian/config/greetd/phrog.toml: -------------------------------------------------------------------------------- 1 | [terminal] 2 | vt = 7 3 | 4 | # The default session, also known as the greeter. 5 | [default_session] 6 | command = "/usr/libexec/phrog-greetd-session" 7 | user = "_greetd" 8 | -------------------------------------------------------------------------------- /debian/config/phoc.ini: -------------------------------------------------------------------------------- 1 | #[core] 2 | #xwayland=false 3 | 4 | #[output:DSI-1] 5 | #scale = 2 6 | 7 | [output:Virtual-1] 8 | # For the x86 VM using QXL to get a phone like geometry 9 | modeline = 87.25 720 776 848 976 1440 1443 1453 1493 -hsync +vsync 10 | mode = 720x1440 11 | scale = 2 12 | 13 | [output:X11-1] 14 | mode = 360x720 15 | #rotate = 90 16 | #scale = 1 17 | 18 | [output:WL-1] 19 | mode = 360x720 20 | #rotate = 90 21 | #scale = 1 22 | 23 | [output:HEADLESS-1] 24 | mode = 720x1440 25 | #rotate = 90 26 | scale = 2 27 | -------------------------------------------------------------------------------- /debian/config/systemd/phrog.conf: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Conflicts=phosh.service 3 | 4 | [Service] 5 | ExecStart= 6 | ExecStart=greetd --config /etc/greetd/phrog.toml 7 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: phrog 2 | Section: x11 3 | Priority: optional 4 | Maintainer: DebianOnMobile Maintainers 5 | Uploaders: Arnaud Ferraris 6 | Build-Depends: 7 | cargo, 8 | debhelper-compat (= 13), 9 | libphosh-0.45-dev | libphosh-dev, 10 | # Dependencies cargo culted from phosh 11 | gsettings-desktop-schemas-dev (>= 47), 12 | libadwaita-1-dev, 13 | libappstream-dev, 14 | libcallaudio-dev, 15 | libevince-dev, 16 | libgirepository1.0-dev, 17 | libjson-glib-dev, 18 | libsecret-1-dev, 19 | libsystemd-dev, 20 | libfeedback-dev (>= 0.4.0), 21 | libfribidi-dev, 22 | libgcr-3-dev, 23 | libgmobile-dev, 24 | libgnome-bluetooth-3.0-dev, 25 | libgnome-desktop-3-dev, 26 | libgtk-3-dev, 27 | libgtk-4-dev, 28 | libgudev-1.0-dev, 29 | libhandy-1-dev (>= 1.1.90), 30 | libmm-glib-dev, 31 | libnm-dev, 32 | libpam0g-dev, 33 | libpolkit-agent-1-dev, 34 | libpulse-dev, 35 | libsoup-3.0-dev, 36 | libupower-glib-dev, 37 | libwayland-dev, 38 | libxml2-utils, 39 | linux-libc-dev (>= 5.12) [arm64], 40 | # Dependencies needed only for tests 41 | at-spi2-core , 42 | dbus-x11 , 43 | foot , 44 | gnome-settings-daemon , 45 | phoc , 46 | # phosh is needed until the gschema is shipped with the lib package 47 | phosh , 48 | xauth , 49 | xvfb , 50 | Standards-Version: 4.7.0 51 | Homepage: https://github.com/samcday/phrog/ 52 | Vcs-Browser: https://salsa.debian.org/DebianOnMobile-team/phrog 53 | Vcs-Git: https://salsa.debian.org/DebianOnMobile-team/phrog.git 54 | Rules-Requires-Root: no 55 | 56 | Package: phrog 57 | Architecture: any 58 | Depends: 59 | ${misc:Depends}, 60 | ${shlibs:Depends}, 61 | fonts-lato, 62 | gnome-shell-common, 63 | greetd, 64 | librsvg2-common, 65 | phoc, 66 | polkitd, 67 | phosh-osk-stub |squeekboard, 68 | Conflicts: phog 69 | Description: Greetd-compatible greeter for mobile phones 70 | Phrog is a graphical greeter speaking the `greetd` protocol and aimed at mobile 71 | devices like smart phones and tablets using touch based inputs and small 72 | screens. 73 | . 74 | It was initially designed for the Phosh Mobile Environment based on GNOME/GTK 75 | but can spawn any graphical session. 76 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: phrog 3 | Upstream-Contact: Sam Day 4 | Source: https://github.com/samcday/phrog/ 5 | 6 | Files: * 7 | Copyright: 2024-2025 Sam Day 8 | License: GPL-3 9 | 10 | Files: debian/* 11 | Copyright: 2024-2025 Arnaud Ferraris 12 | License: GPL-3 13 | 14 | Files: tests/fixtures/guido.png 15 | tests/fixtures/phoshi.png 16 | Copyright: 2022 Guido Günther 17 | License: CC-BY-SA-4.0 18 | 19 | License: GPL-3 20 | This package is free software; you can redistribute it and/or modify 21 | it under the terms of the GNU General Public License as published by 22 | the Free Software Foundation, version 3 of the License. 23 | . 24 | This package is distributed in the hope that it will be useful, 25 | but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 | GNU General Public License for more details. 28 | . 29 | You should have received a copy of the GNU General Public License 30 | along with this program. If not, see 31 | . 32 | On Debian systems, the complete text of the GNU General 33 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". 34 | 35 | License: CC-BY-SA-4.0 36 | Attribution-ShareAlike 4.0 International 37 | . 38 | ======================================================================= 39 | . 40 | Creative Commons Corporation ("Creative Commons") is not a law firm and 41 | does not provide legal services or legal advice. Distribution of 42 | Creative Commons public licenses does not create a lawyer-client or 43 | other relationship. Creative Commons makes its licenses and related 44 | information available on an "as-is" basis. Creative Commons gives no 45 | warranties regarding its licenses, any material licensed under their 46 | terms and conditions, or any related information. Creative Commons 47 | disclaims all liability for damages resulting from their use to the 48 | fullest extent possible. 49 | . 50 | Using Creative Commons Public Licenses 51 | . 52 | Creative Commons public licenses provide a standard set of terms and 53 | conditions that creators and other rights holders may use to share 54 | original works of authorship and other material subject to copyright 55 | and certain other rights specified in the public license below. The 56 | following considerations are for informational purposes only, are not 57 | exhaustive, and do not form part of our licenses. 58 | . 59 | Considerations for licensors: Our public licenses are 60 | intended for use by those authorized to give the public 61 | permission to use material in ways otherwise restricted by 62 | copyright and certain other rights. Our licenses are 63 | irrevocable. Licensors should read and understand the terms 64 | and conditions of the license they choose before applying it. 65 | Licensors should also secure all rights necessary before 66 | applying our licenses so that the public can reuse the 67 | material as expected. Licensors should clearly mark any 68 | material not subject to the license. This includes other CC- 69 | licensed material, or material used under an exception or 70 | limitation to copyright. More considerations for licensors: 71 | wiki.creativecommons.org/Considerations_for_licensors 72 | . 73 | Considerations for the public: By using one of our public 74 | licenses, a licensor grants the public permission to use the 75 | licensed material under specified terms and conditions. If 76 | the licensor's permission is not necessary for any reason--for 77 | example, because of any applicable exception or limitation to 78 | copyright--then that use is not regulated by the license. Our 79 | licenses grant only permissions under copyright and certain 80 | other rights that a licensor has authority to grant. Use of 81 | the licensed material may still be restricted for other 82 | reasons, including because others have copyright or other 83 | rights in the material. A licensor may make special requests, 84 | such as asking that all changes be marked or described. 85 | Although not required by our licenses, you are encouraged to 86 | respect those requests where reasonable. More_considerations 87 | for the public: 88 | wiki.creativecommons.org/Considerations_for_licensees 89 | . 90 | ======================================================================= 91 | . 92 | Creative Commons Attribution-ShareAlike 4.0 International Public 93 | License 94 | . 95 | By exercising the Licensed Rights (defined below), You accept and agree 96 | to be bound by the terms and conditions of this Creative Commons 97 | Attribution-ShareAlike 4.0 International Public License ("Public 98 | License"). To the extent this Public License may be interpreted as a 99 | contract, You are granted the Licensed Rights in consideration of Your 100 | acceptance of these terms and conditions, and the Licensor grants You 101 | such rights in consideration of benefits the Licensor receives from 102 | making the Licensed Material available under these terms and 103 | conditions. 104 | . 105 | . 106 | Section 1 -- Definitions. 107 | . 108 | a. Adapted Material means material subject to Copyright and Similar 109 | Rights that is derived from or based upon the Licensed Material 110 | and in which the Licensed Material is translated, altered, 111 | arranged, transformed, or otherwise modified in a manner requiring 112 | permission under the Copyright and Similar Rights held by the 113 | Licensor. For purposes of this Public License, where the Licensed 114 | Material is a musical work, performance, or sound recording, 115 | Adapted Material is always produced where the Licensed Material is 116 | synched in timed relation with a moving image. 117 | . 118 | b. Adapter's License means the license You apply to Your Copyright 119 | and Similar Rights in Your contributions to Adapted Material in 120 | accordance with the terms and conditions of this Public License. 121 | . 122 | c. BY-SA Compatible License means a license listed at 123 | creativecommons.org/compatiblelicenses, approved by Creative 124 | Commons as essentially the equivalent of this Public License. 125 | . 126 | d. Copyright and Similar Rights means copyright and/or similar rights 127 | closely related to copyright including, without limitation, 128 | performance, broadcast, sound recording, and Sui Generis Database 129 | Rights, without regard to how the rights are labeled or 130 | categorized. For purposes of this Public License, the rights 131 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 132 | Rights. 133 | . 134 | e. Effective Technological Measures means those measures that, in the 135 | absence of proper authority, may not be circumvented under laws 136 | fulfilling obligations under Article 11 of the WIPO Copyright 137 | Treaty adopted on December 20, 1996, and/or similar international 138 | agreements. 139 | . 140 | f. Exceptions and Limitations means fair use, fair dealing, and/or 141 | any other exception or limitation to Copyright and Similar Rights 142 | that applies to Your use of the Licensed Material. 143 | . 144 | g. License Elements means the license attributes listed in the name 145 | of a Creative Commons Public License. The License Elements of this 146 | Public License are Attribution and ShareAlike. 147 | . 148 | h. Licensed Material means the artistic or literary work, database, 149 | or other material to which the Licensor applied this Public 150 | License. 151 | . 152 | i. Licensed Rights means the rights granted to You subject to the 153 | terms and conditions of this Public License, which are limited to 154 | all Copyright and Similar Rights that apply to Your use of the 155 | Licensed Material and that the Licensor has authority to license. 156 | . 157 | j. Licensor means the individual(s) or entity(ies) granting rights 158 | under this Public License. 159 | . 160 | k. Share means to provide material to the public by any means or 161 | process that requires permission under the Licensed Rights, such 162 | as reproduction, public display, public performance, distribution, 163 | dissemination, communication, or importation, and to make material 164 | available to the public including in ways that members of the 165 | public may access the material from a place and at a time 166 | individually chosen by them. 167 | . 168 | l. Sui Generis Database Rights means rights other than copyright 169 | resulting from Directive 96/9/EC of the European Parliament and of 170 | the Council of 11 March 1996 on the legal protection of databases, 171 | as amended and/or succeeded, as well as other essentially 172 | equivalent rights anywhere in the world. 173 | . 174 | m. You means the individual or entity exercising the Licensed Rights 175 | under this Public License. Your has a corresponding meaning. 176 | . 177 | . 178 | Section 2 -- Scope. 179 | . 180 | a. License grant. 181 | . 182 | 1. Subject to the terms and conditions of this Public License, 183 | the Licensor hereby grants You a worldwide, royalty-free, 184 | non-sublicensable, non-exclusive, irrevocable license to 185 | exercise the Licensed Rights in the Licensed Material to: 186 | . 187 | a. reproduce and Share the Licensed Material, in whole or 188 | in part; and 189 | . 190 | b. produce, reproduce, and Share Adapted Material. 191 | . 192 | 2. Exceptions and Limitations. For the avoidance of doubt, where 193 | Exceptions and Limitations apply to Your use, this Public 194 | License does not apply, and You do not need to comply with 195 | its terms and conditions. 196 | . 197 | 3. Term. The term of this Public License is specified in Section 198 | 6(a). 199 | . 200 | 4. Media and formats; technical modifications allowed. The 201 | Licensor authorizes You to exercise the Licensed Rights in 202 | all media and formats whether now known or hereafter created, 203 | and to make technical modifications necessary to do so. The 204 | Licensor waives and/or agrees not to assert any right or 205 | authority to forbid You from making technical modifications 206 | necessary to exercise the Licensed Rights, including 207 | technical modifications necessary to circumvent Effective 208 | Technological Measures. For purposes of this Public License, 209 | simply making modifications authorized by this Section 2(a) 210 | (4) never produces Adapted Material. 211 | . 212 | 5. Downstream recipients. 213 | . 214 | a. Offer from the Licensor -- Licensed Material. Every 215 | recipient of the Licensed Material automatically 216 | receives an offer from the Licensor to exercise the 217 | Licensed Rights under the terms and conditions of this 218 | Public License. 219 | . 220 | b. Additional offer from the Licensor -- Adapted Material. 221 | Every recipient of Adapted Material from You 222 | automatically receives an offer from the Licensor to 223 | exercise the Licensed Rights in the Adapted Material 224 | under the conditions of the Adapter's License You apply. 225 | . 226 | c. No downstream restrictions. You may not offer or impose 227 | any additional or different terms or conditions on, or 228 | apply any Effective Technological Measures to, the 229 | Licensed Material if doing so restricts exercise of the 230 | Licensed Rights by any recipient of the Licensed 231 | Material. 232 | . 233 | 6. No endorsement. Nothing in this Public License constitutes or 234 | may be construed as permission to assert or imply that You 235 | are, or that Your use of the Licensed Material is, connected 236 | with, or sponsored, endorsed, or granted official status by, 237 | the Licensor or others designated to receive attribution as 238 | provided in Section 3(a)(1)(A)(i). 239 | . 240 | b. Other rights. 241 | . 242 | 1. Moral rights, such as the right of integrity, are not 243 | licensed under this Public License, nor are publicity, 244 | privacy, and/or other similar personality rights; however, to 245 | the extent possible, the Licensor waives and/or agrees not to 246 | assert any such rights held by the Licensor to the limited 247 | extent necessary to allow You to exercise the Licensed 248 | Rights, but not otherwise. 249 | . 250 | 2. Patent and trademark rights are not licensed under this 251 | Public License. 252 | . 253 | 3. To the extent possible, the Licensor waives any right to 254 | collect royalties from You for the exercise of the Licensed 255 | Rights, whether directly or through a collecting society 256 | under any voluntary or waivable statutory or compulsory 257 | licensing scheme. In all other cases the Licensor expressly 258 | reserves any right to collect such royalties. 259 | . 260 | . 261 | Section 3 -- License Conditions. 262 | . 263 | Your exercise of the Licensed Rights is expressly made subject to the 264 | following conditions. 265 | . 266 | a. Attribution. 267 | . 268 | 1. If You Share the Licensed Material (including in modified 269 | form), You must: 270 | . 271 | a. retain the following if it is supplied by the Licensor 272 | with the Licensed Material: 273 | . 274 | i. identification of the creator(s) of the Licensed 275 | Material and any others designated to receive 276 | attribution, in any reasonable manner requested by 277 | the Licensor (including by pseudonym if 278 | designated); 279 | . 280 | ii. a copyright notice; 281 | . 282 | iii. a notice that refers to this Public License; 283 | . 284 | iv. a notice that refers to the disclaimer of 285 | warranties; 286 | . 287 | v. a URI or hyperlink to the Licensed Material to the 288 | extent reasonably practicable; 289 | . 290 | b. indicate if You modified the Licensed Material and 291 | retain an indication of any previous modifications; and 292 | . 293 | c. indicate the Licensed Material is licensed under this 294 | Public License, and include the text of, or the URI or 295 | hyperlink to, this Public License. 296 | . 297 | 2. You may satisfy the conditions in Section 3(a)(1) in any 298 | reasonable manner based on the medium, means, and context in 299 | which You Share the Licensed Material. For example, it may be 300 | reasonable to satisfy the conditions by providing a URI or 301 | hyperlink to a resource that includes the required 302 | information. 303 | . 304 | 3. If requested by the Licensor, You must remove any of the 305 | information required by Section 3(a)(1)(A) to the extent 306 | reasonably practicable. 307 | . 308 | b. ShareAlike. 309 | . 310 | In addition to the conditions in Section 3(a), if You Share 311 | Adapted Material You produce, the following conditions also apply. 312 | . 313 | 1. The Adapter's License You apply must be a Creative Commons 314 | license with the same License Elements, this version or 315 | later, or a BY-SA Compatible License. 316 | . 317 | 2. You must include the text of, or the URI or hyperlink to, the 318 | Adapter's License You apply. You may satisfy this condition 319 | in any reasonable manner based on the medium, means, and 320 | context in which You Share Adapted Material. 321 | . 322 | 3. You may not offer or impose any additional or different terms 323 | or conditions on, or apply any Effective Technological 324 | Measures to, Adapted Material that restrict exercise of the 325 | rights granted under the Adapter's License You apply. 326 | . 327 | . 328 | Section 4 -- Sui Generis Database Rights. 329 | . 330 | Where the Licensed Rights include Sui Generis Database Rights that 331 | apply to Your use of the Licensed Material: 332 | . 333 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 334 | to extract, reuse, reproduce, and Share all or a substantial 335 | portion of the contents of the database; 336 | . 337 | b. if You include all or a substantial portion of the database 338 | contents in a database in which You have Sui Generis Database 339 | Rights, then the database in which You have Sui Generis Database 340 | Rights (but not its individual contents) is Adapted Material, 341 | . 342 | including for purposes of Section 3(b); and 343 | c. You must comply with the conditions in Section 3(a) if You Share 344 | all or a substantial portion of the contents of the database. 345 | . 346 | For the avoidance of doubt, this Section 4 supplements and does not 347 | replace Your obligations under this Public License where the Licensed 348 | Rights include other Copyright and Similar Rights. 349 | . 350 | . 351 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 352 | . 353 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 354 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 355 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 356 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 357 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 358 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 359 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 360 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 361 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 362 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 363 | . 364 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 365 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 366 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 367 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 368 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 369 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 370 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 371 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 372 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 373 | . 374 | c. The disclaimer of warranties and limitation of liability provided 375 | above shall be interpreted in a manner that, to the extent 376 | possible, most closely approximates an absolute disclaimer and 377 | waiver of all liability. 378 | . 379 | . 380 | Section 6 -- Term and Termination. 381 | . 382 | a. This Public License applies for the term of the Copyright and 383 | Similar Rights licensed here. However, if You fail to comply with 384 | this Public License, then Your rights under this Public License 385 | terminate automatically. 386 | . 387 | b. Where Your right to use the Licensed Material has terminated under 388 | Section 6(a), it reinstates: 389 | . 390 | 1. automatically as of the date the violation is cured, provided 391 | it is cured within 30 days of Your discovery of the 392 | violation; or 393 | . 394 | 2. upon express reinstatement by the Licensor. 395 | . 396 | For the avoidance of doubt, this Section 6(b) does not affect any 397 | right the Licensor may have to seek remedies for Your violations 398 | of this Public License. 399 | . 400 | c. For the avoidance of doubt, the Licensor may also offer the 401 | Licensed Material under separate terms or conditions or stop 402 | distributing the Licensed Material at any time; however, doing so 403 | will not terminate this Public License. 404 | . 405 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 406 | License. 407 | . 408 | . 409 | Section 7 -- Other Terms and Conditions. 410 | . 411 | a. The Licensor shall not be bound by any additional or different 412 | terms or conditions communicated by You unless expressly agreed. 413 | . 414 | b. Any arrangements, understandings, or agreements regarding the 415 | Licensed Material not stated herein are separate from and 416 | independent of the terms and conditions of this Public License. 417 | . 418 | . 419 | Section 8 -- Interpretation. 420 | . 421 | a. For the avoidance of doubt, this Public License does not, and 422 | shall not be interpreted to, reduce, limit, restrict, or impose 423 | conditions on any use of the Licensed Material that could lawfully 424 | be made without permission under this Public License. 425 | . 426 | b. To the extent possible, if any provision of this Public License is 427 | deemed unenforceable, it shall be automatically reformed to the 428 | minimum extent necessary to make it enforceable. If the provision 429 | cannot be reformed, it shall be severed from this Public License 430 | without affecting the enforceability of the remaining terms and 431 | conditions. 432 | . 433 | c. No term or condition of this Public License will be waived and no 434 | failure to comply consented to unless expressly agreed to by the 435 | Licensor. 436 | . 437 | d. Nothing in this Public License constitutes or may be interpreted 438 | as a limitation upon, or waiver of, any privileges and immunities 439 | that apply to the Licensor or You, including from the legal 440 | processes of any jurisdiction or authority. 441 | . 442 | . 443 | ======================================================================= 444 | . 445 | Creative Commons is not a party to its public licenses. 446 | Notwithstanding, Creative Commons may elect to apply one of its public 447 | licenses to material it publishes and in those instances will be 448 | considered the "Licensor." Except for the limited purpose of indicating 449 | that material is shared under a Creative Commons public license or as 450 | otherwise permitted by the Creative Commons policies published at 451 | creativecommons.org/policies, Creative Commons does not authorize the 452 | use of the trademark "Creative Commons" or any other trademark or logo 453 | of Creative Commons without its prior written consent including, 454 | without limitation, in connection with any unauthorized modifications 455 | to any of its public licenses or any other arrangements, 456 | understandings, or agreements concerning use of licensed material. For 457 | the avoidance of doubt, this paragraph does not form part of the public 458 | licenses. 459 | . 460 | Creative Commons may be contacted at creativecommons.org. 461 | -------------------------------------------------------------------------------- /debian/gbp.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | debian-branch = main 3 | upstream-vcs-tag = %(version)s 4 | pristine-tar = True 5 | 6 | [tag] 7 | sign-tags = True 8 | 9 | [dch] 10 | multimaint-merge = True 11 | commit-msg = d/changelog: release version %(version)s 12 | 13 | [import-orig] 14 | postimport = dch -v%(version)s New upstream version; git add debian/changelog; debcommit 15 | -------------------------------------------------------------------------------- /debian/patches/series: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samcday/phrog/3d0dda9022a6708475734419393ba7274da068a8/debian/patches/series -------------------------------------------------------------------------------- /debian/phrog.install: -------------------------------------------------------------------------------- 1 | # Upstream files 2 | data/mobi.phosh.phrog.gschema.xml usr/share/glib-2.0/schemas 3 | data/phrog.session usr/share/gnome-session/sessions 4 | data/mobi.phosh.Phrog.desktop usr/share/applications 5 | data/systemd-session.conf usr/lib/systemd/user/gnome-session@phrog.target.d 6 | 7 | # Debian-specific config 8 | debian/config/greetd/phrog.toml etc/greetd 9 | debian/config/phoc.ini usr/share/phrog 10 | debian/config/systemd/phrog.conf usr/lib/systemd/system/greetd.service.d 11 | -------------------------------------------------------------------------------- /debian/phrog.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ "$1" = "configure" ]; then 6 | # Ensure our config fragments are taken into account 7 | deb-systemd-invoke --system daemon-reload 8 | deb-systemd-invoke --user daemon-reload 9 | fi 10 | 11 | #DEBHELPER# 12 | -------------------------------------------------------------------------------- /debian/phrog.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then 6 | # Ensure our config fragments are no longer taken into account 7 | deb-systemd-invoke --system daemon-reload 8 | deb-systemd-invoke --user daemon-reload 9 | fi 10 | 11 | #DEBHELPER# 12 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | export DEB_BUILD_MAINT_OPTIONS = hardening=+all 4 | 5 | include /usr/share/dpkg/default.mk 6 | export INSTALL_DIR=$(CURDIR)/debian/phrog 7 | 8 | %: 9 | dh $@ 10 | 11 | # The custom build.rs works under $HOME to ensure the glib schemas 12 | # compile cleanly, so let's ensure there's a valid/writable $HOME 13 | # during build and delete it afterwards 14 | override_dh_auto_build: 15 | HOME=$(CURDIR)/debian/tmp_home cargo build 16 | 17 | override_dh_auto_install: 18 | install -D -m0755 target/$(DEB_HOST_RUST_TYPE)/debug/phrog \ 19 | $(INSTALL_DIR)/usr/bin/phrog 20 | install -D -m0755 data/phrog-greetd-session \ 21 | $(INSTALL_DIR)/usr/libexec/phrog-greetd-session 22 | 23 | override_dh_auto_test: 24 | ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),) 25 | mkdir -p $(CURDIR)/debian/tmp_home $(CURDIR)/debian/tmp_run 26 | LC_ALL=C.UTF-8 XDG_RUNTIME_DIR=$(CURDIR)/debian/tmp_run \ 27 | HOME=$(CURDIR)/debian/tmp_home dbus-run-session xvfb-run -a \ 28 | phoc -C $(CURDIR)/debian/config/phoc.ini -E "cargo test" 29 | endif 30 | 31 | execute_after_dh_auto_clean: 32 | rm -rf $(CURDIR)/debian/tmp_home $(CURDIR)/debian/tmp_run 33 | -------------------------------------------------------------------------------- /debian/salsa-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | include: 3 | - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/recipes/debian.yml 4 | 5 | variables: 6 | SALSA_CI_DISABLE_BLHC: 1 7 | SALSA_CI_DISABLE_REPROTEST: 1 8 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /debian/upstream/metadata: -------------------------------------------------------------------------------- 1 | --- 2 | Bug-Database: https://github.com/samcday/phrog/issues 3 | Bug-Submit: https://github.com/samcday/phrog/issues/new 4 | Repository: https://github.com/samcday/phrog.git 5 | Repository-Browse: https://github.com/samcday/phrog 6 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=4 2 | opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/@PACKAGE@-$1\.tar\.gz/ \ 3 | https://github.com/samcday/phrog/tags .*/v?@ANY_VERSION@\.tar\.gz 4 | -------------------------------------------------------------------------------- /dist/alpine/greetd-config.toml: -------------------------------------------------------------------------------- 1 | # This is a greetd config.toml preconfigured to run phrog. 2 | # You can use it by adding the following line to /etc/conf.d/greetd: 3 | # cfgfile="/etc/phrog/greetd-config.toml" 4 | 5 | [terminal] 6 | vt = 7 7 | 8 | [default_session] 9 | command = "/usr/libexec/phrog-greetd-session" 10 | user = "greetd" 11 | -------------------------------------------------------------------------------- /dist/fedora/greetd-config.toml: -------------------------------------------------------------------------------- 1 | # This is a greetd config.toml preconfigured to run phrog. 2 | # It's intended to be used with phrog.service 3 | # But you can also use it directly by running greetd --config=/etc/phrog/greetd-config.toml 4 | 5 | [terminal] 6 | vt = 1 7 | 8 | [default_session] 9 | command = "/usr/libexec/phrog-greetd-session" 10 | user = "greetd" 11 | -------------------------------------------------------------------------------- /dist/fedora/phrog.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Phrog greeter daemon 3 | After=systemd-user-sessions.service plymouth-quit-wait.service 4 | After=getty@tty1.service 5 | Conflicts=getty@tty1.service greetd.service gdm.service 6 | 7 | [Service] 8 | Type=simple 9 | ExecStart=greetd --config=/etc/phrog/greetd-config.toml 10 | IgnoreSIGPIPE=no 11 | SendSIGHUP=yes 12 | TimeoutStopSec=30s 13 | KeyringMode=shared 14 | Restart=always 15 | RestartSec=1 16 | StartLimitBurst=5 17 | StartLimitInterval=30 18 | 19 | [Install] 20 | Alias=display-manager.service 21 | -------------------------------------------------------------------------------- /phrog.spec: -------------------------------------------------------------------------------- 1 | %bcond_without check 2 | %global cargo_install_lib 0 3 | 4 | Name: phrog 5 | Version: 0.46.0 6 | Release: %autorelease 7 | Summary: Mobile-friendly greeter for greetd 8 | License: GPL-3.0-only 9 | URL: https://github.com/samcday/phrog 10 | Source: %{url}/archive/%{version}/%{name}-%{version}.tar.gz 11 | 12 | ExcludeArch: %{ix86} 13 | 14 | BuildRequires: cargo-rpm-macros >= 24 15 | # for dbus-run-session in %check 16 | BuildRequires: dbus-daemon 17 | # for xvfb-run in %check 18 | BuildRequires: xorg-x11-server-Xvfb 19 | # first-run test uses foot 20 | BuildRequires: foot 21 | 22 | Requires: accountsservice 23 | Requires: gnome-session 24 | Requires: greetd 25 | Requires: phoc 26 | Requires: phosh-osk = 1.0 27 | 28 | %description 29 | Phrog uses Phosh and greetd to provide a graphical login manager. 30 | 31 | %prep 32 | %autosetup -p1 33 | %cargo_prep 34 | # tests need a writable XDG_RUNTIME_DIR 35 | mkdir -p /tmp/runtime-dir 36 | chmod 0700 /tmp/runtime-dir 37 | 38 | %generate_buildrequires 39 | %cargo_generate_buildrequires 40 | 41 | %build 42 | %cargo_build 43 | %{cargo_license_summary} 44 | %{cargo_license} > LICENSE.dependencies 45 | 46 | %install 47 | %{__install} -Dpm 0644 data/mobi.phosh.phrog.gschema.xml -t %{buildroot}%{_datadir}/glib-2.0/schemas/ 48 | %{__install} -Dpm 0644 data/phrog.session -t %{buildroot}%{_datadir}/gnome-session/sessions/ 49 | %{__install} -Dpm 0644 data/mobi.phosh.Phrog.desktop -t %{buildroot}%{_datadir}/applications/ 50 | %{__install} -Dpm 0644 dist/fedora/greetd-config.toml -t %{buildroot}%{_sysconfdir}/phrog/ 51 | %{__install} -Dpm 0644 dist/fedora/phrog.service -t %{buildroot}%{_unitdir}/ 52 | %{__install} -Dpm 0644 data/systemd-session.conf -T %{buildroot}%{_userunitdir}/gnome-session@phrog.target.d/session.conf 53 | %{__install} -Dpm 0755 data/phrog-greetd-session -t %{buildroot}%{_libexecdir}/ 54 | %{__install} -d %{buildroot}%{_datadir}/phrog/autostart 55 | %{__install} -d %{buildroot}%{_sysconfdir}/phrog/autostart 56 | %cargo_install 57 | 58 | %if %{with check} 59 | %check 60 | export G_MESSAGES_DEBUG=all 61 | export XDG_RUNTIME_DIR=/tmp/runtime-dir 62 | cat > test.sh < 2 | 3 | 4 | 80 | 81 | -------------------------------------------------------------------------------- /resources/phrog.css: -------------------------------------------------------------------------------- 1 | phosh-top-panel.debug { 2 | background-color: red; 3 | animation: red-pulse 2s linear infinite; 4 | } 5 | 6 | .phosh-fader-default-fade { 7 | animation-duration: 500ms; 8 | } 9 | 10 | @keyframes red-pulse 11 | { 12 | 0% {background-color: @phosh_bg_color;} 13 | 50% {background-color: red;} 14 | 100% {background-color: @phosh_bg_color;} 15 | } 16 | 17 | phrog-user-session-page list { 18 | background-color: transparent; 19 | } 20 | 21 | phrog-user-session-page .users row:not(:selected) { 22 | background-color: @phosh_action_bg_color; 23 | } 24 | 25 | phrog-user-session-page .users row:selected { 26 | background-color: @theme_selected_bg_color; 27 | } 28 | 29 | phrog-user-session-page .sessions { 30 | background-color: @phosh_action_bg_color; 31 | } 32 | 33 | phrog-user-session-page row:first-child { 34 | -gtk-outline-top-left-radius: 7px; 35 | -gtk-outline-top-right-radius: 7px; 36 | border-top-left-radius: 8px; 37 | border-top-right-radius: 8px; 38 | } 39 | 40 | phrog-user-session-page row:not(:last-child) { 41 | border-width: 1px 1px 0px 1px; 42 | } 43 | 44 | phrog-user-session-page row:last-child { 45 | -gtk-outline-bottom-left-radius: 7px; 46 | -gtk-outline-bottom-right-radius: 7px; 47 | border-bottom-left-radius: 8px; 48 | border-bottom-right-radius: 8px; 49 | } 50 | -------------------------------------------------------------------------------- /resources/phrog.gresources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | lockscreen-user-session.ui 5 | shuffle-keypad-quick-setting.ui 6 | phrog.css 7 | 8 | 9 | -------------------------------------------------------------------------------- /resources/shuffle-keypad-quick-setting.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /src/dbus.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(clippy::type_complexity)] 3 | pub mod accounts { 4 | //! # D-Bus interface proxy for: `org.freedesktop.Accounts` 5 | //! 6 | //! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data. 7 | use zbus::proxy; 8 | #[proxy( 9 | interface = "org.freedesktop.Accounts", 10 | default_service = "org.freedesktop.Accounts", 11 | default_path = "/org/freedesktop/Accounts" 12 | )] 13 | pub trait Accounts { 14 | /// CacheUser method 15 | fn cache_user(&self, name: &str) -> zbus::Result; 16 | 17 | /// CreateUser method 18 | fn create_user( 19 | &self, 20 | name: &str, 21 | fullname: &str, 22 | accountType: i32, 23 | ) -> zbus::Result; 24 | 25 | /// DeleteUser method 26 | fn delete_user(&self, id: i64, removeFiles: bool) -> zbus::Result<()>; 27 | 28 | /// FindUserById method 29 | fn find_user_by_id(&self, id: i64) -> zbus::Result; 30 | 31 | /// FindUserByName method 32 | fn find_user_by_name(&self, name: &str) -> zbus::Result; 33 | 34 | /// GetUsersLanguages method 35 | fn get_users_languages(&self) -> zbus::Result>; 36 | 37 | /// ListCachedUsers method 38 | fn list_cached_users(&self) -> zbus::Result>; 39 | 40 | /// UncacheUser method 41 | fn uncache_user(&self, name: &str) -> zbus::Result<()>; 42 | 43 | /// UserAdded signal 44 | #[zbus(signal)] 45 | fn user_added(&self, user: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>; 46 | 47 | /// UserDeleted signal 48 | #[zbus(signal)] 49 | fn user_deleted(&self, user: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>; 50 | 51 | /// AutomaticLoginUsers property 52 | #[zbus(property)] 53 | fn automatic_login_users(&self) -> zbus::Result>; 54 | 55 | /// DaemonVersion property 56 | #[zbus(property)] 57 | fn daemon_version(&self) -> zbus::Result; 58 | 59 | /// HasMultipleUsers property 60 | #[zbus(property)] 61 | fn has_multiple_users(&self) -> zbus::Result; 62 | 63 | /// HasNoUsers property 64 | #[zbus(property)] 65 | fn has_no_users(&self) -> zbus::Result; 66 | } 67 | } 68 | 69 | pub mod user { 70 | //! # D-Bus interface proxy for: `org.freedesktop.Accounts.User` 71 | //! 72 | //! This code was generated by `zbus-xmlgen` `4.1.0` from D-Bus introspection data. 73 | use zbus::proxy; 74 | #[proxy( 75 | default_service = "org.freedesktop.Accounts", 76 | interface = "org.freedesktop.Accounts.User" 77 | )] 78 | pub trait User { 79 | /// GetPasswordExpirationPolicy method 80 | fn get_password_expiration_policy(&self) -> zbus::Result<(i64, i64, i64, i64, i64, i64)>; 81 | 82 | /// SetAccountType method 83 | fn set_account_type(&self, accountType: i32) -> zbus::Result<()>; 84 | 85 | /// SetAutomaticLogin method 86 | fn set_automatic_login(&self, enabled: bool) -> zbus::Result<()>; 87 | 88 | /// SetEmail method 89 | fn set_email(&self, email: &str) -> zbus::Result<()>; 90 | 91 | /// SetHomeDirectory method 92 | fn set_home_directory(&self, homedir: &str) -> zbus::Result<()>; 93 | 94 | /// SetIconFile method 95 | fn set_icon_file(&self, filename: &str) -> zbus::Result<()>; 96 | 97 | /// SetLanguage method 98 | fn set_language(&self, language: &str) -> zbus::Result<()>; 99 | 100 | /// SetLanguages method 101 | fn set_languages(&self, languages: &[&str]) -> zbus::Result<()>; 102 | 103 | /// SetLocation method 104 | fn set_location(&self, location: &str) -> zbus::Result<()>; 105 | 106 | /// SetLocked method 107 | fn set_locked(&self, locked: bool) -> zbus::Result<()>; 108 | 109 | /// SetPassword method 110 | fn set_password(&self, password: &str, hint: &str) -> zbus::Result<()>; 111 | 112 | /// SetPasswordExpirationPolicy method 113 | fn set_password_expiration_policy( 114 | &self, 115 | min_days_between_changes: i64, 116 | max_days_between_changes: i64, 117 | days_to_warn: i64, 118 | days_after_expiration_until_lock: i64, 119 | ) -> zbus::Result<()>; 120 | 121 | /// SetPasswordHint method 122 | fn set_password_hint(&self, hint: &str) -> zbus::Result<()>; 123 | 124 | /// SetPasswordMode method 125 | fn set_password_mode(&self, mode: i32) -> zbus::Result<()>; 126 | 127 | /// SetRealName method 128 | fn set_real_name(&self, name: &str) -> zbus::Result<()>; 129 | 130 | /// SetSession method 131 | fn set_session(&self, session: &str) -> zbus::Result<()>; 132 | 133 | /// SetSessionType method 134 | fn set_session_type(&self, session_type: &str) -> zbus::Result<()>; 135 | 136 | /// SetShell method 137 | fn set_shell(&self, shell: &str) -> zbus::Result<()>; 138 | 139 | /// SetUserExpirationPolicy method 140 | fn set_user_expiration_policy(&self, expiration_time: i64) -> zbus::Result<()>; 141 | 142 | /// SetUserName method 143 | fn set_user_name(&self, name: &str) -> zbus::Result<()>; 144 | 145 | /// SetXSession method 146 | #[zbus(name = "SetXSession")] 147 | fn set_xsession(&self, x_session: &str) -> zbus::Result<()>; 148 | 149 | /// Changed signal 150 | #[zbus(signal)] 151 | fn changed(&self) -> zbus::Result<()>; 152 | 153 | /// AccountType property 154 | #[zbus(property)] 155 | fn account_type(&self) -> zbus::Result; 156 | 157 | /// AutomaticLogin property 158 | #[zbus(property)] 159 | fn automatic_login(&self) -> zbus::Result; 160 | 161 | /// Email property 162 | #[zbus(property)] 163 | fn email(&self) -> zbus::Result; 164 | 165 | /// HomeDirectory property 166 | #[zbus(property)] 167 | fn home_directory(&self) -> zbus::Result; 168 | 169 | /// IconFile property 170 | #[zbus(property)] 171 | fn icon_file(&self) -> zbus::Result; 172 | 173 | /// Language property 174 | #[zbus(property)] 175 | fn language(&self) -> zbus::Result; 176 | 177 | /// Languages property 178 | #[zbus(property)] 179 | fn languages(&self) -> zbus::Result>; 180 | 181 | /// LocalAccount property 182 | #[zbus(property)] 183 | fn local_account(&self) -> zbus::Result; 184 | 185 | /// Location property 186 | #[zbus(property)] 187 | fn location(&self) -> zbus::Result; 188 | 189 | /// Locked property 190 | #[zbus(property)] 191 | fn locked(&self) -> zbus::Result; 192 | 193 | /// LoginFrequency property 194 | #[zbus(property)] 195 | fn login_frequency(&self) -> zbus::Result; 196 | 197 | /// LoginHistory property 198 | #[zbus(property)] 199 | fn login_history( 200 | &self, 201 | ) -> zbus::Result< 202 | Vec<( 203 | i64, 204 | i64, 205 | std::collections::HashMap, 206 | )>, 207 | >; 208 | 209 | /// LoginTime property 210 | #[zbus(property)] 211 | fn login_time(&self) -> zbus::Result; 212 | 213 | /// PasswordHint property 214 | #[zbus(property)] 215 | fn password_hint(&self) -> zbus::Result; 216 | 217 | /// PasswordMode property 218 | #[zbus(property)] 219 | fn password_mode(&self) -> zbus::Result; 220 | 221 | /// RealName property 222 | #[zbus(property)] 223 | fn real_name(&self) -> zbus::Result; 224 | 225 | /// Saved property 226 | #[zbus(property)] 227 | fn saved(&self) -> zbus::Result; 228 | 229 | /// Session property 230 | #[zbus(property)] 231 | fn session(&self) -> zbus::Result; 232 | 233 | /// SessionType property 234 | #[zbus(property)] 235 | fn session_type(&self) -> zbus::Result; 236 | 237 | /// Shell property 238 | #[zbus(property)] 239 | fn shell(&self) -> zbus::Result; 240 | 241 | /// SystemAccount property 242 | #[zbus(property)] 243 | fn system_account(&self) -> zbus::Result; 244 | 245 | /// Uid property 246 | #[zbus(property)] 247 | fn uid(&self) -> zbus::Result; 248 | 249 | /// UserName property 250 | #[zbus(property)] 251 | fn user_name(&self) -> zbus::Result; 252 | 253 | /// XSession property 254 | #[zbus(property, name = "XSession")] 255 | fn xsession(&self) -> zbus::Result; 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod lockscreen; 2 | pub mod shell; 3 | pub mod supervised_child; 4 | 5 | mod dbus; 6 | pub mod session_object; 7 | mod sessions; 8 | mod user; 9 | mod user_session_page; 10 | 11 | use anyhow::{anyhow, Context}; 12 | use gtk::{gdk, gio}; 13 | use wayland_client::protocol::wl_registry; 14 | 15 | pub const APP_ID: &str = "mobi.phosh.phrog"; 16 | 17 | struct DetectPhoc(bool); 18 | 19 | impl wayland_client::Dispatch for DetectPhoc { 20 | fn event( 21 | state: &mut Self, 22 | _: &wl_registry::WlRegistry, 23 | event: wl_registry::Event, 24 | _: &(), 25 | _: &wayland_client::Connection, 26 | _: &wayland_client::QueueHandle, 27 | ) { 28 | if let wl_registry::Event::Global { interface, .. } = event { 29 | if interface == "phosh_private" { 30 | state.0 = true; 31 | } 32 | } 33 | } 34 | } 35 | 36 | fn is_phoc_detected() -> anyhow::Result { 37 | let conn = wayland_client::Connection::connect_to_env()?; 38 | let display = conn.display(); 39 | let mut event_queue = conn.new_event_queue(); 40 | let qh = event_queue.handle(); 41 | let _registry = display.get_registry(&qh, ()); 42 | let detect = &mut DetectPhoc(false); 43 | event_queue.roundtrip(detect)?; 44 | Ok(detect.0) 45 | } 46 | 47 | pub fn init() -> anyhow::Result<()> { 48 | gio::resources_register_include!("phrog.gresource").context("failed to register resources.")?; 49 | 50 | if !is_phoc_detected().context("failed to detect Wayland compositor globals")? { 51 | return Err(anyhow!("Phoc parent compositor not detected")); 52 | } 53 | 54 | gdk::set_allowed_backends("wayland"); 55 | 56 | gdk::init(); 57 | 58 | let display = gdk::Display::default(); 59 | if display.is_none() { 60 | return Err(anyhow!("failed GDK init")); 61 | } 62 | 63 | gtk::init()?; 64 | libhandy::init(); 65 | Ok(()) 66 | } 67 | -------------------------------------------------------------------------------- /src/lockscreen.rs: -------------------------------------------------------------------------------- 1 | use glib::Object; 2 | use greetd_ipc::AuthMessageType::Secret; 3 | use greetd_ipc::ErrorType::AuthError; 4 | use greetd_ipc::{Request, Response}; 5 | use gtk::glib; 6 | 7 | static G_LOG_DOMAIN: &str = "phrog-lockscreen"; 8 | 9 | glib::wrapper! { 10 | pub struct Lockscreen(ObjectSubclass) 11 | @extends libphosh::Lockscreen, gtk::Widget, gtk::Window, gtk::Bin; 12 | } 13 | 14 | impl Lockscreen { 15 | pub fn new() -> Self { 16 | Object::builder().build() 17 | } 18 | } 19 | 20 | impl Default for Lockscreen { 21 | fn default() -> Self { 22 | Self::new() 23 | } 24 | } 25 | 26 | mod imp { 27 | use super::G_LOG_DOMAIN; 28 | use crate::lockscreen::fake_greetd_interaction; 29 | use crate::shell::Shell; 30 | use crate::user_session_page::UserSessionPage; 31 | use crate::APP_ID; 32 | use anyhow::{anyhow, Context}; 33 | use async_channel::{Receiver, Sender}; 34 | use glib::{error, info, warn}; 35 | use greetd_ipc::codec::SyncCodec; 36 | use greetd_ipc::{AuthMessageType, ErrorType, Request, Response}; 37 | use gtk::gio::Settings; 38 | use gtk::glib::{clone, closure_local, timeout_add_once, ObjectExt, Properties}; 39 | use gtk::prelude::SettingsExtManual; 40 | use gtk::prelude::*; 41 | use gtk::subclass::prelude::*; 42 | use gtk::{gio, glib}; 43 | use libphosh::prelude::*; 44 | use libphosh::subclass::lockscreen::LockscreenImpl; 45 | use libphosh::LockscreenPage; 46 | use std::cell::{OnceCell, RefCell}; 47 | use std::os::unix::net::UnixStream; 48 | use std::time::Duration; 49 | 50 | #[derive(Default, Properties)] 51 | #[properties(wrapper_type = super::Lockscreen)] 52 | pub struct Lockscreen { 53 | #[property(get, set)] 54 | pub user_session_page: OnceCell, 55 | greetd: RefCell, Receiver)>>, 56 | session: RefCell>, 57 | } 58 | 59 | #[glib::object_subclass] 60 | impl ObjectSubclass for Lockscreen { 61 | const NAME: &'static str = "PhrogLockscreen"; 62 | type Type = super::Lockscreen; 63 | type ParentType = libphosh::Lockscreen; 64 | } 65 | 66 | fn run_greetd() -> (Sender, Receiver) { 67 | let (greetd_req_send, greetd_req_recv) = async_channel::bounded::(1); 68 | let (greetd_resp_send, greetd_resp_recv) = async_channel::bounded(1); 69 | 70 | gio::spawn_blocking(move || { 71 | let mut sock = std::env::var("GREETD_SOCK") 72 | .ok() 73 | .and_then(|path| UnixStream::connect(path).ok()); 74 | while let Ok(req) = greetd_req_recv.recv_blocking() { 75 | let resp = if let Some(ref mut sock) = sock { 76 | req.write_to(sock) 77 | .and_then(|_| Response::read_from(sock)) 78 | .unwrap_or_else(|err| Response::Error { 79 | error_type: ErrorType::Error, 80 | description: err.to_string(), 81 | }) 82 | } else { 83 | Response::Error { 84 | error_type: ErrorType::Error, 85 | description: "Greetd not connected".into(), 86 | } 87 | }; 88 | 89 | if let Err(err) = greetd_resp_send.send_blocking(resp) { 90 | error!("error sending greetd response on channel: {}", err); 91 | continue; 92 | } 93 | } 94 | }); 95 | 96 | (greetd_req_send, greetd_resp_recv) 97 | } 98 | 99 | #[glib::derived_properties] 100 | impl ObjectImpl for Lockscreen { 101 | fn constructed(&self) { 102 | let self_obj = self.obj(); 103 | let usp = UserSessionPage::new(); 104 | 105 | // Default unlock status in PhoshLockscreen is "Enter Passcode", which doesn't make 106 | // sense in our case. 107 | self_obj.set_unlock_status(""); 108 | 109 | // Insert the UserSessionPage widget into the "extra page" of Phosh.Lockscreen. 110 | // This sits in-between the Info and Unlock (keypad) pages. 111 | // We default to this page (which means inactivity bounces user back to it). 112 | self_obj.add_extra_page(&usp); 113 | self_obj.set_default_page(LockscreenPage::Extra); 114 | 115 | // Add a signal handler for when Phosh.Lockscreen active page changes. 116 | // We hook up greetd session initiation/cancellation to this. 117 | self_obj.connect_page_notify(clone!(@weak self as this => move |ls| { 118 | glib::spawn_future_local(clone!(@weak ls => async move { 119 | // Page is lockscreen, begin greetd conversation. 120 | if ls.page() == LockscreenPage::Unlock { 121 | this.obj().set_default_page(LockscreenPage::Unlock); 122 | this.create_session().await; 123 | } else { 124 | // No longer on unlock, cancel session. 125 | this.obj().set_default_page(LockscreenPage::Extra); 126 | this.cancel_session().await; 127 | this.session.replace(None); 128 | // Make absolutely sure that lockscreen is sensitive again. 129 | // This should already be taken care of elsewhere, but if we somehow hit 130 | // an edge case in the convoluted dance with greetd, we really don't want 131 | // the user to end up with a lockscreen that cannot be interacted with, as 132 | // that deadlocks the whole UI, basically. 133 | this.obj().set_sensitive(true); 134 | } 135 | })); 136 | })); 137 | 138 | // Add a handler for the UserSessionPage notifying of readiness, which happens when 139 | // all user+sessions on the system have been loaded. At this point we can decide if 140 | // the "trivial flow" is suitable (jump straight to keypad if there's only one user and 141 | // session choice available). 142 | usp.connect_ready_notify(clone!(@weak self_obj => move |usp| { 143 | let shell = Shell::default(); 144 | let user_count = usp.imp().box_users.children().len(); 145 | let session_count = shell.sessions().map_or(0, |s| s.n_items()); 146 | // If there's only one user and one session, set the default + active page to the keypad. 147 | if session_count == 1 && user_count == 1 { 148 | self_obj.set_page(LockscreenPage::Unlock); 149 | } 150 | })); 151 | 152 | usp.connect_closure( 153 | "login", 154 | false, 155 | closure_local!(@watch self_obj => move |_: UserSessionPage| { 156 | self_obj.set_page(LockscreenPage::Unlock); 157 | }), 158 | ); 159 | 160 | self.user_session_page.set(usp).unwrap(); 161 | 162 | self.parent_constructed(); 163 | } 164 | } 165 | 166 | impl Lockscreen { 167 | // Whenever user swipes away from keypad entry page, and after an auth failure, fire off a 168 | // CancelSession. 169 | async fn cancel_session(&self) { 170 | if self.session.borrow().is_none() { 171 | // no session to cancel 172 | return; 173 | } 174 | 175 | if let Err(err) = self.greetd_req(Request::CancelSession).await { 176 | warn!("greetd CancelSession failed: {}", err); 177 | } 178 | } 179 | 180 | async fn create_session(&self) { 181 | let user = self.user_session_page.get().unwrap().username(); 182 | if user.is_none() || self.session.borrow().eq(&user) { 183 | // no user selected, or the session for that user is already started 184 | return; 185 | } 186 | 187 | self.session.replace(user.clone()); 188 | let username = user.unwrap(); 189 | info!("creating greetd session for user {}", username); 190 | self.obj().set_unlock_status("Please wait..."); 191 | self.obj().set_sensitive(false); 192 | let mut req = Some(Request::CreateSession { username }); 193 | while let Some(next_req) = req.take() { 194 | req = self.greetd_interaction(next_req).await; 195 | } 196 | } 197 | 198 | async fn start_session(&self) -> anyhow::Result<()> { 199 | let session = self.user_session_page.get().unwrap().session(); 200 | 201 | let settings = Settings::new(APP_ID); 202 | if let Err(err) = 203 | settings.set("last-user", self.session.clone().take().unwrap_or_default()) 204 | { 205 | warn!("setting last-user failed {}", err); 206 | } 207 | 208 | if let Err(err) = settings.set("last-session", session.id()) { 209 | warn!("setting last-session failed {}", err); 210 | } 211 | self.greetd_req(Request::StartSession { 212 | cmd: vec![session.command()], 213 | env: vec![ 214 | format!("XDG_SESSION_TYPE={}", session.session_type()), 215 | format!("XDG_CURRENT_DESKTOP={}", session.desktop_names()), 216 | format!("XDG_SESSION_DESKTOP={}", session.id()), 217 | format!("GDMSESSION={}", session.id()), 218 | ], 219 | }) 220 | .await 221 | .context("start session")?; 222 | 223 | Ok(()) 224 | } 225 | 226 | async fn greetd_req(&self, req: Request) -> anyhow::Result { 227 | if Shell::default().fake_greetd() { 228 | return fake_greetd_interaction(req); 229 | } 230 | if self.greetd.borrow().is_none() { 231 | self.greetd.set(Some(run_greetd())); 232 | } 233 | let (sender, receiver) = self.greetd.clone().take().unwrap(); 234 | sender.send(req).await.context("send greetd request")?; 235 | match receiver.recv().await.context("receive greetd response")? { 236 | Response::Error { 237 | error_type: ErrorType::Error, 238 | description, 239 | } => Err(anyhow!("greetd error: {}", description)), 240 | resp => Ok(resp), 241 | } 242 | } 243 | 244 | async fn greetd_interaction(&self, req: Request) -> Option { 245 | let resp = self.greetd_req(req).await; 246 | 247 | if let Err(err) = resp { 248 | error!("failed to send greetd request: {:?}", err); 249 | self.obj().set_unlock_status("Error, please try again"); 250 | self.obj().set_sensitive(true); 251 | return None; 252 | } 253 | 254 | match resp.unwrap() { 255 | Response::AuthMessage { 256 | auth_message_type, 257 | auth_message, 258 | } => { 259 | self.obj().set_unlock_status(&auth_message); 260 | if let AuthMessageType::Error = auth_message_type { 261 | self.obj().shake_pin_entry(); 262 | // Lockscreen will be made sensitive at the end of PIN shake. 263 | 264 | // We can only communicate status via the unlock status label. 265 | // As soon as we PostAuthMessageResponse below, that will move to the next 266 | // auth attempt and likely a new auth message that will overwrite this one. 267 | // So we wait here a second before dismissing the message, to ensure the 268 | // user has a chance to notice the message. 269 | glib::timeout_future_seconds(1).await; 270 | } else { 271 | self.obj().set_sensitive(true); 272 | } 273 | match auth_message_type { 274 | AuthMessageType::Info | AuthMessageType::Error => { 275 | // Dismiss the message and move on to the next auth question. 276 | // TODO: This might mean that some info messages are swallowed. 277 | // Currently, we only care about fprintd's Info message, which blocks 278 | // on the response until fingerprint reader is deactivated. 279 | return Some(Request::PostAuthMessageResponse { response: None }) 280 | } 281 | _ => { 282 | // TODO: set GtkEntry input-purpose depending on AuthMessageType. 283 | } 284 | } 285 | } 286 | Response::Success => { 287 | self.obj().set_unlock_status("Success. Logging in..."); 288 | self.start_session().await.unwrap(); 289 | Shell::default().fade_out(0); 290 | // Keep this timeout in sync with fadeout animation duration in phrog.css 291 | timeout_add_once(Duration::from_millis(500), || { 292 | gtk::main_quit(); 293 | }); 294 | } 295 | Response::Error { 296 | error_type: ErrorType::AuthError, 297 | description, 298 | } => { 299 | warn!("auth error: '{}'", description); 300 | self.obj().set_unlock_status("Login failed, please try again"); 301 | self.obj().shake_pin_entry(); 302 | // Greetd IPC dox seem to suggest that this isn't necessary, but then agreety 303 | // does this, and if we don't we get a "session is already being configured" 304 | // error. So. 305 | self.cancel_session().await; 306 | // We hold here for a second, so that the login failure message has a chance 307 | // to marinate in users' gray meat. Otherwise, the caller driving this 308 | // interaction will fire off the CreateSession immediately, which will then 309 | // result in a new AuthMessage that overwrites the unlock status. 310 | glib::timeout_future_seconds(1).await; 311 | 312 | return Some(Request::CreateSession { 313 | username: self.user_session_page.get()?.username()?, 314 | }); 315 | } 316 | v => error!("unexpected response to start session: {:?}", v), 317 | } 318 | None 319 | } 320 | } 321 | 322 | impl WidgetImpl for Lockscreen {} 323 | impl ContainerImpl for Lockscreen {} 324 | impl BinImpl for Lockscreen {} 325 | impl WindowImpl for Lockscreen {} 326 | impl LockscreenImpl for Lockscreen { 327 | fn unlock_submit(&self) { 328 | glib::spawn_future_local(clone!(@weak self as this => async move { 329 | this.obj().set_unlock_status("Please wait..."); 330 | this.obj().set_sensitive(false); 331 | let mut req = Some(Request::PostAuthMessageResponse { 332 | response: Some(this.obj().pin_entry().to_string()) 333 | }); 334 | while let Some(next_req) = req.take() { 335 | req = this.greetd_interaction(next_req).await; 336 | } 337 | this.obj().clear_pin_entry(); 338 | })); 339 | } 340 | } 341 | } 342 | 343 | fn fake_greetd_interaction(req: Request) -> anyhow::Result { 344 | match req { 345 | Request::CreateSession { .. } => anyhow::Ok(Response::AuthMessage { 346 | auth_message_type: Secret, 347 | auth_message: "Password:".into(), 348 | }), 349 | Request::PostAuthMessageResponse { response } => { 350 | if response.is_none() || response.unwrap() != "0" { 351 | anyhow::Ok(Response::Error { 352 | error_type: AuthError, 353 | description: String::from("Incorrect password (hint: it's '0')"), 354 | }) 355 | } else { 356 | anyhow::Ok(Response::Success) 357 | } 358 | } 359 | _ => anyhow::Ok(Response::Success), 360 | } 361 | } 362 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use clap::Parser; 2 | use gtk::glib::*; 3 | use gtk::Application; 4 | use libphosh::prelude::*; 5 | use libphosh::WallClock; 6 | use nix::libc::SIGTERM; 7 | use phrog::shell::Shell; 8 | 9 | static G_LOG_DOMAIN: &str = "phrog"; 10 | 11 | static GLIB_LOGGER: GlibLogger = 12 | GlibLogger::new(GlibLoggerFormat::Plain, GlibLoggerDomain::CrateTarget); 13 | 14 | #[derive(Parser, Debug)] 15 | #[command(version, about, long_about = None)] 16 | struct Args { 17 | #[arg( 18 | short, 19 | long, 20 | default_value = "false", 21 | help = "Fake interactions with greetd (useful for local testing)" 22 | )] 23 | fake: bool, 24 | } 25 | 26 | fn main() -> anyhow::Result<()> { 27 | log::set_logger(&GLIB_LOGGER).unwrap(); 28 | log::set_max_level(log::LevelFilter::Debug); 29 | 30 | let args = Args::parse(); 31 | 32 | // TODO: check XDG_RUNTIME_DIR here? Angry if not set? Default? 33 | 34 | phrog::init()?; 35 | 36 | let _app = Application::builder().application_id(phrog::APP_ID).build(); 37 | 38 | let wall_clock = WallClock::new(); 39 | wall_clock.set_default(); 40 | 41 | let shell: Shell = Object::builder() 42 | .property("fake-greetd", args.fake) 43 | .property("overview-visible", false) 44 | .build(); 45 | shell.set_default(); 46 | 47 | shell.connect_ready(|_| { 48 | info!("Shell is ready"); 49 | }); 50 | 51 | unix_signal_add_local_once(SIGTERM, || { 52 | gtk::main_quit(); 53 | }); 54 | 55 | gtk::main(); 56 | 57 | Ok(()) 58 | } 59 | -------------------------------------------------------------------------------- /src/session_object.rs: -------------------------------------------------------------------------------- 1 | use gtk::glib; 2 | use gtk::glib::Object; 3 | 4 | glib::wrapper! { 5 | pub struct SessionObject(ObjectSubclass); 6 | } 7 | 8 | impl SessionObject { 9 | pub fn new( 10 | id: &str, 11 | name: &str, 12 | session_type: &str, 13 | command: &str, 14 | desktop_names: &str, 15 | ) -> Self { 16 | Object::builder() 17 | .property("id", id.to_string()) 18 | .property("name", name.to_string()) 19 | .property("session-type", session_type.to_string()) 20 | .property("command", command.to_string()) 21 | .property("desktop-names", desktop_names.to_string()) 22 | .build() 23 | } 24 | } 25 | 26 | mod imp { 27 | use gtk::glib; 28 | use gtk::glib::Properties; 29 | use gtk::prelude::*; 30 | use gtk::subclass::prelude::*; 31 | use std::cell::OnceCell; 32 | 33 | #[derive(Properties, Default)] 34 | #[properties(wrapper_type = super::SessionObject)] 35 | pub struct SessionObject { 36 | #[property(get, set)] 37 | id: OnceCell, 38 | #[property(get, set)] 39 | name: OnceCell, 40 | #[property(get, set)] 41 | session_type: OnceCell, 42 | #[property(get, set)] 43 | command: OnceCell, 44 | #[property(get, set)] 45 | desktop_names: OnceCell, 46 | } 47 | 48 | #[glib::object_subclass] 49 | impl ObjectSubclass for SessionObject { 50 | const NAME: &'static str = "PhrogSessionObject"; 51 | type Type = super::SessionObject; 52 | } 53 | 54 | #[glib::derived_properties] 55 | impl ObjectImpl for SessionObject {} 56 | } 57 | -------------------------------------------------------------------------------- /src/sessions.rs: -------------------------------------------------------------------------------- 1 | use crate::session_object::SessionObject; 2 | use glib::warn; 3 | use glob::glob; 4 | use gtk::gio::DesktopAppInfo; 5 | use gtk::prelude::*; 6 | use std::collections::HashMap; 7 | 8 | static G_LOG_DOMAIN: &str = "phrog-sessions"; 9 | 10 | pub fn sessions() -> Vec { 11 | let mut sessions = HashMap::new(); 12 | session_list( 13 | "/usr/share/wayland-sessions/*.desktop", 14 | "wayland", 15 | &mut sessions, 16 | ); 17 | session_list("/usr/share/xsessions/*.desktop", "x11", &mut sessions); 18 | sessions.values().cloned().collect() 19 | } 20 | 21 | fn session_list(path: &str, session_type: &str, sessions: &mut HashMap) { 22 | for f in match glob(path) { 23 | Err(e) => { 24 | warn!("couldn't check sessions in {}: {}", path, e); 25 | return; 26 | } 27 | Ok(iter) => iter, 28 | } 29 | .flatten() 30 | { 31 | let id = f.file_stem().unwrap().to_string_lossy().to_string(); 32 | if sessions.contains_key(&id) { 33 | continue; 34 | } 35 | 36 | let info = if let Some(info) = DesktopAppInfo::from_filename(&f) { 37 | info 38 | } else { 39 | warn!("Unable to parse session file {:?}", f); 40 | continue; 41 | }; 42 | sessions.insert( 43 | id.clone(), 44 | SessionObject::new( 45 | &id, 46 | info.name().as_ref(), 47 | session_type, 48 | &info 49 | .commandline() 50 | .map_or(String::new(), |v| v.to_string_lossy().to_string()), 51 | &info 52 | .string("DesktopNames") 53 | .map(|v| v.trim_end_matches(';').replace(';', ":")) 54 | .unwrap_or(String::new()), 55 | ), 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/shell.rs: -------------------------------------------------------------------------------- 1 | use glib::{Cast, Object}; 2 | use gtk::glib; 3 | 4 | static G_LOG_DOMAIN: &str = "phrog"; 5 | 6 | glib::wrapper! { 7 | pub struct Shell(ObjectSubclass) 8 | @extends libphosh::Shell, gtk::gio::ActionGroup; 9 | } 10 | 11 | impl Shell { 12 | #[allow(clippy::new_without_default)] 13 | pub fn new() -> Self { 14 | Object::builder().build() 15 | } 16 | } 17 | 18 | impl Default for Shell { 19 | fn default() -> Self { 20 | libphosh::Shell::default().downcast::().unwrap() 21 | } 22 | } 23 | 24 | mod imp { 25 | use super::G_LOG_DOMAIN; 26 | use crate::lockscreen::Lockscreen; 27 | use crate::session_object::SessionObject; 28 | use crate::sessions; 29 | use glib::{clone, spawn_future_local, warn}; 30 | use gtk::gio::Settings; 31 | use gtk::gio::{spawn_blocking, ListStore}; 32 | use gtk::glib::{Properties, Type}; 33 | use gtk::prelude::StaticType; 34 | use gtk::prelude::*; 35 | use gtk::subclass::prelude::*; 36 | use gtk::subclass::prelude::{ObjectImpl, ObjectSubclass}; 37 | use gtk::{gdk, glib, CssProvider, StyleContext}; 38 | use libphosh::subclass::shell::ShellImpl; 39 | use std::cell::RefCell; 40 | use std::cell::{Cell, OnceCell}; 41 | use std::process::Command; 42 | use libphosh::prelude::ShellExt; 43 | 44 | #[derive(Default, Properties)] 45 | #[properties(wrapper_type = super::Shell)] 46 | pub struct Shell { 47 | #[property(get, set)] 48 | fake_greetd: Cell, 49 | 50 | #[property(get, set)] 51 | pub sessions: RefCell>, 52 | 53 | provider: Cell, 54 | pub dbus_connection: OnceCell, 55 | } 56 | 57 | #[glib::object_subclass] 58 | impl ObjectSubclass for Shell { 59 | const NAME: &'static str = "PhrogShell"; 60 | type Type = super::Shell; 61 | type ParentType = libphosh::Shell; 62 | } 63 | 64 | #[glib::derived_properties] 65 | impl ObjectImpl for Shell { 66 | fn constructed(&self) { 67 | let system_dbus = async_global_executor::block_on(zbus::Connection::system()).unwrap(); 68 | self.dbus_connection.set(system_dbus).unwrap(); 69 | 70 | self.parent_constructed(); 71 | 72 | if self.obj().sessions().is_none() { 73 | let sessions_store = ListStore::new::(); 74 | sessions_store.extend_from_slice(&sessions::sessions()); 75 | self.obj().set_sessions(sessions_store); 76 | } 77 | 78 | let provider = CssProvider::new(); 79 | provider.load_from_resource("/mobi/phosh/phrog/phrog.css"); 80 | StyleContext::add_provider_for_screen( 81 | &gdk::Screen::default().unwrap(), 82 | &provider, 83 | // Slightly hacky, we want to be above phosh to override some stuff 84 | gtk::STYLE_PROVIDER_PRIORITY_APPLICATION + 5, 85 | ); 86 | self.provider.set(provider); 87 | 88 | let settings = Settings::new(crate::APP_ID); 89 | 90 | let shell = self.to_owned(); 91 | glib::idle_add_local_once(move || { 92 | let first_run = settings.string("first-run"); 93 | if !first_run.is_empty() { 94 | spawn_future_local(clone!(@weak shell as this => async move { 95 | if let Err(err) = spawn_blocking(|| { 96 | Command::new(first_run).spawn().and_then(|mut child| child.wait()) 97 | }).await 98 | { 99 | warn!("Failed to execute first-run app: {:?}", err); 100 | } 101 | this.obj().set_locked(true); 102 | })); 103 | } else { 104 | shell.obj().set_locked(true); 105 | } 106 | }); 107 | } 108 | } 109 | 110 | impl ShellImpl for Shell { 111 | fn get_lockscreen_type(&self) -> Type { 112 | Lockscreen::static_type() 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/supervised_child.rs: -------------------------------------------------------------------------------- 1 | use glib::{error, info, warn}; 2 | use nix::sys::signal::SIGTERM; 3 | use nix::unistd::Pid; 4 | use std::process::Child; 5 | use std::thread::sleep; 6 | use std::time::{Duration, Instant}; 7 | 8 | static G_LOG_DOMAIN: &str = "phrog-supervised-child"; 9 | 10 | pub struct SupervisedChild { 11 | pub child: Child, 12 | name: String, 13 | } 14 | 15 | impl SupervisedChild { 16 | pub fn new(name: &str, child: Child) -> Self { 17 | Self { 18 | child, 19 | name: name.to_string(), 20 | } 21 | } 22 | 23 | pub fn stop(&mut self) { 24 | let pid = Pid::from_raw(self.child.id() as _); 25 | let label = format!("{} ({})", self.name, pid); 26 | info!("Stopping process {} with SIGTERM", label); 27 | // First try to SIGTERM, allowing maximum of 5 seconds for graceful exit. 28 | match nix::sys::signal::kill(pid, SIGTERM) { 29 | Ok(_) => { 30 | let start = Instant::now(); 31 | while start.elapsed() < Duration::from_secs(5) { 32 | if self.child.try_wait().is_ok() { 33 | return; 34 | } 35 | sleep(Duration::from_secs(1)); 36 | } 37 | warn!("Process {} ignored SIGTERM. Killing...", label); 38 | } 39 | Err(err) => warn!("Failed to SIGTERM process {}: {}", label, err), 40 | } 41 | 42 | if let Err(err) = self.child.kill() { 43 | error!("Failed to kill process {}: {}", label, err); 44 | } 45 | } 46 | } 47 | 48 | impl Drop for SupervisedChild { 49 | fn drop(&mut self) { 50 | self.stop(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/user.rs: -------------------------------------------------------------------------------- 1 | use crate::dbus::user::UserProxy; 2 | use futures_util::StreamExt; 3 | use futures_util::select; 4 | use glib::warn; 5 | use gtk::gdk_pixbuf::Pixbuf; 6 | use gtk::gio::Cancellable; 7 | use gtk::glib::{Object, clone, spawn_future_local}; 8 | use gtk::prelude::{FileExt, ObjectExt}; 9 | use gtk::{gio, glib}; 10 | use zbus::zvariant::{ObjectPath, OwnedObjectPath}; 11 | 12 | static G_LOG_DOMAIN: &str = "phrog-user"; 13 | 14 | glib::wrapper! { 15 | pub struct User(ObjectSubclass); 16 | } 17 | 18 | impl User { 19 | pub fn new(conn: zbus::Connection, path: ObjectPath) -> Self { 20 | let obj: Self = Object::builder().property("path", path.as_str()).build(); 21 | 22 | let path = OwnedObjectPath::from(path); 23 | spawn_future_local(clone!(@weak obj => async move { 24 | let user_proxy = if let Ok(proxy) = UserProxy::builder(&conn) 25 | .path(&path) 26 | .unwrap_or_else(|_| panic!("failed to construct UserProxy for {}", path)) 27 | .build() 28 | .await 29 | { 30 | proxy 31 | } else { 32 | warn!("failed to construct UserProxy for {}", path); 33 | return; 34 | }; 35 | 36 | if let Ok(v) = user_proxy.user_name().await { 37 | obj.set_username(v); 38 | } 39 | if let Ok(v) = user_proxy.real_name().await { 40 | obj.set_name(v); 41 | } 42 | if let Ok(v) = user_proxy.icon_file().await { 43 | obj.set_icon_file(v); 44 | } 45 | 46 | obj.emit_by_name::<()>("loaded", &[]); 47 | 48 | let mut name_stream = user_proxy.receive_real_name_changed().await.fuse(); 49 | let mut username_stream = user_proxy.receive_user_name_changed().await.fuse(); 50 | let mut icon_stream = user_proxy.receive_icon_file_changed().await.fuse(); 51 | 52 | loop { 53 | select! { 54 | name = name_stream.next() => if let Some(name) = name { 55 | if let Ok(v) = name.get().await { 56 | obj.set_name(v); 57 | } 58 | }, 59 | username = username_stream.next() => if let Some(username) = username { 60 | if let Ok(v) = username.get().await { 61 | obj.set_username(v); 62 | } 63 | }, 64 | icon = icon_stream.next() => if let Some(icon) = icon { 65 | if let Ok(v) = icon.get().await { 66 | obj.set_icon_file(v); 67 | } 68 | }, 69 | } 70 | } 71 | })); 72 | obj 73 | } 74 | 75 | pub fn load_pixbuf(&self, f: &gio::File) { 76 | let c = Cancellable::current(); 77 | if let Ok(input) = f.read(c.as_ref()) { 78 | if let Ok(pixbuf) = Pixbuf::from_stream_at_scale(&input, 32, 32, true, c.as_ref()) { 79 | self.set_icon_pixbuf(pixbuf); 80 | } 81 | } 82 | } 83 | } 84 | 85 | mod imp { 86 | use super::G_LOG_DOMAIN; 87 | use glib::warn; 88 | use gtk::gdk_pixbuf::Pixbuf; 89 | use gtk::gio::{Cancellable, FileMonitorFlags}; 90 | use gtk::glib::subclass::Signal; 91 | use gtk::glib::{Properties, clone}; 92 | use gtk::prelude::*; 93 | use gtk::subclass::prelude::*; 94 | use gtk::{gio, glib}; 95 | use std::cell::RefCell; 96 | use std::sync::OnceLock; 97 | 98 | #[derive(Properties, Default)] 99 | #[properties(wrapper_type = super::User)] 100 | pub struct User { 101 | #[property(get, set)] 102 | path: RefCell, 103 | #[property(get, set)] 104 | name: RefCell, 105 | #[property(get, set)] 106 | username: RefCell, 107 | #[property(get, set)] 108 | icon_file: RefCell>, 109 | #[property(get, set)] 110 | icon_monitor: RefCell>, 111 | #[property(get, set)] 112 | icon_pixbuf: RefCell>, 113 | } 114 | 115 | #[glib::object_subclass] 116 | impl ObjectSubclass for User { 117 | const NAME: &'static str = "PhrogUser"; 118 | type Type = super::User; 119 | } 120 | 121 | #[glib::derived_properties] 122 | impl ObjectImpl for User { 123 | fn constructed(&self) { 124 | self.parent_constructed(); 125 | 126 | self.obj().connect_icon_file_notify(move |user| { 127 | if let Some(path) = user.icon_file() { 128 | let file = gio::File::for_path(&path); 129 | user.load_pixbuf(&file); 130 | 131 | let c = Cancellable::current(); 132 | match file.monitor(FileMonitorFlags::empty(), c.as_ref()) { 133 | Ok(monitor) => user.set_icon_monitor(monitor.clone()), 134 | Err(err) => { 135 | warn!("error starting file monitor on {}: {}", path, err) 136 | } 137 | } 138 | } 139 | }); 140 | self.obj().connect_icon_monitor_notify(move |user| { 141 | if let Some(monitor) = user.icon_monitor() { 142 | monitor.connect_changed(clone!(@weak user => move |_, f, _, _| { 143 | user.load_pixbuf(f); 144 | })); 145 | } 146 | }); 147 | } 148 | 149 | fn signals() -> &'static [Signal] { 150 | static SIGNALS: OnceLock> = OnceLock::new(); 151 | SIGNALS.get_or_init(|| vec![Signal::builder("loaded").build()]) 152 | } 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/user_session_page.rs: -------------------------------------------------------------------------------- 1 | use crate::session_object::SessionObject; 2 | use gtk::glib; 3 | use gtk::glib::{Cast, CastNone, Object}; 4 | use gtk::prelude::*; 5 | use gtk::subclass::prelude::ObjectSubclassIsExt; 6 | use libhandy::prelude::{ActionRowExt, ComboRowExt}; 7 | use libhandy::ActionRow; 8 | use crate::shell::Shell; 9 | 10 | glib::wrapper! { 11 | pub struct UserSessionPage(ObjectSubclass) 12 | @extends gtk::Widget, gtk::Box; 13 | } 14 | 15 | impl Default for UserSessionPage { 16 | fn default() -> Self { 17 | Self::new() 18 | } 19 | } 20 | 21 | impl UserSessionPage { 22 | pub fn new() -> Self { 23 | Object::builder().build() 24 | } 25 | 26 | pub fn session(&self) -> SessionObject { 27 | let shell = Shell::default(); 28 | let session_idx = self.imp().row_sessions.selected_index() as u32; 29 | shell.sessions().unwrap() 30 | .item(session_idx) 31 | .clone() 32 | .and_downcast::() 33 | .unwrap() 34 | } 35 | 36 | pub fn username(&self) -> Option { 37 | self.imp() 38 | .box_users 39 | .selected_row() 40 | .and_then(|row| row.downcast_ref::().unwrap().subtitle()) 41 | .map(|str| str.to_string()) 42 | } 43 | } 44 | 45 | mod imp { 46 | use crate::dbus::accounts::AccountsProxy; 47 | use crate::session_object::SessionObject; 48 | use crate::shell::Shell; 49 | use crate::user::User; 50 | use crate::APP_ID; 51 | use futures_util::select; 52 | use futures_util::StreamExt; 53 | use glib::subclass::InitializingObject; 54 | use gtk::gio::{ListStore, Settings}; 55 | use gtk::glib::subclass::Signal; 56 | use gtk::glib::{clone, closure_local}; 57 | use gtk::prelude::*; 58 | use gtk::subclass::prelude::*; 59 | use gtk::{glib, CompositeTemplate, Image, ListBox, ListBoxRow}; 60 | use libhandy::prelude::*; 61 | use libhandy::ActionRow; 62 | use std::cell::{Cell, OnceCell}; 63 | use std::sync::OnceLock; 64 | use glib::{GString, Properties}; 65 | 66 | #[derive(CompositeTemplate, Default, Properties)] 67 | #[properties(wrapper_type = super::UserSessionPage)] 68 | #[template(resource = "/mobi/phosh/phrog/lockscreen-user-session.ui")] 69 | pub struct UserSessionPage { 70 | #[template_child] 71 | pub box_users: TemplateChild, 72 | 73 | #[template_child] 74 | pub row_sessions: TemplateChild, 75 | 76 | users: OnceCell, 77 | 78 | #[property(get, set)] 79 | ready: Cell, 80 | } 81 | 82 | #[glib::object_subclass] 83 | impl ObjectSubclass for UserSessionPage { 84 | const NAME: &'static str = "PhrogUserSessionPage"; 85 | type Type = super::UserSessionPage; 86 | type ParentType = gtk::Box; 87 | 88 | fn class_init(klass: &mut Self::Class) { 89 | Self::bind_template(klass); 90 | klass.set_css_name("phrog-user-session-page"); 91 | } 92 | 93 | fn instance_init(obj: &InitializingObject) { 94 | obj.init_template(); 95 | } 96 | } 97 | 98 | #[glib::derived_properties] 99 | impl ObjectImpl for UserSessionPage { 100 | fn constructed(&self) { 101 | self.parent_constructed(); 102 | 103 | let settings = Settings::new(APP_ID); 104 | let shell = Shell::default(); 105 | let conn = shell.imp().dbus_connection.clone().into_inner().unwrap(); 106 | 107 | self.box_users 108 | .connect_row_activated(clone!(@weak self as this => move |_, _| { 109 | this.obj().emit_by_name::<()>("login", &[]); 110 | })); 111 | 112 | self.row_sessions.bind_name_model( 113 | Some(shell.sessions().as_ref().unwrap()), 114 | Some(Box::new(|v| { 115 | v.downcast_ref::().unwrap().name() 116 | })), 117 | ); 118 | let mut last_session = settings.string("last-session"); 119 | 120 | if last_session.is_empty() { 121 | // No preference for a session exists, so let's default to Phosh. 122 | last_session = GString::from("phosh"); 123 | } 124 | 125 | for (idx, session) in shell.sessions() 126 | .as_ref().unwrap() 127 | .iter::() 128 | .flatten() 129 | .enumerate() 130 | { 131 | if session.id() == last_session { 132 | self.row_sessions.set_selected_index(idx as _); 133 | break; 134 | } 135 | } 136 | 137 | let users = ListStore::new::(); 138 | let last_user = settings.string("last-user"); 139 | 140 | self.box_users.bind_model(Some(&users), clone!(@weak self as this, @strong last_user => @default-panic, move |v| { 141 | let user = v.downcast_ref::().unwrap(); 142 | let row = ActionRow::builder().activatable(true).build(); 143 | user.bind_property("username", &row, "subtitle").build(); 144 | user.bind_property("name", &row, "title").build(); 145 | let image = Image::new(); 146 | row.add_prefix(&image); 147 | image.show(); 148 | user.bind_property("icon-pixbuf", &image, "pixbuf").build(); 149 | 150 | user.connect_closure("loaded", false, closure_local!(@strong this, @strong last_user, @strong row => move |obj: glib::Object| { 151 | if let Ok(user) = obj.downcast::() { 152 | if user.username() == last_user { 153 | this.box_users.select_row(Some(&row)); 154 | } 155 | } 156 | })); 157 | 158 | row.upcast() 159 | })); 160 | 161 | self.users.set(users.clone()).unwrap(); 162 | glib::spawn_future_local(clone!(@weak self as this, @strong last_user => async move { 163 | let accounts_proxy = AccountsProxy::new(&conn).await.unwrap(); 164 | 165 | for path in accounts_proxy.list_cached_users().await.unwrap() { 166 | users.append(&User::new(conn.clone(), path.into())); 167 | } 168 | 169 | // The initial user list has been populated. Select the first item in the list to 170 | // ensure something is selected. 171 | // This will be overridden by the "loaded" signal handler, if the appropriate user 172 | // matching the last-user setting was discovered. 173 | this.box_users.select_row( 174 | this 175 | .box_users 176 | .children() 177 | .first() 178 | .and_then(|v| v.downcast_ref::()), 179 | ); 180 | 181 | this.obj().set_ready(true); 182 | 183 | let mut added_stream = accounts_proxy.receive_user_added().await.unwrap(); 184 | let mut deleted_stream = accounts_proxy.receive_user_deleted().await.unwrap(); 185 | 186 | loop { 187 | select! { 188 | added = added_stream.next() => if let Some(added) = added { 189 | if let Some(path) = added.args().ok().map(|v| v.user) { 190 | users.append(&User::new(conn.clone(), path)); 191 | } 192 | }, 193 | deleted = deleted_stream.next() => if let Some(deleted) = deleted { 194 | if let Some(path) = deleted.args().ok().map(|v| v.user) { 195 | for (idx, user) in users.iter::().flatten().enumerate() { 196 | if user.path() == path.as_str() { 197 | users.remove(idx as _); 198 | break; 199 | } 200 | } 201 | } 202 | }, 203 | } 204 | } 205 | })); 206 | } 207 | 208 | fn signals() -> &'static [Signal] { 209 | static SIGNALS: OnceLock> = OnceLock::new(); 210 | SIGNALS.get_or_init(|| { 211 | vec![ 212 | Signal::builder("login").build(), 213 | ] 214 | }) 215 | } 216 | } 217 | 218 | impl WidgetImpl for UserSessionPage {} 219 | impl ContainerImpl for UserSessionPage {} 220 | impl BoxImpl for UserSessionPage {} 221 | } 222 | -------------------------------------------------------------------------------- /tests/accent_colours.rs: -------------------------------------------------------------------------------- 1 | pub mod common; 2 | 3 | use gtk::glib; 4 | use libphosh::prelude::ShellExt; 5 | 6 | use common::*; 7 | use gtk::prelude::*; 8 | use std::time::Duration; 9 | 10 | #[test] 11 | fn test_accent_colours() { 12 | let mut test = test_init(None); 13 | 14 | test.shell.set_locked(true); 15 | 16 | let ready_rx = test.ready_rx.clone(); 17 | let if_settings = test.if_settings.clone(); 18 | test.start("accent-colours", glib::spawn_future_local(async move { 19 | let (_, _) = ready_rx.recv().await.unwrap(); 20 | glib::timeout_future(Duration::from_millis(1500)).await; 21 | 22 | for color in ["red", "slate", "pink", "teal", "red", "purple", "blue"] { 23 | if_settings.set_string("accent-color", color).unwrap(); 24 | glib::timeout_future(Duration::from_millis(500)).await; 25 | } 26 | 27 | fade_quit(); 28 | })); 29 | } 30 | -------------------------------------------------------------------------------- /tests/common/dbus.rs: -------------------------------------------------------------------------------- 1 | use crate::common::SupervisedChild; 2 | use anyhow::Context; 3 | use std::path::{Path, PathBuf}; 4 | use std::process::Stdio; 5 | use std::time::{Duration, Instant}; 6 | use zbus::zvariant::ObjectPath; 7 | 8 | pub fn dbus_daemon(kind: &str, tmpdir: &Path) -> SupervisedChild { 9 | let config_path = tmpdir.join(format!("{}-dbus.xml", kind)); 10 | let sock_path = tmpdir.join(format!("{}.sock", kind)); 11 | let dbus_path = format!("unix:path={}", sock_path.display()); 12 | std::fs::write( 13 | &config_path, 14 | format!( 15 | r#" 16 | 18 | 19 | {} 20 | 21 | {} 22 | 23 | 24 | 25 | 26 | 27 | 28 | "#, 29 | kind, dbus_path 30 | ), 31 | ) 32 | .expect("failed to write dbus config"); 33 | 34 | std::env::set_var( 35 | format!("DBUS_{}_BUS_ADDRESS", kind.to_uppercase()), 36 | dbus_path, 37 | ); 38 | let child = std::process::Command::new("dbus-daemon") 39 | .arg(format!("--config-file={}", config_path.to_str().unwrap())) 40 | .stdout(Stdio::null()) 41 | .stdin(Stdio::null()) 42 | .stderr(Stdio::null()) 43 | .spawn() 44 | .expect("failed to launch dbus-daemon"); 45 | 46 | let start = Instant::now(); 47 | while !sock_path.exists() { 48 | if start.elapsed() > Duration::from_secs(5) { 49 | panic!("dbus-daemon failed to launch"); 50 | } 51 | std::thread::sleep(Duration::from_millis(50)); 52 | } 53 | 54 | SupervisedChild::new("dbus-daemon", child) 55 | } 56 | 57 | struct AccountsFixture { 58 | num_users: Option, 59 | } 60 | struct UserFixture { 61 | name: String, 62 | username: String, 63 | icon_file: String, 64 | } 65 | 66 | #[zbus::interface(name = "org.freedesktop.Accounts")] 67 | impl AccountsFixture { 68 | async fn list_cached_users(&self) -> Vec { 69 | let mut users = vec![ 70 | ObjectPath::from_static_str_unchecked("/org/freedesktop/Accounts/phoshi"), 71 | ObjectPath::from_static_str_unchecked("/org/freedesktop/Accounts/agx"), 72 | ObjectPath::from_static_str_unchecked("/org/freedesktop/Accounts/sam"), 73 | ]; 74 | if let Some(num_users) = self.num_users { 75 | users.truncate(num_users as _); 76 | } 77 | users 78 | } 79 | } 80 | 81 | impl UserFixture { 82 | fn new(name: &str, username: &str, icon_file: &str) -> Self { 83 | Self { 84 | name: name.into(), 85 | username: username.into(), 86 | icon_file: PathBuf::from(env!("CARGO_MANIFEST_DIR")) 87 | .join("tests/fixtures/") 88 | .join(icon_file) 89 | .display() 90 | .to_string(), 91 | } 92 | } 93 | } 94 | 95 | #[zbus::interface(name = "org.freedesktop.Accounts.User")] 96 | impl UserFixture { 97 | #[zbus(property)] 98 | async fn real_name(&self) -> &str { 99 | &self.name 100 | } 101 | #[zbus(property)] 102 | async fn user_name(&self) -> &str { 103 | &self.username 104 | } 105 | #[zbus(property)] 106 | async fn icon_file(&self) -> &str { 107 | &self.icon_file 108 | } 109 | } 110 | 111 | pub async fn run_accounts_fixture( 112 | connection: zbus::Connection, 113 | num_users: Option, 114 | ) -> anyhow::Result<()> { 115 | connection 116 | .object_server() 117 | .at("/org/freedesktop/Accounts", AccountsFixture { num_users }) 118 | .await 119 | .context("failed to serve org.freedesktop.Accounts")?; 120 | connection 121 | .object_server() 122 | .at( 123 | "/org/freedesktop/Accounts/agx", 124 | UserFixture::new("Guido", "agx", "guido.png"), 125 | ) 126 | .await 127 | .context("failed to serve org.freedesktop.Accounts.User")?; 128 | connection 129 | .object_server() 130 | .at( 131 | "/org/freedesktop/Accounts/phoshi", 132 | UserFixture::new("Phoshi", "phoshi", "phoshi.png"), 133 | ) 134 | .await 135 | .context("failed to serve org.freedesktop.Accounts.User")?; 136 | connection 137 | .object_server() 138 | .at( 139 | "/org/freedesktop/Accounts/sam", 140 | UserFixture::new("Sam", "samcday", "samcday.jpeg"), 141 | ) 142 | .await 143 | .context("failed to serve org.freedesktop.Accounts.User")?; 144 | connection 145 | .request_name("org.freedesktop.Accounts") 146 | .await 147 | .context("failed to request name")?; 148 | Ok(()) 149 | } 150 | -------------------------------------------------------------------------------- /tests/common/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dbus; 2 | pub mod virtual_keyboard; 3 | pub mod virtual_pointer; 4 | 5 | use crate::common::virtual_keyboard::VirtualKeyboard; 6 | use async_channel::Receiver; 7 | use glib::{JoinHandle, Object, g_critical, spawn_future_local}; 8 | use greetd_ipc::AuthMessageType::Secret; 9 | use greetd_ipc::codec::SyncCodec; 10 | use greetd_ipc::{Request, Response}; 11 | use gtk::gio::{ListStore, Settings}; 12 | use gtk::glib::{clone, timeout_add_once}; 13 | use gtk::prelude::*; 14 | use gtk::{Button, Grid, Revealer}; 15 | use libhandy::Carousel; 16 | use libphosh::WallClock; 17 | use libphosh::prelude::ShellExt; 18 | use libphosh::prelude::WallClockExt; 19 | use phrog::lockscreen::Lockscreen; 20 | use phrog::session_object::SessionObject; 21 | use phrog::shell::Shell; 22 | use phrog::supervised_child::SupervisedChild; 23 | use std::env::temp_dir; 24 | use std::os::unix::net::UnixListener; 25 | use std::path::PathBuf; 26 | use std::process::Stdio; 27 | use std::sync::Arc; 28 | use std::sync::atomic::{AtomicBool, Ordering}; 29 | use std::time::{Duration, SystemTime, UNIX_EPOCH}; 30 | use tempfile::TempDir; 31 | pub use virtual_pointer::VirtualPointer; 32 | 33 | #[allow(dead_code)] 34 | pub struct Test { 35 | pub session_dbus_conn: zbus::Connection, 36 | system_dbus_conn: zbus::Connection, 37 | pub if_settings: Settings, 38 | pub logged_in: Arc, 39 | pub ready_called: Arc, 40 | pub ready_rx: Receiver<(VirtualPointer, VirtualKeyboard)>, 41 | recording: Option, 42 | pub shell: Shell, 43 | system_dbus: SupervisedChild, 44 | session_dbus: SupervisedChild, 45 | tmp: TempDir, 46 | wall_clock: WallClock, 47 | } 48 | 49 | impl Test { 50 | pub fn start(&mut self, name: &str, jh: JoinHandle<()>) { 51 | if let Ok(base_path) = std::env::var("RECORD_TESTS") { 52 | if let Ok(child) = std::process::Command::new("wf-recorder") 53 | .arg("-f") 54 | .arg(PathBuf::from(base_path).join(format!("{}.mp4", name))) 55 | .stdout(Stdio::null()) 56 | .stdin(Stdio::null()) 57 | .stderr(Stdio::null()) 58 | .spawn() 59 | { 60 | self.recording = Some(SupervisedChild::new("wf-recorder", child)); 61 | } 62 | } 63 | 64 | let timed_out = Arc::new(AtomicBool::new(false)); 65 | timeout_add_once( 66 | Duration::from_secs(60), 67 | clone!(@strong timed_out => move || { 68 | timed_out.store(true, Ordering::SeqCst); 69 | g_critical!("phrog", "Test timed out!"); 70 | gtk::main_quit(); 71 | }), 72 | ); 73 | 74 | let failed = Arc::new(AtomicBool::new(false)); 75 | spawn_future_local(clone!(@strong failed => async move { 76 | if jh.await.is_err() { 77 | g_critical!("phrog", "Test failed!"); 78 | gtk::main_quit(); 79 | failed.store(true, Ordering::SeqCst); 80 | } 81 | })); 82 | 83 | gtk::main(); 84 | 85 | assert!(!timed_out.load(Ordering::SeqCst)); 86 | assert!(!failed.load(Ordering::SeqCst)); 87 | assert!(self.ready_called.load(Ordering::Relaxed)); 88 | } 89 | } 90 | 91 | #[derive(Default)] 92 | pub struct TestOptions { 93 | pub num_users: Option, 94 | pub sessions: Option>, 95 | pub last_user: Option, 96 | pub last_session: Option, 97 | pub first_run: Option, 98 | } 99 | 100 | pub fn test_init(options: Option) -> Test { 101 | std::env::set_var("GSETTINGS_BACKEND", "memory"); 102 | let tmp = tempfile::tempdir().unwrap(); 103 | let system_dbus = dbus::dbus_daemon("system", tmp.path()); 104 | let session_dbus = dbus::dbus_daemon("session", tmp.path()); 105 | 106 | phrog::init().unwrap(); 107 | 108 | if let Some(ref options) = options { 109 | let phrog_settings = Settings::new("mobi.phosh.phrog"); 110 | phrog_settings 111 | .set_string( 112 | "last-user", 113 | &options.last_user.clone().unwrap_or(String::new()), 114 | ) 115 | .unwrap(); 116 | phrog_settings 117 | .set_string( 118 | "last-session", 119 | &options.last_session.clone().unwrap_or(String::new()), 120 | ) 121 | .unwrap(); 122 | phrog_settings 123 | .set_string( 124 | "first-run", 125 | &options.first_run.clone().unwrap_or(String::new()), 126 | ) 127 | .unwrap(); 128 | } 129 | 130 | let if_settings = Settings::new("org.gnome.desktop.interface"); 131 | // use a more appropriate (moar froggy) accent color 132 | if_settings.set_string("accent-color", "green").unwrap(); 133 | 134 | let num_users = options.as_ref().and_then(|opts| opts.num_users); 135 | let (system_dbus_conn, session_dbus_conn) = async_global_executor::block_on(async move { 136 | let system = zbus::Connection::system() 137 | .await 138 | .expect("failed to connect to system bus"); 139 | 140 | dbus::run_accounts_fixture(system.clone(), num_users) 141 | .await 142 | .unwrap(); 143 | 144 | let session = zbus::Connection::session() 145 | .await 146 | .expect("failed to connect to session bus"); 147 | 148 | (system, session) 149 | }); 150 | 151 | let logged_in = Arc::new(AtomicBool::new(false)); 152 | fake_greetd(&logged_in); 153 | 154 | let mut shell_builder = Object::builder(); 155 | 156 | let sessions_store = ListStore::new::(); 157 | sessions_store.extend_from_slice(&options.and_then(|opts| opts.sessions.clone()).unwrap_or( 158 | vec![ 159 | SessionObject::new("gnome", "GNOME", "", "", ""), 160 | SessionObject::new("phosh", "Phosh", "", "", ""), 161 | ], 162 | )); 163 | shell_builder = shell_builder.property("sessions", sessions_store); 164 | 165 | let wall_clock = WallClock::new(); 166 | wall_clock.set_default(); 167 | let shell: Shell = shell_builder.build(); 168 | shell.set_default(); 169 | 170 | let ready_called = Arc::new(AtomicBool::new(false)); 171 | let ready_called2 = ready_called.clone(); 172 | let (ready_tx, ready_rx) = async_channel::bounded(1); 173 | shell.connect_ready(clone!(@strong ready_called2 => move |shell| { 174 | ready_called2.store(true, Ordering::Relaxed); 175 | 176 | let (_, _, width, height) = shell.usable_area(); 177 | let vp = VirtualPointer::new(wayland_client::Connection::connect_to_env().unwrap(), width as _, height as _); 178 | let kb = VirtualKeyboard::new(wayland_client::Connection::connect_to_env().unwrap()); 179 | ready_tx.send_blocking((vp, kb)).expect("notify ready failed"); 180 | })); 181 | 182 | Test { 183 | system_dbus_conn, 184 | session_dbus_conn, 185 | if_settings, 186 | logged_in, 187 | ready_called, 188 | ready_rx, 189 | recording: None, 190 | shell, 191 | system_dbus, 192 | session_dbus, 193 | tmp, 194 | wall_clock, 195 | } 196 | } 197 | 198 | pub fn fake_greetd(logged_in: &Arc) { 199 | let path = temp_dir().join(format!( 200 | ".phrog-test-greetd-{}.sock", 201 | SystemTime::now() 202 | .duration_since(UNIX_EPOCH) 203 | .unwrap() 204 | .as_secs() 205 | )); 206 | std::env::set_var("GREETD_SOCK", &path); 207 | std::thread::spawn(clone!(@strong logged_in => move || { 208 | let listener = UnixListener::bind(&path).unwrap(); 209 | loop { 210 | let (mut stream, _addr) = listener 211 | .accept() 212 | .expect("failed to accept greetd connection"); 213 | 214 | match Request::read_from(&mut stream).unwrap() { 215 | Request::CreateSession { .. } => Response::AuthMessage { 216 | auth_message_type: Secret, 217 | auth_message: "Password:".to_string(), 218 | } 219 | .write_to(&mut stream) 220 | .unwrap(), 221 | req => panic!("wrong request: {:?}", req), 222 | } 223 | 224 | match Request::read_from(&mut stream).unwrap() { 225 | Request::PostAuthMessageResponse { 226 | response: Some(password), 227 | } => { 228 | assert_eq!(password, "0451"); 229 | Response::Success.write_to(&mut stream).unwrap(); 230 | } 231 | req => panic!("wrong request: {:?}", req), 232 | } 233 | 234 | match Request::read_from(&mut stream).unwrap() { 235 | Request::StartSession { .. } => { 236 | Response::Success.write_to(&mut stream).unwrap(); 237 | logged_in.store(true, Ordering::Relaxed); 238 | } 239 | req => panic!("wrong request: {:?}", req), 240 | } 241 | } 242 | })); 243 | } 244 | 245 | pub fn get_lockscreen_bits(lockscreen: &mut Lockscreen) -> (Grid, Button) { 246 | // Here we do some yucky traversal of the UI structure in phosh/src/ui/lockscreen.ui in the 247 | // name of "art". We drill through to find the keypad, and then pick out the individual 248 | // digits + submit button to drive the UI interactions entirely via mouse. 249 | // This looks nice for the video recording. 250 | let carousel = lockscreen.child().unwrap().downcast::().unwrap(); 251 | 252 | let keypad_page = carousel 253 | .children() 254 | .get(2) 255 | .unwrap() 256 | .clone() 257 | .downcast::() 258 | .unwrap(); 259 | let keypad_revealer = keypad_page 260 | .children() 261 | .get(2) 262 | .unwrap() 263 | .clone() 264 | .downcast::() 265 | .unwrap(); 266 | let keypad = keypad_revealer.child().unwrap().downcast::().unwrap(); 267 | let submit_box = keypad_page 268 | .children() 269 | .get(3) 270 | .unwrap() 271 | .clone() 272 | .downcast::() 273 | .unwrap(); 274 | let submit_btn = submit_box 275 | .children() 276 | .first() 277 | .unwrap() 278 | .clone() 279 | .downcast::