Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/omarchy
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ GROUP_DESCRIPTIONS[config]="System configuration helpers"
GROUP_DESCRIPTIONS[crash]="Crash notification controls"
GROUP_DESCRIPTIONS[debug]="Diagnostics and support logs"
GROUP_DESCRIPTIONS[finalize]="Finalize user setup"
GROUP_DESCRIPTIONS[fingerprint]="Fingerprint enrollment and setup"
GROUP_DESCRIPTIONS[default]="Default application selection"
GROUP_DESCRIPTIONS[dev]="Omarchy development tools"
GROUP_DESCRIPTIONS[disk]="Disk performance helpers"
Expand Down
98 changes: 98 additions & 0 deletions bin/omarchy-fingerprint-enroll
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/bin/bash

# omarchy:summary=Enroll fingerprints with the on-screen guide
# omarchy:args=[finger]
# omarchy:examples=omarchy fingerprint enroll | omarchy fingerprint enroll right-thumb

# Without a finger, open the finger picker and exit 0 once it is on screen.
# With one, enroll that finger and wait: exit 0 on success, 1 on failure or
# cancel, the same contract as fprintd-enroll. When the overlay cannot open,
# fall back to fprintd-enroll in a terminal, and fail without one.

set -uo pipefail

finger=${1:-}
plugin=omarchy.fingerprint-enroll

if [[ -n $finger && ! $finger =~ ^(left|right)-(thumb|(index|middle|ring|little)-finger)$ ]]; then
echo "Unknown finger: $finger (for example right-index-finger or left-thumb)" >&2
exit 2
fi

overlay_call() {
omarchy-shell shell call "$plugin" "$1" "${2:-}" 2>/dev/null
}

fallback() {
if [[ -t 0 ]]; then
exec fprintd-enroll ${finger:+-f "$finger"}
fi
echo "The fingerprint overlay could not open" >&2
exit 1
}

if [[ $(omarchy-shell shell ping 2>/dev/null) != "ok" ]]; then
fallback
fi

# summon only queues the request and the overlay loads asynchronously, so a
# request can reach it after this script has given up and fallen back. Each
# request carries a deadline (epoch milliseconds): the overlay refuses one
# that arrives later, and this script gives up only once the deadline has
# passed, so the overlay and the fallback never both run.
WAIT_MS=${OMARCHY_FINGERPRINT_ENROLL_WAIT_MS:-10000}
deadline=$(( $(date +%s%3N) + WAIT_MS ))

past_deadline() {
(( $(date +%s%3N) > deadline ))
}

if [[ -z $finger ]]; then
[[ $(omarchy-shell shell summon "$plugin" "{\"expires\":$deadline}" 2>/dev/null) == "ok" ]] || fallback
until past_deadline; do
[[ $(overlay_call isOpen) == "open" ]] && exit 0
sleep 0.2
done
# Past the deadline the overlay no longer takes the request, so this
# answer is final.
[[ $(overlay_call isOpen) == "open" ]] && exit 0
fallback
fi

# The overlay writes its result into a directory only this user can enter, so
# no other local process can plant a result or race the file into existence.
result_dir=$(mktemp -d)
trap 'rm -rf "$result_dir"' EXIT
done_file="$result_dir/result"

if [[ $(omarchy-shell shell summon "$plugin" "{\"finger\":\"$finger\",\"doneFile\":\"$done_file\",\"expires\":$deadline}" 2>/dev/null) != "ok" ]]; then
rm -rf "$result_dir"
trap - EXIT
fallback
fi

# Wait for the result. While waiting, ask the overlay whether it is still
# handling this request: if it never took it, or it went away without
# answering (load failure, shell restart), stop instead of waiting out the
# safety net. fprintd times out an idle enrollment itself.
seen=false
for i in $(seq 1 1200); do
[[ -f $done_file ]] && break
if (( i % 2 == 0 )); then
case $(overlay_call handles "$done_file") in
yes) seen=true ;;
*)
# Gone after having been ours, or not ours once the deadline has
# passed (the overlay refuses it from then on): give a result
# written on the way out a moment to land, then stop.
if [[ $seen == "true" ]] || past_deadline; then
sleep 1
break
fi
;;
esac
fi
sleep 0.5
done

