Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
6 changes: 4 additions & 2 deletions desktop/armv7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
`python -m release.package --output DIR --architecture armv7h` makes the
ARMv7 `omarchy-a` package of the checkout (the keyboard and cursor helper
compiled for ARMv7) in the ARMv7 builder. The image installs it, and `wlroots0.20`, `labwc`,
`omafox`, `omactivity`, `folio-touch` (Files) and `omacalc` from the ARMv7 channel of the
`omafox`, `omactivity`, `folio-touch` (Files), `omacalc` and `mesa` from the ARMv7 channel of the
[Orchard package repository](https://github.com/OrchardLinux/packages)
(`repo-armv7h`), listed before Arch Linux ARM's repositories. Upstream Omarchy
publishes no ARMv7 packages, so an ARMv7 image has no `[omarchy]` repository
and Omacalc is the Orchard repository's build of upstream's pinned source.
Mesa is Arch Linux ARM's there.
Mesa is the Orchard repository's too: OrchardLinux's fork with the SGX543's
OpenGL ES 2 driver (the A5 and A6) and software OpenGL, in the place of Arch
Linux ARM's.

A provisioned native ARMv7 Arch Linux ARM environment can run the recipes with
`ORCHARD_BUILD_NATIVE=1` and `ORCHARD_BUILD_ENV_ID` set to its reproducible image
Expand Down
74 changes: 50 additions & 24 deletions desktop/configuration/auto-brightness
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import time

IIO_ROOT = "/sys/bus/iio/devices"
BACKLIGHT_ROOT = "/sys/class/backlight"
TICK = 0.1
STATE_INTERVAL = 2.0 # powerd's als-state is request/reply, without change notifications
RAMP_TICK = 1.0 / 30 # loop period while a ramp runs: small, frequent steps look like a fade
RAMP_GAMMA = 2.2 # ramp in perceived brightness (raw ~ perceived ** gamma), not raw PWM
RAMP_MIN_SECS, RAMP_MAX_SECS = 0.3, 3.0
Expand Down Expand Up @@ -326,15 +326,15 @@ class IioSource:

def __init__(self, root, hz):
self.root = root
self.interval = 1.0 / max(hz, 0.5)
self.interval = max(STATE_INTERVAL, 1.0 / hz) if hz > 0 else STATE_INTERVAL
self.due = 0.0
self.warned = False

def poll(self, timeout):
wait = max(0.0, min(timeout, self.due - time.monotonic()))
time.sleep(wait)
if time.monotonic() < self.due:
return []
remaining = self.due - time.monotonic()
if remaining > 0:
time.sleep(min(timeout, remaining))
return [] # recheck the panel before touching the sensor
self.due = time.monotonic() + self.interval
dev = find_iio_light(self.root)
lux = read_iio_lux(dev) if dev else None
Expand Down Expand Up @@ -423,6 +423,7 @@ class ProxySource:
self.master = None
self.buf = b""
self.retry_at = 0.0
self.cmd = None

@staticmethod
def command():
Expand All @@ -439,13 +440,19 @@ class ProxySource:
return cmd

def start(self):
cmd = self.command()
if self.cmd is None:
self.cmd = self.command()
master, slave = pty.openpty()
self.proc = subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=slave, stderr=slave, close_fds=True)
os.close(slave)
try:
self.proc = subprocess.Popen(self.cmd, stdin=subprocess.DEVNULL, stdout=slave, stderr=slave, close_fds=True)
except OSError:
os.close(master)
raise
finally:
os.close(slave)
self.master = master
self.buf = b""
log("started", " ".join(cmd))
log("started", " ".join(self.cmd))

def stop(self):
if self.proc:
Expand All @@ -454,6 +461,7 @@ class ProxySource:
self.proc.wait(timeout=3)
except subprocess.TimeoutExpired:
self.proc.kill()
self.proc.wait()
if self.master is not None:
os.close(self.master)
self.proc = self.master = None
Expand Down Expand Up @@ -603,6 +611,7 @@ class Daemon:
self.moves = 0
self.stop = False
self.shown = None
self.last_status = None

# -- helpers
def tolerance(self):
Expand All @@ -623,8 +632,11 @@ class Daemon:
if not is_enabled(conf):
self.pause("off")
self.write_status(now, enabled=False)
return
return False
raw = self.backlight.read()
hold = [] if self.dry else holds()
if raw is None or raw <= 0:
hold = hold or ["backlight"]
if hold != self.hold:
if hold:
log("holding for", ", ".join(hold))
Expand All @@ -634,10 +646,7 @@ class Daemon:
if hold or now < self.settle_until:
self.pause("hold")
self.write_status(now, enabled=True)
return
raw = self.backlight.read()
if raw is None:
return
return False
# A change we didn't make: a brightness key, the menu.
if self.last_written is not None and abs(raw - self.last_written) > self.tolerance():
self.override_until = now + conf["override_secs"]
Expand All @@ -646,7 +655,7 @@ class Daemon:
self.pause("manual change")
if now < self.override_until:
self.write_status(now, enabled=True, override=self.override_until - now)
return
return True
if not self.active:
self.active = True
log("auto-brightness on")
Expand All @@ -668,6 +677,7 @@ class Daemon:
if self.goal_raw is not None:
self.step(raw, now)
self.write_status(now, enabled=True)
return True

