Start cthulhu in laptop layout with -l.
This commit is contained in:
1 parent
7723bd7e09
commit
d8b59aa05b
10 files changed
+259
-5
No files matched your search
@@ -71,6 +71,7 @@ func run(ctx context.Context, arguments []string, stdout, stderr io.Writer) (res
|
||||
greeter := options.String("greeter", "", "copy the saved active profile to a greeter account and exit (supported: lightdm)")
|
||||
shortSettings := options.Bool("s", false, "open the preferences window at startup")
|
||||
settingsFlag := options.Bool("settings", false, "open the preferences window at startup")
|
||||
laptopLayout := options.Bool("l", false, "start with laptop layout and Caps Lock as the Cthulhu key for this session")
|
||||
preferencesUI := options.Bool("preferences-ui", false, "run the internal preferences helper (private pipe protocol)")
|
||||
notificationListUI := options.Bool("notification-list-ui", false, "run the internal notification list helper (private pipe protocol)")
|
||||
speechHistoryUI := options.Bool("speech-history-ui", false, "run the internal speech history helper (private pipe protocol)")
|
||||
@@ -248,6 +249,7 @@ func run(ctx context.Context, arguments []string, stdout, stderr io.Writer) (res
|
||||
TentacleCgroupParent: *tentacleParent,
|
||||
EnableRemote: true,
|
||||
OpenPreferences: *shortSettings || *settingsFlag,
|
||||
LaptopLayout: *laptopLayout,
|
||||
Logger: logger,
|
||||
SpeechSocket: *speechSocket,
|
||||
Settings: &settings,
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.stormux.org/storm/cthulhu/internal/atspi"
|
||||
"git.stormux.org/storm/cthulhu/internal/config"
|
||||
"git.stormux.org/storm/cthulhu/internal/version"
|
||||
"git.stormux.org/storm/cthulhu/internal/wine"
|
||||
)
|
||||
@@ -62,12 +63,66 @@ func TestHelp(t *testing.T) {
|
||||
}
|
||||
if !strings.HasPrefix(help, versionOutput.String()+"\nUsage: cthulhu [options]\n\nOptions:\n") ||
|
||||
!strings.Contains(help, "-s") || !strings.Contains(help, "-settings") ||
|
||||
!strings.Contains(help, "-l\t") || !strings.Contains(help, "laptop layout") ||
|
||||
!strings.Contains(help, "-r") || !strings.Contains(help, "-replace") {
|
||||
t.Fatalf("help output does not contain expected version, usage, and flags: %q", help)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLaptopStartupDoesNotSaveKeyboard(t *testing.T) {
|
||||
directory := t.TempDir()
|
||||
path := filepath.Join(directory, "settings.toml")
|
||||
store, err := config.NewStore(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
settings := config.DefaultSettings()
|
||||
settings.EnableSound = false
|
||||
if err := store.Save(settings); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
original, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, laptop := range []bool{true, false} {
|
||||
logPath := filepath.Join(directory, "startup.log")
|
||||
arguments := []string{"--config", path, "--debug-file", logPath,
|
||||
"--speech-socket", filepath.Join(directory, "absent.sock")}
|
||||
if laptop {
|
||||
arguments = append(arguments, "-l")
|
||||
}
|
||||
var output bytes.Buffer
|
||||
err := run(t.Context(), arguments, &output, &output)
|
||||
if err == nil || !strings.Contains(err.Error(), "connect to Speech Dispatcher") {
|
||||
t.Fatalf("expected isolated startup failure, got %v", err)
|
||||
}
|
||||
data, err := os.ReadFile(logPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Contains(string(data), `"message":"using temporary laptop keyboard layout"`) != laptop {
|
||||
t.Fatalf("startup laptop override = %t: %s", laptop, data)
|
||||
}
|
||||
current, err := os.ReadFile(path)
|
||||
if err != nil || !bytes.Equal(current, original) {
|
||||
t.Fatalf("startup changed saved profile: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLaptopCheckConfigDoesNotCreateProfile(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "absent.toml")
|
||||
var output bytes.Buffer
|
||||
if err := run(t.Context(), []string{"-l", "--check-config", "--config", path}, &output, &output); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
||||
t.Fatalf("checking built-in defaults created a profile: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckConfig(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "user-settings.toml")
|
||||
contents := []byte("[general]\nstartingProfile = [\"Default\", \"default\"]\n[profiles.default]\nspeakDescription = false\n")
|
||||
|
||||
Reference in new issue
Block a user