[[ $(cat "$done_file" 2>/dev/null) == "ok" ]]
83 changes: 83 additions & 0 deletions bin/omarchy-fingerprint-setup-helper
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

# omarchy:summary=Privileged steps of fingerprint setup for the enrollment overlay
# omarchy:args=status|install|enable-login
# omarchy:hidden=true
# omarchy:requires-sudo=true

# The enrollment overlay has no terminal for sudo, so its privileged steps run
# through this command, which re-runs itself through pkexec. It adds no setup
# logic of its own: packages use the same transaction as
# omarchy-setup-security-fingerprint, and turning login on runs that script's
# own PAM and lock-screen steps.
#
# status ready (login on) | enroll (packages in) | install
# install fingerprint packages
# enable-login sudo, polkit and lock-screen authentication

set -euo pipefail

# Whenever this runs as root, sudo's secure_path or pkexec decides where a bare
# helper resolves, and a dev link prepends a user-writable checkout bin/ to
# sudo's. Pin PATH to trusted system directories, and run the setup script
# from its packaged location with the packaged OMARCHY_PATH.
if (( EUID == 0 )); then
export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
export OMARCHY_PATH=/usr/share/omarchy
fi

# The privileged half always runs from the packaged path rather than whichever
# copy was invoked, so a dev checkout is never what root executes.
PACKAGED_PATH=/usr/bin/omarchy-fingerprint-setup-helper

require_root() {
if (( EUID == 0 )); then
return
elif [[ -t 0 ]]; then
exec sudo "$PACKAGED_PATH" "$@"
else
# No terminal for sudo's prompt (the overlay): polkit shows one on screen.
exec pkexec "$PACKAGED_PATH" "$@"
fi
}

status() {
if grep -qs pam_fprintd.so /etc/pam.d/sudo && [[ -f /etc/pam.d/omarchy-lock-fingerprint ]]; then
echo ready
elif omarchy-cmd-present fprintd-enroll; then
echo enroll
else
echo install
fi
}

install_packages() {
# Same transaction as omarchy-setup-security-fingerprint: libfprint-git
# tracks upstream ahead of the Arch release, and --ask 4 accepts its
# replacement of stock libfprint in one transaction, so a failed install
# leaves the existing driver alone.
if ! pacman -Q -- libfprint-git fprintd usbutils &>/dev/null; then
echo "Installing fingerprint packages"
pacman -S --needed --noconfirm --ask 4 -- libfprint-git fprintd usbutils >/dev/null
fi
echo "Packages ready"
}

case "${1:-}" in
status)
status
;;
install)
require_root "$@"
install_packages
;;
enable-login)
require_root "$@"
echo "Turning fingerprint login on"
exec /usr/bin/omarchy-setup-security-fingerprint --enable-login
;;
*)
echo "Usage: omarchy-fingerprint-setup-helper status|install|enable-login" >&2
exit 2
;;
esac
48 changes: 42 additions & 6 deletions bin/omarchy-setup-security-fingerprint
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,47 @@ EOF
fi
}

# PAM for sudo and polkit, then the lock screen and its resume recovery, then
# confirmation that the lock screen picked it up.
enable_fingerprint_login() {
setup_pam_config
"$OMARCHY_PATH/bin/omarchy-apply-lock"
if [[ ! -f /etc/pam.d/omarchy-lock-fingerprint ]]; then
echo "Fingerprint enrollment succeeded, but lock-screen configuration could not be confirmed. Run omarchy-apply-lock and try again." >&2
exit 1
fi
}

# The enrollment overlay turns fingerprint login on through
# omarchy-fingerprint-setup-helper, once a print is enrolled and confirmed.
if [[ ${1:-} == "--enable-login" ]]; then
enable_fingerprint_login
exit 0
fi

