Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ is missing or empty.

### Desktop

- Every iPad, iPhone and iPod touch screen now starts at the size it has
under iOS. Before, only the iPad 6, iPad 7 and iPhone 7 did; on the others,
such as the iPod touch 6, everything was drawn at half size.
- A new launcher replaces the app grid: Home, Super and the bar's logo open
apps, actions and (on a phone) the system controls in swipeable tabs, with
search, recent apps and files, long-press app menus and full keyboard
Expand Down
10 changes: 5 additions & 5 deletions desktop/configuration/scale-output
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
# Scale the single native panel (the iPads' and the iPhone 7's), accepting both
# current/preferred flag lists.
# Scale the single built-in panel of an iPad, iPhone or iPod touch, accepting
# both current/preferred flag lists.
# Never change its timing or force the VM's Virtual-1 mode.
# The scale is the one omarchy-hyprland-monitor-persist saved for this output
# (upstream Omarchy's monitors/settings file, scale in the third field, the
# output last), else 2.
# output last), else the one iOS gives that panel (omarchy-panel-scale).
set -euo pipefail
state=$(wlr-randr)
mapfile -t outputs < <(awk '/^[^[:space:]]/ {print $1}' <<< "$state")
mode=$(awk '/^[[:space:]]+[0-9]+x[0-9]+ px, .*current/ {print $1; exit}' <<< "$state")
if (( ${#outputs[@]} != 1 )) || ! grep -q ' Enabled: yes' <<< "$state" ||
! grep -Eq '^[[:space:]]+(1536x2048|2048x1536|1620x2160|2160x1620|750x1334|1334x750) px, .*current' <<< "$state"; then
! scale=$(omarchy-panel-scale "${mode:-none}" 2>/dev/null); then
echo 'Native single-panel mode not established; left scale unchanged' >&2
exit 0
fi
scale=2
settings="${XDG_STATE_HOME:-${HOME:-}/.local/state}/omarchy/monitors/settings"
if [[ -r $settings ]]; then
saved=$(awk -F'\t' -v output="${outputs[0]}" '$NF == output { scale = $3 } END { print scale }' "$settings")
Expand Down
4 changes: 3 additions & 1 deletion desktop/shell/bin/omarchy-labwc-window-rules
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ rules=$HOME/.local/state/omarchy/xdg-config/labwc/rc.xml

# A phone: the panel's short side under 480 logical pixels (the shell's
# narrow bar), at the scale omarchy-hyprland-monitor-persist saved for it,
# else 2 (as scale-output). Read from the kernel: at login labwc is not up.
# else the panel's own (omarchy-panel-scale, as scale-output), else 2. Read
# from the kernel: at login labwc is not up.
phone() {
local modes mode short scale=2 settings
for modes in "${OMARCHY_DRM_ROOT:-/sys/class/drm}"/card*-*/modes; do
[[ -r $modes ]] || continue
mode=$(head -1 "$modes")
[[ $mode =~ ^([0-9]+)x([0-9]+) ]] || continue
short=$(( BASH_REMATCH[1] < BASH_REMATCH[2] ? BASH_REMATCH[1] : BASH_REMATCH[2] ))
scale=$(omarchy-panel-scale "${BASH_REMATCH[1]}x${BASH_REMATCH[2]}" 2>/dev/null) || scale=2
settings=$HOME/.local/state/omarchy/monitors/settings
if [[ -r $settings ]]; then
local saved
Expand Down
30 changes: 30 additions & 0 deletions desktop/shell/bin/omarchy-panel-scale
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# omarchy:summary=Print the scale an Apple panel starts at, by its mode
# omarchy:args=WIDTHxHEIGHT
# omarchy:hidden=true

# The built-in panels of the iPads, iPhones and iPod touches, each with the
# scale iOS gives it (its points), so a screen starts at the size it has
# under iOS. Either orientation. An unknown mode (a VM, an external monitor)
# prints nothing and fails: callers leave such a screen alone.
# The iPhone Plus panels: iOS draws them at 3x and shrinks the picture to the
# panel, about 2.61 here; 2.5 is the nearest scale that splits the panel into
# whole pixels.
set -euo pipefail
[[ ${1:-} =~ ^([0-9]+)x([0-9]+)$ ]] || { echo "Usage: omarchy-panel-scale WIDTHxHEIGHT" >&2; exit 2; }
w=${BASH_REMATCH[1]} h=${BASH_REMATCH[2]}
(( w <= h )) || { t=$w; w=$h; h=$t; }
case ${w}x$h in
# iPad 2, iPad mini.
768x1024) echo 1 ;;
# iPads: 9.7" and 7.9", 10.2", 10.5", 11", 12.9", 10.9", 8.3", 11" and 13" (M4).
1536x2048 | 1620x2160 | 1668x2224 | 1668x2388 | 2048x2732 | 1640x2360 | 1488x2266 | 1668x2420 | 2064x2752) echo 2 ;;
# iPhone 4s; iPhone 5 to SE and iPod touch 5 to 7; iPhone 6 to 8 and SE 2/3; iPhone XR and 11.
640x960 | 640x1136 | 750x1334 | 828x1792) echo 2 ;;
# iPhone 6 Plus to 8 Plus.
1080x1920) echo 2.5 ;;
# iPhone X to 16 and their Max, Pro and mini models.
1125x2436 | 1242x2688 | 1080x2340 | 1170x2532 | 1284x2778 | 1179x2556 | 1290x2796 | 1206x2622 | 1320x2868) echo 3 ;;
*) exit 1 ;;
esac
11 changes: 10 additions & 1 deletion tests/test_menu_toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def setUp(self):
# An iPad's panel unless a test says otherwise (the host's own is not asked).
self.drm = self.home / 'drm'
self.panel('1536x2048')
self.env = {**os.environ, 'HOME': str(self.home), 'OMARCHY_DRM_ROOT': str(self.drm)}
self.env = {**os.environ, 'HOME': str(self.home), 'OMARCHY_DRM_ROOT': str(self.drm),
'PATH': f'{BIN}:{os.environ["PATH"]}'}

