Skip to content
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

updating for scaling #120

Merged
merged 1 commit into from
Mar 7, 2024
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ NOTE: Flags with parameters should use an "equals"
Top Left Position of Kiosk (default "0,0")
-window-size string
Size of Kiosk in pixels (e.g. "1920,1080")
-scale-factor string
Scale factor of Kiosk. This is sort of like zoom. (default: "1")
```

### Using a configuration file
Expand All @@ -124,6 +126,7 @@ general:
autofit: true
lxde: true
lxde-home: /home/pi
scale-factor: 1.0

target:
login-method: anon
Expand Down Expand Up @@ -154,6 +157,8 @@ They can also be used instead of a configuration file.
Top Left Position of Kiosk (default "0,0")
KIOSK_WINDOW_SIZE string
Size of Kiosk in pixels (e.g. "1920,1080")
KIOSK_SCALE_FACTOR string
Scale factor, like zoom
KIOSK_IGNORE_CERTIFICATE_ERRORS bool
Ignore SSL/TLS certificate errors (default "false")
KIOSK_IS_PLAYLIST bool
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/grafana-kiosk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Args struct {
PasswordField string
WindowPosition string
WindowSize string
ScaleFactor string
}

// ProcessArgs processes and handles CLI arguments.
Expand All @@ -56,6 +57,7 @@ func ProcessArgs(cfg interface{}) Args {
flagSettings.StringVar(&processedArgs.URL, "URL", "https://play.grafana.org", "URL to Grafana server")
flagSettings.StringVar(&processedArgs.WindowPosition, "window-position", "0,0", "Top Left Position of Kiosk")
flagSettings.StringVar(&processedArgs.WindowSize, "window-size", "", "Size of Kiosk in pixels (width,height)")
flagSettings.StringVar(&processedArgs.ScaleFactor, "scale-factor", "1.0", "Scale factor, sort of zoom")
flagSettings.BoolVar(&processedArgs.IsPlayList, "playlists", false, "URL is a playlist")
flagSettings.BoolVar(&processedArgs.AutoFit, "autofit", true, "Fit panels to screen")
flagSettings.BoolVar(&processedArgs.LXDEEnabled, "lxde", false, "Initialize LXDE for kiosk mode")
Expand Down Expand Up @@ -122,6 +124,7 @@ func summary(cfg *kiosk.Config) {
log.Println("Mode:", cfg.General.Mode)
log.Println("WindowPosition:", cfg.General.WindowPosition)
log.Println("WindowSize:", cfg.General.WindowSize)
log.Println("ScaleFactor:", cfg.General.ScaleFactor)
// target
log.Println("URL:", cfg.Target.URL)
log.Println("LoginMethod:", cfg.Target.LoginMethod)
Expand Down
1 change: 1 addition & 0 deletions pkg/kiosk/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config struct {
Mode string `yaml:"kiosk-mode" env:"KIOSK_MODE" env-default:"full" env-description:"[full|tv|disabled]"`
WindowPosition string `yaml:"window-position" env:"KIOSK_WINDOW_POSITION" env-default:"0,0" env-description:"Top Left Position of Kiosk"`
WindowSize string `yaml:"window-size" env:"KIOSK_WINDOW_SIZE" env-default:"" env-description:"Size of Kiosk in pixels (width,height)"`
ScaleFactor string `yaml:"scale-factor" env:"KIOSK_SCALE_FACTOR" env-default:"1.0" env-description:"Scale factor, like zoom"`
} `yaml:"general"`
Target struct {
IgnoreCertificateErrors bool `yaml:"ignore-certificate-errors" env:"KIOSK_IGNORE_CERTIFICATE_ERRORS" env-description:"ignore SSL/TLS certificate errors" env-default:"false"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/kiosk/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,9 @@ func generateExecutorOptions(dir string, cfg *Config) []chromedp.ExecAllocatorOp
execAllocatorOption = append(execAllocatorOption, chromedp.Flag("window-size", cfg.General.WindowSize))
}

if cfg.General.ScaleFactor != "" {
execAllocatorOption = append(execAllocatorOption, chromedp.Flag("force-device-scale-factor", cfg.General.ScaleFactor))
}

return execAllocatorOption
}