Skip to content

Commit

Permalink
treewide: Packaging overhaul
Browse files Browse the repository at this point in the history
Booting a fully-functional phrog greeter session under greetd is a
little complicated. The right way to do it varies by distribution.

This commit introduces prescriptive configuration for Alpine and Fedora.
Eventually Debian will be a first-class citizen here too (when I
finally wrap my head around its packaging/tooling).

Since Alpine already allows the greetd config file to be specified in
/etc/conf.d/greetd, we make use of that.

On Fedora, a distinct phrog.service unit is introduced which conflicts
with greetd's default greetd.service. For now, the only difference this
service has to the default is a --config arg. Later, when we support
Plymouth flicker-free boot, it will also Conflict=plymouth-quit.service
to take over that process (just like gdm.service does).

This commit also introduces the use of gnome-session to run the phrog
shell. This ensures auxiliary services like the gsd-* daemons and an OSK
are present.

Since gnome-session is in place, we also use that to spawn phrog itself.
A mobi.phosh.Phrog.desktop file is now shipped for that.

The phrog-session wrapper example Guido introduced recently is moved to
data/ and shipped in Alpine and Fedora. Since this script is only
intended to be referenced by greetd's default_session.command config, it
goes in /usr/libexec rather than in the PATH. As such the --help and
--version are excised, and the script is made as minimal as possible.

The README is updated and cleaned up a bit to reflect this work.

Signed-off-by: Sam Day <me@samcday.com>
  • Loading branch information
