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

View File

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