Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
Bryan Frimin
2026-05-26 14:07:22 -07:00
parent 712f00f434
commit 51f37b9d85
2 changed files with 14 additions and 6 deletions

View File

@@ -93,6 +93,7 @@ func linuxScreenLock(ctx context.Context) Result {
}
anyTool = true
switch result.Status {
case StatusPass, StatusFail:
return result
@@ -173,6 +174,7 @@ func linuxScreenLockGsettings(ctx context.Context, user string) (Result, bool) {
}
val := strings.TrimSpace(out.Stdout)
ev := map[string]any{
"backend": schema.backend,
"schema": schema.schema,
@@ -305,6 +307,7 @@ func linuxScreenLockI3(ctx context.Context, user string) (Result, bool) {
}
idleMinutes, locker, mechanism, ok := parseI3IdleLock(body)
ev := map[string]any{
"backend": "i3",
"config": configPath,
@@ -370,11 +373,13 @@ func linuxReadI3Config(ctx context.Context, user, path string, depth int) string
}
body := string(data)
var merged strings.Builder
merged.WriteString(body)
home := linuxUserHome(ctx, user)
for line := range strings.SplitSeq(body, "\n") {
trimmed := strings.TrimSpace(line)
if trimmed == "" || strings.HasPrefix(trimmed, "#") {
@@ -388,6 +393,7 @@ func linuxReadI3Config(ctx context.Context, user, path string, depth int) string
inc := strings.TrimSpace(trimmed[len("include "):])
inc = strings.Trim(inc, `"`)
inc = linuxExpandHome(inc, home)
if nested := linuxReadI3Config(ctx, user, inc, depth+1); nested != "" {
merged.WriteString("\n")
@@ -468,12 +474,12 @@ func parseXssLockIdleLock(line string) (locker string, ok bool) {
return "", false
}
idx := strings.Index(line, "--")
if idx < 0 {
_, after, ok0 := strings.Cut(line, "--")
if !ok0 {
return "", false
}
locker = strings.TrimSpace(line[idx+2:])
locker = strings.TrimSpace(after)
locker = strings.Trim(locker, `"`)
if locker == "" || !linuxLooksLikeLockCommand(locker) {
return "", false
@@ -508,12 +514,12 @@ func parseXautolockTime(value string) (minutes int, ok bool) {
}
func linuxParseFlagValue(line, flag string) (string, bool) {
idx := strings.Index(line, flag)
if idx < 0 {
_, after, ok := strings.Cut(line, flag)
if !ok {
return "", false
}
rest := strings.TrimSpace(line[idx+len(flag):])
rest := strings.TrimSpace(after)
if rest == "" {
return "", false
}
@@ -566,6 +572,7 @@ func linuxOrderGsettingsSchemas(desktop string) []struct {
seen := make(map[string]struct{}, len(linuxGsettingsLockSchemas))
preferred := ""
switch {
case strings.Contains(desktop, "cinnamon"):
preferred = "cinnamon"

View File

@@ -118,6 +118,7 @@ func TestParseI3IdleLock(t *testing.T) {
idleMins, _, mechanism, ok := parseI3IdleLock(tt.config)
require.Equal(t, tt.wantOK, ok)
if !tt.wantOK {
return
}