samcday committed Feb 4, 2025
1 parent 90a862d commit 7a3199d
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 71 deletions.
6 changes: 6 additions & 0 deletions APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ build() {

package() {
install -Dm644 data/mobi.phosh.phrog.gschema.xml -t "$pkgdir"/usr/share/glib-2.0/schemas/
install -Dm644 data/phrog.session -t "$pkgdir"/usr/share/gnome-session/sessions/
install -Dm644 data/mobi.phosh.Phrog.desktop -t "$pkgdir"/usr/share/applications/
install -Dm644 dist/alpine/greetd-config.toml -t "$pkgdir"/etc/phrog/
install -d "$pkgdir"/usr/share/phrog/autostart
install -d "$pkgdir"/etc/phrog/autostart
install -Dm755 target/release/phrog -t "$pkgdir"/usr/bin/
install -Dm755 data/phrog-greetd-session -t "$pkgdir"/usr/libexec/
}

check() {
Expand Down
47 changes: 32 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,37 @@ It is the spiritual successor of [phog][].

<br clear="right"/>

## Installation
## Usage

* Alpine (v3.21+): `apk add greetd-phrog`
* Fedora ([COPR][]): `sudo dnf copr enable samcday/phrog && sudo dnf install phrog`
* Other: you must build from source, see the Development section below.
### Alpine/postmarketOS

## Running
```
sudo apk add greetd-phrog
`phrog` is a [greetd][] "greeter". To use it, make sure your `/etc/greetd/config.toml` looks like this:
# Configure greetd to run phrog:
cat <<HERE | sudo tee -a /etc/conf.d/greetd
cfgfile="/etc/phrog/greetd-config.toml"
HERE
rc-update add greetd
```
[default_session]
command = "systemd-cat --identifier=phrog phrog"
```

Then run greetd however your distro prefers you to, see the
[example-config](./example-config) directory for an example greetd config and
startup script that launches greetd in a way suitable for mobile use.

You can also test it outside greetd, nested in your favourite Wayland desktop environment:
### Fedora

```
phoc -S -E "phrog --fake"
# Phrog is not yet available in Fedora's repos
sudo dnf copr enable samcday/phrog
sudo dnf install phrog
sudo systemctl enable phrog
```

### Other

Want to use phrog on another distro? [Please get in touch.](#getting-help)

If you want to run it manually, you'll need to build from source (see below), and then take a look at the existing packaging to understand how to wire up the necessary bits to spawn a functional greeter session under greetd.

## Development

`libphosh` is required to build this project.
Expand All @@ -52,11 +58,22 @@ If `libphosh` is not packaged for your distro, you need to build Phosh+libphosh
Once `libphosh` is installed, building and running 🐸 should be as simple as:

```sh
# To run phrog without greetd, pass --fake
# You can "login" to any user with the password "0"
phoc -S -E "cargo run -- --fake"

phoc -S -E "cargo test"
```

## Getting help

Found a bug or want to request a feature? [Please file an issue!][issues]

You can also come chat in Matrix: [#phosh:talk.puri.sm][Matrix]

[phog]: https://gitlab.com/mobian1/phog
[Phosh]: https://gitlab.gnome.org/World/Phosh/phosh
[greetd]: https://sr.ht/~kennylevinsen/greetd/
[COPR]: https://copr.fedorainfracloud.org/coprs/samcday/phrog/
[issues]: /~https://github.com/samcday/phrog/issues
[Matrix]: https://matrix.to/#/#phosh:talk.puri.sm
6 changes: 6 additions & 0 deletions data/mobi.phosh.Phrog.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Desktop Entry]
Name=Phrog
Comment=Greeter shell for greetd
Type=Application
Exec=phrog
NoDisplay=true
23 changes: 23 additions & 0 deletions data/phrog-greetd-session
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

# This simple wrapper script is intended to be used directly by greetd to
# start up the phrog greeter session.
# Your distribution packaging should have already set something up for you,
# but if you're doing this manually you can make use of this script by
# adding something like this to your config.toml:
# [default_session]
# command = "/usr/libexec/phrog-greetd-session"

PHOC_INI="/usr/share/phrog/phoc.ini"
if [ -f /etc/phrog/phoc.ini ]; then
PHOC_INI=/etc/phrog/phoc.ini
fi

# Need to set XDG_CURRENT_DESKTOP now, otherwise gnome-session defaults it to
# "GNOME", which is a problem because default desktop files for Squeekboard and
# phosh-osk-stub specify "OnlyShowIn=Phosh;"
export XDG_CURRENT_DESKTOP=Phosh:GNOME

export GNOME_SESSION_AUTOSTART_DIR=/usr/share/phrog/autostart:/etc/phrog/autostart

exec phoc -S -C "${PHOC_INI}" -E 'gnome-session --session=phrog'
4 changes: 4 additions & 0 deletions data/phrog.session
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[GNOME Session]
Name=phrog
# Keep this in sync with systemd/user/gnome-session@phrog.target.d/session.conf
RequiredComponents=mobi.phosh.Phrog;org.gnome.SettingsDaemon.MediaKeys;org.gnome.SettingsDaemon.Power;sm.puri.OSK0;
4 changes: 4 additions & 0 deletions data/systemd-session.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Unit]
# Keep this in sync with phrog.session
Wants=org.gnome.SettingsDaemon.MediaKeys.target
Wants=org.gnome.SettingsDaemon.Power.target
10 changes: 10 additions & 0 deletions dist/alpine/greetd-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This is a greetd config.toml preconfigured to run phrog.
# You can use it by adding the following line to /etc/conf.d/greetd:
# cfgfile="/etc/phrog/greetd-config.toml"

[terminal]
vt = 7

[default_session]
command = "sh -c 'dbus-run-session /usr/libexec/phrog-greetd-session 2>&1 | logger -t phrog'"
user = "greetd"
10 changes: 10 additions & 0 deletions dist/fedora/greetd-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This is a greetd config.toml preconfigured to run phrog.
# It's intended to be used with phrog.service
# But you can also use it directly by running greetd --config=/etc/phrog/greetd-config.toml

[terminal]
vt = 1

[default_session]
command = "systemd-cat --identifier=phrog /usr/libexec/phrog-greetd-session"
user = "greetd"
20 changes: 20 additions & 0 deletions dist/fedora/phrog.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Unit]
Description=Phrog greeter daemon
After=systemd-user-sessions.service plymouth-quit-wait.service
After=getty@tty1.service
Conflicts=getty@tty1.service greetd.service gdm.service

[Service]
Type=simple
ExecStart=greetd --config=/etc/phrog/greetd-config.toml
IgnoreSIGPIPE=no
SendSIGHUP=yes
TimeoutStopSec=30s
KeyringMode=shared
Restart=always
RestartSec=1
StartLimitBurst=5
StartLimitInterval=30

[Install]
Alias=display-manager.service
45 changes: 0 additions & 45 deletions example-config/phrog-session

This file was deleted.

8 changes: 0 additions & 8 deletions example-config/phrog.toml

This file was deleted.

23 changes: 20 additions & 3 deletions phrog.spec
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ Provides: greetd-%{name} = %{version}
%{cargo_license} > LICENSE.dependencies

%install
install -d %{buildroot}%{_datadir}/glib-2.0/schemas/
%{__install} -Dpm 0644 data/mobi.phosh.phrog.gschema.xml %{buildroot}%{_datadir}/glib-2.0/schemas/
%{__install} -Dpm 0644 data/mobi.phosh.phrog.gschema.xml -t %{buildroot}%{_datadir}/glib-2.0/schemas/
%{__install} -Dpm 0644 data/phrog.session -t %{buildroot}%{_datadir}/gnome-session/sessions/
%{__install} -Dpm 0644 data/mobi.phosh.Phrog.desktop -t %{buildroot}%{_datadir}/applications/
%{__install} -Dpm 0644 dist/fedora/greetd-config.toml -t %{buildroot}%{_sysconfdir}/phrog/
%{__install} -Dpm 0644 dist/fedora/phrog.service -t %{buildroot}%{_unitdir}/
%{__install} -Dpm 0644 data/systemd-session.conf -T %{buildroot}%{_userunitdir}/gnome-session@phrog.target.d/session.conf
%{__install} -Dpm 0755 data/phrog-greetd-session -t %{buildroot}%{_libexecdir}/
%{__install} -d %{buildroot}%{_datadir}/phrog/autostart
%{__install} -d %{buildroot}%{_sysconfdir}/phrog/autostart
%cargo_install

%if %{with check}
Expand All @@ -49,8 +56,18 @@ install -d %{buildroot}%{_datadir}/glib-2.0/schemas/
%files
%license LICENSE
%doc README.md
%{_datadir}/glib-2.0/schemas/*
%{_bindir}/phrog
%{_datadir}/applications/mobi.phosh.Phrog.desktop
%{_datadir}/glib-2.0/schemas/mobi.phosh.phrog.gschema.xml
%{_datadir}/gnome-session/sessions/phrog.session
%{_datadir}/phrog
%{_datadir}/phrog/autostart
%{_libexecdir}/phrog-greetd-session
%{_sysconfdir}/phrog
%{_sysconfdir}/phrog/autostart
%config(noreplace) %{_sysconfdir}/phrog/greetd-config.toml
%{_unitdir}/phrog.service
%{_userunitdir}/gnome-session@phrog.target.d/session.conf

%changelog
%autochangelog

0 comments on commit 7a3199d

Please sign in to comment.