# Inside a running shell the whole flow is the fingerprint overlay: it
# installs packages through omarchy-fingerprint-setup-helper, guides the
# enrollment on screen, confirms the print with a touch, and then turns
# fingerprint login on with --enable-login above. Later runs open its finger
# picker. omarchy-fingerprint-enroll exits 0 only once the overlay is on
# screen; otherwise setup continues with the text flow below, which --text
# asks for directly.
if [[ ${1:-} != "--text" && $(omarchy-shell shell ping 2>/dev/null) == "ok" ]]; then
if ! omarchy-hw-fingerprint; then
echo -e "\e[31mNo fingerprint sensor detected.\e[0m"
exit 1
fi
if omarchy-fingerprint-enroll </dev/null; then
exit 0
fi
fi

# The menu runs this without a terminal, which the text flow needs for sudo
# and fprintd-enroll, so when the overlay did not open, reopen in one.
if [[ ${1:-} == "--menu" ]]; then
exec omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-fingerprint --text
fi

echo -e "\e[32mSetting up fingerprint scanner for authentication.\n\e[0m"

# Bail before installing anything if there's no reader to talk to.
Expand Down Expand Up @@ -88,12 +129,7 @@ if sudo fprintd-enroll "$USER"; then
# sensor outside the elanmoc table gets this far and then fails to enroll.
# Editing the stacks up front would leave those machines pointing at
# pam_fprintd with nothing to match.
setup_pam_config
"$OMARCHY_PATH/bin/omarchy-apply-lock"
if [[ ! -f /etc/pam.d/omarchy-lock-fingerprint ]]; then
echo "Fingerprint enrollment succeeded, but lock-screen configuration could not be confirmed. Run omarchy-apply-lock and try again." >&2
exit 1
fi
enable_fingerprint_login
echo -e "\e[32m\nPerfect! Fingerprint authentication is now configured.\e[0m"
echo "You can use your fingerprint for sudo, polkit, and lock screen (Super + Ctrl + L)."
else
Expand Down
77 changes: 77 additions & 0 deletions default/i18n/en/shell.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,83 @@
"elsewhen.yesterday": "Yesterday",
"emojis.noMatches": "No matches for “%1”",
"emojis.search": "Search emojis…",
"fingerprint.checking": "Checking fingerprint login",
"fingerprint.choose": "Choose a finger to enroll",
"fingerprint.chooseFirst": "Choose the finger to enroll first",
"fingerprint.confirmAgain": "Didn't match, touch again (%1 of %2)",
"fingerprint.confirmHint": "Press the way you normally would",
"fingerprint.confirmTouch": "Touch the sensor once to confirm",
"fingerprint.couldNotVerify": "Couldn't verify your %1",
"fingerprint.disconnected": "The reader was disconnected",
"fingerprint.done": "Done",
"fingerprint.duplicate": "This finger is already enrolled, possibly as another finger",
"fingerprint.enrollFailed": "Enrollment failed. Try again",
"fingerprint.enrolled": "Fingerprint enrolled",
"fingerprint.escBack": "Press Esc to go back",
"fingerprint.escClose": "Press Esc to close",
"fingerprint.failed": "Failed",
"fingerprint.finger.leftIndex": "left index finger",
"fingerprint.finger.leftLittle": "left little finger",
"fingerprint.finger.leftMiddle": "left middle finger",
"fingerprint.finger.leftRing": "left ring finger",
"fingerprint.finger.leftThumb": "left thumb",
"fingerprint.finger.rightIndex": "right index finger",
"fingerprint.finger.rightLittle": "right little finger",
"fingerprint.finger.rightMiddle": "right middle finger",
"fingerprint.finger.rightRing": "right ring finger",
"fingerprint.finger.rightThumb": "right thumb",
"fingerprint.finger.unknown": "finger",
"fingerprint.fingerReady": "Your %1 is ready for sudo, admin prompts and the lock screen",
"fingerprint.hand.left": "Left hand",
"fingerprint.hand.right": "Right hand",
"fingerprint.holdStill": "Hold still",
"fingerprint.loginOff": "Fingerprint login is off",
"fingerprint.loginOn": "Fingerprint login is on",
"fingerprint.loginOnHint": "Use it for sudo, admin prompts and the lock screen. Add more fingers next",
"fingerprint.matched": "Matched",
"fingerprint.noResponse": "The reader did not respond",
"fingerprint.notCentered": "Center the finger on the sensor",
"fingerprint.passwordNeeded": "Not added: your password is needed to add a fingerprint",
"fingerprint.pickerHint": "Arrow keys and Enter, or click. Esc closes",
"fingerprint.placeFinger": "Place the finger on the sensor",
"fingerprint.placement.above": "slightly above center",
"fingerprint.placement.below": "slightly below center",
"fingerprint.placement.center": "the center of the fingertip",
"fingerprint.placement.left": "slightly left of center",
"fingerprint.placement.lowerLeft": "the lower-left",
"fingerprint.placement.lowerRight": "the lower-right",
"fingerprint.placement.right": "slightly right of center",
"fingerprint.placement.upperLeft": "the upper-left",
"fingerprint.placement.upperRight": "the upper-right",
"fingerprint.pleaseWait": "Please wait until this finishes",
"fingerprint.pressAt": "Press %1 on the sensor",
"fingerprint.readerBusy": "The reader is busy. Close other fingerprint tools and retry",
"fingerprint.readerNotStarted": "The fingerprint reader could not start. Try again, or replug it",
"fingerprint.reenrollHint": "Press Enter to enroll it again, Esc to close",
"fingerprint.removeAndRetry": "Lift the finger, then press again",
"fingerprint.retryHint": "Press Enter to try again, Esc to close",
"fingerprint.retryScan": "Not a clear scan. Press flat and hold for a second",
"fingerprint.settingUp": "Setting up",
"fingerprint.setupCancelled": "Setup was cancelled",
"fingerprint.setupFailed": "Setup failed. Check your internet connection and try again",
"fingerprint.short.index": "Index",
"fingerprint.short.little": "Little",
"fingerprint.short.middle": "Middle",
"fingerprint.short.ring": "Ring",
"fingerprint.short.thumb": "Thumb",
"fingerprint.stageCount": "%1 of %2",
"fingerprint.stagePassed": "Lift, shift the finger a little, press again",
"fingerprint.starting": "Starting the reader",
"fingerprint.storageFull": "The reader's storage is full",
"fingerprint.title.confirm": "Confirm your %1",
"fingerprint.title.enroll": "Enroll your %1",
"fingerprint.title.login": "Fingerprint login",
"fingerprint.title.picker": "Fingerprints",
"fingerprint.tooShort": "Too short. Hold the finger on the sensor for a second",
"fingerprint.turnOnCancelled": "Turning it on was cancelled",
"fingerprint.turnOnFailed": "Could not turn on fingerprint login",
"fingerprint.turnOnHint": "Press Enter to turn it on. You will be asked for your password",
"fingerprint.turningOn": "Turning fingerprint login on",
"imagePicker.deleteTheme": "Do you want to delete %1?",
"lock.authenticationFailed": "Authentication failed (%1)",
"lock.checking": "Checking…",
Expand Down
2 changes: 1 addition & 1 deletion default/omarchy/omarchy-menu.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
"setup.plugin.remove": {"icon":"󰭌","label":"Remove Plugin","when":"compgen -G \"$HOME/.config/omarchy/plugins/*/manifest.json\"","action":"omarchy-menu-plugin remove"},
"setup.security": {"icon":"","label":"Security"},
"setup.config": {"icon":"","label":"Config"},
"setup.security.fingerprint": {"icon":"󰈷","label":"Fingerprint","when":"omarchy-hw-fingerprint","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-fingerprint"},
"setup.security.fingerprint": {"icon":"󰈷","label":"Fingerprint","when":"omarchy-hw-fingerprint","action":"omarchy-setup-security-fingerprint --menu"},
"setup.security.fido2": {"icon":"","label":"Fido2","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-fido2"},
"setup.security.sshd": {"icon":"󰣀","label":"SSHD","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-sshd"},
"setup.security.ssh-agent": {"icon":"󰣀","label":"SSH Agent","when":"! systemctl --user -q is-enabled gcr-ssh-agent.socket","action":"omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-ssh-agent"},
Expand Down
2 changes: 1 addition & 1 deletion manual/37-hardware-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A lot of laptops come with a fingerprint sensor to do authentication. You can use this with Omarchy by running _Setup > Security > Fingerprint_ in the Omarchy menu (`Super + Space`).