def panel(self, mode):
modes = self.drm / 'card0-DSI-1/modes'
Expand Down Expand Up @@ -90,6 +91,14 @@ def test_on_a_phone_about_and_omacalc_fill_the_screen_too(self):
self.run_bin('omarchy-toggle-maximize-windows', '--apply')
self.assert_maximizes(rules)

def test_a_3x_iphone_is_a_phone_at_its_own_scale(self):
# 1125 wide is a tablet at 2, but the iPhone X starts at 3: 375.
rules = self.home / '.local/state/omarchy/xdg-config/labwc/rc.xml'
self.panel('1125x2436')
result = self.run_bin('omarchy-toggle-maximize-windows', '--apply')
self.assertEqual(result.returncode, 0, result.stderr)
self.assert_maximizes(rules, phone=True)

def test_the_on_flag_from_before_the_default_goes(self):
legacy = self.home / '.local/state/omarchy/toggles/maximize-windows'
legacy.parent.mkdir(parents=True)
Expand Down
8 changes: 7 additions & 1 deletion tests/test_monitor_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def run_script(self, mode='1536x2048', settings=None):
(state / 'omarchy/monitors').mkdir(parents=True)
(state / 'omarchy/monitors/settings').write_text(settings)
log = root / 'randr.log'
env = {**os.environ, 'PATH': f'{stubs}:{os.environ["PATH"]}', 'XDG_STATE_HOME': str(state),
env = {**os.environ, 'PATH': f'{stubs}:{BIN}:{os.environ["PATH"]}', 'XDG_STATE_HOME': str(state),
'RANDR_LOG': str(log), 'RANDR_TEXT': str(text)}
subprocess.run([BASH, str(SCALE_OUTPUT)], env=env, check=True, capture_output=True)
return log.read_text().splitlines() if log.exists() else []
Expand All @@ -167,6 +167,12 @@ def test_nothing_saved_scales_the_native_panel_by_two(self):
self.assertEqual(self.run_script(), ['--output Unknown-1 --scale 2'])
self.assertEqual(self.run_script(settings='\t\t1.6\t\tDP-1\n'), ['--output Unknown-1 --scale 2'])

def test_every_apple_panel_starts_at_its_ios_scale(self):
# The iPod touch 6 (640x1136) was missing and stayed at 1.
for mode, scale in (('640x1136', '2'), ('1136x640', '2'), ('640x960', '2'), ('2224x1668', '2'),
('2048x2732', '2'), ('768x1024', '1'), ('1080x1920', '2.5'), ('1125x2436', '3')):
self.assertEqual(self.run_script(mode=mode), [f'--output Unknown-1 --scale {scale}'], mode)

def test_the_saved_scale_for_the_panel_wins(self):
self.assertEqual(self.run_script(mode='2160x1620', settings='\t\t1.66667\t\tUnknown-1\n'),
['--output Unknown-1 --scale 1.66667'])
Expand Down
Loading