-
Notifications
You must be signed in to change notification settings - Fork 42
feat: auto-toggle Chromium app mode for small viewports #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
157826e
370b0a5
26ab02f
d57b171
de3585c
9e9dfdf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,10 @@ Section "Monitor" | |
| Modeline "960x720_60.00" 55.86 960 1008 1104 1248 720 721 724 746 -HSync +Vsync | ||
| # 800x600 @ 60.00 Hz (GTF) hsync: 37.32 kHz; pclk: 38.22 MHz | ||
| Modeline "800x600_60.00" 38.22 800 832 912 1024 600 601 604 622 -HSync +Vsync | ||
| # 768x1024 @ 60.00 Hz (GTF) hsync: 63.60 kHz; pclk: 65.13 MHz | ||
| Modeline "768x1024_60.00" 65.13 768 816 896 1024 1024 1025 1028 1060 -HSync +Vsync | ||
| # 390x844 @ 60.00 Hz (manual, non-CVT) pclk: 27.26 MHz (mobile: iPhone 14/15) | ||
| Modeline "390x844_60.00" 27.26 390 406 446 520 844 845 848 874 -HSync +Vsync | ||
| # 2560x1440 @ 60.00 Hz (GTF) hsync: 89.52 kHz; pclk: 312.25 MHz | ||
| Modeline "2560x1440_60.00" 312.25 2560 2752 3024 3488 1440 1443 1448 1493 -HSync +Vsync | ||
| # 1024x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 63.50 MHz | ||
|
|
@@ -89,6 +93,10 @@ Section "Monitor" | |
| Modeline "960x720_30.00" 25.33 960 960 1056 1152 720 721 724 733 -HSync +Vsync | ||
| # 800x600 @ 30.00 Hz (GTF) hsync: 18.33 kHz; pclk: 17.01 MHz | ||
| Modeline "800x600_30.00" 17.01 800 792 864 928 600 601 604 611 -HSync +Vsync | ||
| # 768x1024 @ 30.00 Hz (GTF) hsync: 31.26 kHz; pclk: 30.01 MHz | ||
| Modeline "768x1024_30.00" 30.01 768 784 864 960 1024 1025 1028 1042 -HSync +Vsync | ||
| # 390x844 @ 30.00 Hz (manual, non-CVT) pclk: 12.57 MHz (mobile: iPhone 14/15) | ||
| Modeline "390x844_30.00" 12.57 390 406 446 488 844 845 848 859 -HSync +Vsync | ||
| # 1920x1200 @ 30.00 Hz (GTF) hsync: 36.90 kHz; pclk: 96.00 MHz | ||
| Modeline "1920x1200_30.00" 96.00 1920 2000 2200 2528 1200 1203 1209 1235 -HSync +Vsync | ||
| # 1440x900 @ 30.00 Hz (GTF) hsync: 27.72 kHz; pclk: 52.80 MHz | ||
|
|
@@ -120,6 +128,10 @@ Section "Monitor" | |
| Modeline "1200x800_25.00" 31.48 1200 1224 1352 1540 800 801 804 818 -HSync +Vsync | ||
| # 800x1600 @ 24.92 Hz (CVT) hsync: 40.53 kHz; pclk: 41.50 MHz | ||
| Modeline "800x1600_25.00" 41.50 800 832 912 1024 1600 1603 1613 1626 -Hsync +Vsync | ||
| # 768x1024 @ 25.00 Hz (GTF) hsync: 25.97 kHz; pclk: 24.52 MHz | ||
| Modeline "768x1024_25.00" 24.52 768 784 856 944 1024 1025 1028 1039 -HSync +Vsync | ||
| # 390x844 @ 25.00 Hz (manual, non-CVT) pclk: 11.14 MHz (mobile: iPhone 14/15) | ||
| Modeline "390x844_25.00" 11.14 390 406 446 520 844 845 848 857 -HSync +Vsync | ||
|
|
||
| # 2560x1440 @ 10.00 Hz (GTF) hsync: 14.65 kHz; pclk: 48.76 MHz | ||
| Modeline "2560x1440_10.00" 48.76 2560 2568 2816 3104 1440 1441 1444 1465 -HSync +Vsync | ||
|
|
@@ -143,7 +155,7 @@ Section "Screen" | |
| SubSection "Display" | ||
| Viewport 0 0 | ||
| Depth 24 | ||
| Modes "2560x1440_60.00" "1920x1080_60.00" "1920x1200_60.00" "1440x900_60.00" "1280x720_60.00" "1200x800_60.00" "1152x648_60.00" "1024x768_60.00" "1024x576_60.00" "960x720_60.00" "800x600_60.00" "2560x1440_30.00" "1920x1080_30.00" "1920x1200_30.00" "1440x900_30.00" "1368x768_30.00" "1280x720_30.00" "1200x800_30.00" "1152x648_30.00" "1024x768_30.00" "1024x576_30.00" "960x720_30.00" "800x600_30.00" "800x1600_30.00" "3840x2160_25.00" "2560x1440_25.00" "1920x1080_25.00" "1920x1200_25.00" "1600x900_25.00" "1440x900_25.00" "1368x768_25.00" "1200x800_25.00" "1024x768_25.00" "800x1600_25.00" "2560x1440_10.00" "1920x1080_10.00" "1920x1200_10.00" "1440x900_10.00" "1200x800_10.00" "1024x768_10.00" | ||
| Modes "2560x1440_60.00" "1920x1080_60.00" "1920x1200_60.00" "1440x900_60.00" "1280x720_60.00" "1200x800_60.00" "1152x648_60.00" "1024x768_60.00" "1024x576_60.00" "960x720_60.00" "800x600_60.00" "768x1024_60.00" "390x844_60" "2560x1440_30.00" "1920x1080_30.00" "1920x1200_30.00" "1440x900_30.00" "1368x768_30.00" "1280x720_30.00" "1200x800_30.00" "1152x648_30.00" "1024x768_30.00" "1024x576_30.00" "960x720_30.00" "800x600_30.00" "800x1600_30.00" "768x1024_30.00" "390x844_30" "3840x2160_25.00" "2560x1440_25.00" "1920x1080_25.00" "1920x1200_25.00" "1600x900_25.00" "1440x900_25.00" "1368x768_25.00" "1200x800_25.00" "1024x768_25.00" "800x1600_25.00" "768x1024_25.00" "390x844_25" "2560x1440_10.00" "1920x1080_10.00" "1920x1200_10.00" "1440x900_10.00" "1200x800_10.00" "1024x768_10.00" | ||
|
||
| EndSubSection | ||
| EndSection | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ go.work | |
|
|
||
| .tmp/ | ||
| bin/ | ||
| chromium-launcher | ||
| recordings/ | ||
|
|
||
| # downconverted openapi spec | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,15 @@ import ( | |
|
|
||
| var nameRegex = regexp.MustCompile(`^[A-Za-z0-9._-]{1,255}$`) | ||
|
|
||
| const ( | ||
| // chromiumFlagsPath is the runtime flags file read by the chromium-launcher at startup. | ||
| chromiumFlagsPath = "/chromium/flags" | ||
|
|
||
| // appModeURL is the URL loaded in --app mode for small viewports. Keep in | ||
| // sync with "NewTabPageLocation" in shared/chromium-policies/managed/policy.json. | ||
| appModeURL = "https://start.duckduckgo.com" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. URL trailing slash mismatch with policy fileLow Severity The |
||
| ) | ||
|
|
||
| // UploadExtensionsAndRestart handles multipart upload of one or more extension zips, extracts | ||
| // them under /home/kernel/extensions/<name>, writes /chromium/flags to enable them, restarts | ||
| // Chromium via supervisord, and waits (via UpstreamManager) until DevTools is ready. | ||
|
|
@@ -291,14 +300,12 @@ func (s *ApiService) UploadExtensionsAndRestart(ctx context.Context, request oap | |
| } | ||
|
|
||
| // mergeAndWriteChromiumFlags reads existing flags, merges them with new flags, | ||
| // and writes the result back to /chromium/flags. Returns the merged tokens or an error. | ||
| // and writes the result back to chromiumFlagsPath. Returns the merged tokens or an error. | ||
| func (s *ApiService) mergeAndWriteChromiumFlags(ctx context.Context, newTokens []string) ([]string, error) { | ||
| log := logger.FromContext(ctx) | ||
|
|
||
| const flagsPath = "/chromium/flags" | ||
|
|
||
| // Read existing runtime flags from /chromium/flags (if any) | ||
| existingTokens, err := chromiumflags.ReadOptionalFlagFile(flagsPath) | ||
| // Read existing runtime flags (if any) | ||
| existingTokens, err := chromiumflags.ReadOptionalFlagFile(chromiumFlagsPath) | ||
| if err != nil { | ||
| log.Error("failed to read existing flags", "error", err) | ||
| return nil, fmt.Errorf("failed to read existing flags: %w", err) | ||
|
|
@@ -309,22 +316,27 @@ func (s *ApiService) mergeAndWriteChromiumFlags(ctx context.Context, newTokens [ | |
| // Merge existing flags with new flags using token-aware API | ||
| mergedTokens := chromiumflags.MergeFlags(existingTokens, newTokens) | ||
|
|
||
| // Ensure the chromium directory exists | ||
| if err := os.MkdirAll("/chromium", 0o755); err != nil { | ||
| log.Error("failed to create chromium dir", "error", err) | ||
| return nil, fmt.Errorf("failed to create chromium dir: %w", err) | ||
| } | ||
|
|
||
| // Write flags file with merged flags | ||
| if err := chromiumflags.WriteFlagFile(flagsPath, mergedTokens); err != nil { | ||
| if err := writeChromiumFlags(mergedTokens); err != nil { | ||
| log.Error("failed to write flags", "error", err) | ||
| return nil, fmt.Errorf("failed to write flags: %w", err) | ||
| return nil, err | ||
| } | ||
|
|
||
| log.Info("flags written", "merged", mergedTokens) | ||
| return mergedTokens, nil | ||
| } | ||
|
|
||
| // writeChromiumFlags ensures the /chromium directory exists and writes tokens | ||
| // to chromiumFlagsPath. Shared by mergeAndWriteChromiumFlags and ensureAppMode. | ||
| func writeChromiumFlags(tokens []string) error { | ||
| if err := os.MkdirAll("/chromium", 0o755); err != nil { | ||
| return fmt.Errorf("failed to create chromium dir: %w", err) | ||
| } | ||
| if err := chromiumflags.WriteFlagFile(chromiumFlagsPath, tokens); err != nil { | ||
| return fmt.Errorf("failed to write flags file: %w", err) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // restartChromiumAndWait restarts Chromium via supervisorctl and waits for DevTools to be ready. | ||
| // Returns an error if the restart fails or times out. | ||
| func (s *ApiService) restartChromiumAndWait(ctx context.Context, operation string) error { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,3 +34,4 @@ func TestExecLookPath(t *testing.T) { | |
| t.Fatalf("execLookPath PATH search failed: p=%q err=%v", p, err) | ||
| } | ||
| } | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.