That'll install the fingerprint package, collect your print, verify it, and you'll be set to go using your fingerprint to unlock from the lock screen (which you can trigger with `Super + Ctrl + L`), enter sudo mode, and authorize system prompts.
That opens the fingerprint guide. The first time it asks for your password, installs the fingerprint package, and lets you pick a finger; you then press it about twenty times, shifting it a little each time as the on-screen print fills in, touch once more to confirm, and you're set to go using your fingerprint to unlock from the lock screen (which you can trigger with `Super + Ctrl + L`), enter sudo mode, and authorize system prompts. Open the same menu item again to add more fingers. Adding a fingerprint always asks for your own password first, so nobody at your unlocked computer can add theirs; it's remembered for a few minutes, so adding several fingers in a row asks only once.

Once the lock screen has turned the display off, the sensor rests to save power, so wake the screen with any key or the touchpad before touching it.

Expand Down
27 changes: 27 additions & 0 deletions shell/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ User-installed plugins live alongside these conceptually but on disk under
| Emojis | `omarchy.emojis` | `overlay` | `emojis/Emojis.qml` |
| Clipboard mgr | `omarchy.clipboard` | `overlay` | `clipboard/Clipboard.qml` |
| Reminders | `omarchy.reminders` | `overlay` | `reminders/ReminderFlow.qml` |
| Fingerprint | `omarchy.fingerprint-enroll` | `overlay` | `fingerprint-enroll/Enroll.qml` |
| Omarchy menu | `omarchy.menu` | `menu`, `bar-widget` | `menu/Menu.qml`, `menu/BarWidget.qml` |
| Notifications | `omarchy.notifications` | `service` | `notifications/Service.qml` |
| Audio | `omarchy.audio` | `bar-widget` | `panels/audio/Panel.qml` |
Expand Down Expand Up @@ -92,6 +93,32 @@ The plugin sets `keepLoaded: true` so a plugin hot-reload (for example
an installed bar widget changing on disk) does not destroy the lock
client while Hyprland still holds the session lock.