# Perceived brightness in [0, 1]: equal steps here look equal on the panel.
def perceived(self, raw):
Expand Down Expand Up @@ -728,13 +738,15 @@ class Daemon:
"hold": self.hold,
"override_secs_left": round(override, 1),
"moves": self.moves,
"time": time.time(),
}
if data == self.last_status:
return
tmp = status_path() + ".tmp"
try:
with open(tmp, "w") as f:
json.dump(data, f)
json.dump(dict(data, time=time.time()), f)
os.replace(tmp, status_path())
self.last_status = data
except OSError:
pass

Expand All @@ -749,13 +761,27 @@ class Daemon:
os.kill(int(compositor), 0)
except (OSError, ValueError):
break
if not is_enabled(self.conf):
self.tick(time.monotonic())
time.sleep(1) # off means no 10Hz backlight/status work
now = time.monotonic()
wait = STATE_INTERVAL if end is None else min(STATE_INTERVAL, max(0, end - now))
if not self.tick(now):
if isinstance(self.source, ProxySource):
self.source.stop() # dropping monitor-sensor releases its ClaimLight
self.latest = None
if now < self.settle_until:
wait = min(wait, self.settle_until - now)
time.sleep(wait)
continue
for lux in self.source.poll(RAMP_TICK if self.ramping() else TICK):
# Reuse the last signalled lux while the median and low-pass filter
# settle. Stable light needs no intermediate policy ticks.
if self.latest is not None and now >= self.override_until:
target = max(0.0, self.latest * self.conf["lux_scale"])
if (self.smoother.level is None or self.smoother.readings != [target] * self.smoother.window
or abs(math.log1p(target) - self.smoother.level) > 0.001):
wait = min(wait, max(0.0, self.next_sample - now))
if self.ramping():
wait = min(wait, RAMP_TICK)
for lux in self.source.poll(wait):
self.latest = lux
self.tick(time.monotonic())
self.source.close()
try:
os.unlink(status_path())
Expand Down Expand Up @@ -843,7 +869,7 @@ def main():
os.kill(int(compositor), 0)
except (OSError, ValueError):
return 0
time.sleep(1)
time.sleep(STATE_INTERVAL)
name = find_backlight(conf["backlight"])
source = make_source(args, conf)
daemon = Daemon(conf, source, Backlight(name), args.dry_run, args.debug)
Expand Down
42 changes: 32 additions & 10 deletions desktop/configuration/login-session
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,42 @@ export LIBGL_ALWAYS_SOFTWARE=1 LIBSEAT_BACKEND=seatd MOZ_ENABLE_WAYLAND=1
# which (journalctl -t omarchy-gpu-probe). On the GPU desktop the shell and
# its apps draw with Qt Quick on the GPU; on the software desktop with Qt's
# software renderer.
gpu=
# A board with the A5's or A6's PowerVR SGX543 (kernel driver apple-sgx) has one
# card that is both its display controller and its GPU, and Mesa's sgx driver
# draws OpenGL ES 2 on it: there Labwc draws on wlroots' GLES2 renderer on that
# card and applications get the GPU's OpenGL ES, once gpu-probe has drawn a frame
# that way in this boot. The shell keeps Qt's software renderer: the SGX has
# OpenGL ES 2 only, and Qt Quick on it is untested. The lite shell avoids
# offscreen passes for masks and shadows on this tile-based GPU.
gpu= gpu_driver=
for node in /sys/class/drm/renderD*; do
if [[ $(basename "$(readlink -f "$node/device/driver")") == powervr ]]; then gpu=$node; fi
driver=$(basename "$(readlink -f "$node/device/driver")")
if [[ $driver == powervr || $driver == apple-sgx ]]; then gpu=$node gpu_driver=$driver; fi
done
if [[ -n $gpu ]]; then
gpu_probe=/usr/lib/omarchy-a/gpu-probe
gpu_log=$XDG_RUNTIME_DIR/omarchy-gpu-probe.log
# The GPU has no display outputs: Labwc must open the display's card only.
# The PowerVR GPU has no display outputs: Labwc must open the display's card
# only. The SGX's card is the display.
display=
for card in /sys/class/drm/card*; do
if [[ ${card##*/} =~ ^card[0-9]+$ && $(readlink -f "$card/device") != "$(readlink -f "$gpu/device")" ]]; then
[[ ${card##*/} =~ ^card[0-9]+$ ]] || continue
if [[ $gpu_driver == apple-sgx ]]; then
if [[ $(readlink -f "$card/device") == "$(readlink -f "$gpu/device")" ]]; then display=/dev/dri/${card##*/}; fi
elif [[ $(readlink -f "$card/device") != "$(readlink -f "$gpu/device")" ]]; then
display=/dev/dri/${card##*/}
fi
done
# GTK draws with Vulkan: GTK 4 takes its Vulkan renderer by itself only when the driver offers a dma-buf
# modifier other than LINEAR. Where it offers LINEAR alone (the A7), GTK took its GL renderer on Zink, which
# drew text twice and WebKit's pages not at all (Web showed an empty window); Vulkan draws them right.
gpu_desktop=(WLR_RENDERER=gles2 "WLR_RENDER_DRM_DEVICE=/dev/dri/${gpu##*/}"
MESA_LOADER_DRIVER_OVERRIDE=zink PVR_I_WANT_A_BROKEN_VULKAN_DRIVER=1 GSK_RENDERER=vulkan)
if [[ $gpu_driver == apple-sgx ]]; then
# The display's own card renders: wlroots finds the GPU through it.
gpu_desktop=(WLR_RENDERER=gles2)
else
# GTK draws with Vulkan: GTK 4 takes its Vulkan renderer by itself only when the driver offers a dma-buf
# modifier other than LINEAR. Where it offers LINEAR alone (the A7), GTK took its GL renderer on Zink, which
# drew text twice and WebKit's pages not at all (Web showed an empty window); Vulkan draws them right.
gpu_desktop=(WLR_RENDERER=gles2 "WLR_RENDER_DRM_DEVICE=/dev/dri/${gpu##*/}"
MESA_LOADER_DRIVER_OVERRIDE=zink PVR_I_WANT_A_BROKEN_VULKAN_DRIVER=1 GSK_RENDERER=vulkan)
fi
if [[ -n $display ]]; then
gpu_desktop+=("WLR_DRM_DEVICES=$display")
# simpledrm cannot scan out a buffer the GPU drew (it takes no dma-buf), so
Expand All @@ -64,7 +81,9 @@ if [[ -n $gpu ]]; then
gpu_desktop+=(WLR_SCENE_DISABLE_DIRECT_SCANOUT=1)
fi
fi
if [[ ! -e /usr/share/vulkan/icd.d/powervr_mesa_icd.json ]]; then
if [[ $gpu_driver == apple-sgx && ! -e /usr/lib/dri/apple_sgx_dri.so ]]; then
gpu_verdict='software desktop: this image has no OpenGL ES driver for the GPU'
elif [[ $gpu_driver == powervr && ! -e /usr/share/vulkan/icd.d/powervr_mesa_icd.json ]]; then
gpu_verdict='software desktop: this image has no Vulkan driver for the GPU'
elif [[ -z $display || ! -x $gpu_probe ]]; then
gpu_verdict='software desktop: no display card or no gpu-probe to test the GPU with'
Expand All @@ -77,6 +96,7 @@ if [[ -n $gpu ]]; then
gpu_key=
if [[ -n $gpu_cache ]]; then
gpu_icd_sig=$(stat -Lc '%Y:%s' /usr/share/vulkan/icd.d/powervr_mesa_icd.json 2>/dev/null || echo icd)
if [[ $gpu_driver == apple-sgx ]]; then gpu_icd_sig=$(stat -Lc '%Y:%s' /usr/lib/libgbm.so.1 2>/dev/null || echo gbm); fi
gpu_probe_sig=$(stat -Lc '%Y:%s' "$gpu_probe" 2>/dev/null || echo probe)
gpu_key="$(uname -r)|${display_driver:-none}|$gpu_icd_sig|$gpu_probe_sig"
fi
Expand All @@ -86,6 +106,7 @@ if [[ -n $gpu ]]; then
export "${gpu_desktop[@]}" MESA_DISK_CACHE_SINGLE_FILE=1
unset LIBGL_ALWAYS_SOFTWARE QT_QUICK_BACKEND
export QSG_NO_DEPTH_BUFFER=1 QSG_NO_STENCIL_BUFFER=1
if [[ $gpu_driver == apple-sgx ]]; then export QT_QUICK_BACKEND=software OMARCHY_SHELL_LITE=1; fi
else
# The probe runs with the environment the desktop would get. The login
# waits for it 10 s at most and does not depend on it ending: a probe
Expand All @@ -109,6 +130,7 @@ if [[ -n $gpu ]]; then
# keeps a full-size depth/stencil buffer in memory that the UI never
# reads (on the iPod touch 6 that is about 50 MB in the shell alone).
export QSG_NO_DEPTH_BUFFER=1 QSG_NO_STENCIL_BUFFER=1
if [[ $gpu_driver == apple-sgx ]]; then export QT_QUICK_BACKEND=software OMARCHY_SHELL_LITE=1; fi
if [[ -n $gpu_cache ]]; then
mkdir -p "$(dirname "$gpu_cache")" 2>/dev/null || true
printf '%s\n%s\n' "$gpu_key" "$gpu_detail" >"$gpu_cache.tmp" 2>/dev/null &&
Expand Down
Loading
Loading