## Fingerprint enrollment

Setup > Security > Fingerprint. Drives `fprintd-enroll` and turns its
per-stage results into a print that fills in press by press, with a hint
for where to press next, so an enrollment covers the finger rather than one
spot twenty times. `fprintd`'s `finger-present` property gives instant
"hold still" feedback. On a first run (PAM not yet configured) it calls
`omarchy-fingerprint-setup-helper`, which re-runs itself through `pkexec`
to install packages and, after one confirm touch, turn fingerprint login
on; later runs open a finger picker. Enrolling asks for the user's own
password (fprintd's default polkit rule, kept for a few minutes), so an
unlocked session alone cannot add a fingerprint. Works with any fprintd
reader.

Summon with `omarchy-fingerprint-enroll` (picker; exits 0 once it is on
screen) or `omarchy-fingerprint-enroll right-thumb` (one finger, waits for
the result). Payload keys: `finger`, `doneFile`, `expires`. One request at
a time: a request arriving while the overlay is open, or after its
`expires` deadline (epoch milliseconds; the wrapper waits that long before
falling back), is refused with `failed`.
`isOpen()` and `handles(doneFile)`, through `omarchy-shell shell call`, let
a waiting script notice when the overlay went away without answering. When
the overlay cannot open, `omarchy-setup-security-fingerprint` continues
with its text flow, reopening in a terminal when the menu ran it (`--menu`,
which hands over with `--text`).

## Polkit agent

Theme-aware authentication dialog for privileged actions. It uses
Expand Down
Loading