Skip to content

Commit c62a3ef

Browse files
committed
more screensaver madness
1 parent 35521a9 commit c62a3ef

File tree

2 files changed

+62
-27
lines changed

2 files changed

+62
-27
lines changed

cmd/agent/checks.yaml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -216,23 +216,23 @@ checks:
216216
- Configure LXQt screen locking
217217
- Set lockScreenCommand in ~/.config/lxqt/session.conf
218218
- Install a screen locker like light-locker, xscreensaver, or xlock
219-
# LXDE - Only check if LXDE session is running
220-
- output: pgrep lxsession >/dev/null && (command -v light-locker || command -v xscreensaver || command -v xlock)
221-
exitcode: 1
219+
# LXDE - Check if a screen locker is actually running
220+
- output: pgrep lxsession >/dev/null && pgrep -l "light-locker|xscreensaver|xautolock|i3lock|slock|xlock"
221+
excludes: "light-locker|xscreensaver|xautolock|i3lock|slock|xlock"
222222
remediation:
223-
- Install a screen locker for LXDE
224-
- "Linux/FreeBSD: Install light-locker or xscreensaver"
225-
- "OpenBSD/NetBSD: Install xlock from packages"
226-
# i3 Window Manager - Only check if i3 is running
227-
- output: pgrep i3 >/dev/null && (grep "i3lock\|xautolock\|xss-lock" ~/.config/i3/config 2>/dev/null || grep "i3lock\|xautolock\|xss-lock" ~/.i3/config 2>/dev/null)
228-
excludes: "i3lock|xautolock|xss-lock"
223+
- No screen locker is running for LXDE
224+
- Install and configure a screen locker (light-locker, xscreensaver, or xautolock)
225+
- Add to ~/.config/lxsession/LXDE/autostart or ~/.config/autostart/
226+
# i3 Window Manager - Check if screen locker is running
227+
- output: pgrep i3 >/dev/null && pgrep -l "xautolock|xss-lock|xidlehook"
228+
excludes: "xautolock|xss-lock|xidlehook"
229229
remediation:
230230
- Install and configure screen locking for i3
231231
- "Install locker: i3lock, slock, or xlock (varies by OS)"
232232
- "Add to i3 config: 'exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock -n'"
233-
# Openbox Window Manager - Only check if openbox is running
234-
- output: pgrep openbox >/dev/null && grep "xautolock\|xss-lock" ~/.config/openbox/autostart 2>/dev/null
235-
excludes: "xautolock|xss-lock"
233+
# Openbox Window Manager - Check if screen locker is running
234+
- output: pgrep openbox >/dev/null && pgrep -l "xautolock|xss-lock|light-locker"
235+
excludes: "xautolock|xss-lock|light-locker"
236236
remediation:
237237
- Configure screen locking for Openbox
238238
- "Add to ~/.config/openbox/autostart: 'xautolock -time 15 -locker \"i3lock -c 000000\" &'"
@@ -324,27 +324,27 @@ checks:
324324
remediation:
325325
- Set LXQt idle timeout to 15 minutes (900000 ms) or less
326326
- Configure in LXQt System Settings > Power Management
327-
# LXDE - Only check timeout if LXDE session is running
328-
- output: pgrep lxsession >/dev/null && (grep "sleep_display_ac" ~/.config/lxsession/LXDE/desktop.conf 2>/dev/null || grep "sleep_display_ac" /etc/xdg/lxsession/LXDE/desktop.conf 2>/dev/null)
329-
includes: "sleep_display_ac.*([1-9][6-9]|[2-9][0-9]|[1-9][0-9]{2,})"
327+
# LXDE - Check if xautolock is running with proper timeout
328+
- output: pgrep lxsession >/dev/null && pgrep -fl "xautolock.*-time"
329+
includes: "-time (1[6-9]|[2-9][0-9]|[1-9][0-9]{2,})"
330330
remediation:
331-
- Set LXDE display sleep to 15 minutes or less
332-
- Edit ~/.config/lxsession/LXDE/desktop.conf and set sleep_display_ac=15
331+
- Configure xautolock with 15 minute timeout or less
332+
- "Add to autostart: 'xautolock -time 15 -locker \"light-locker\" &'"
333333
# Sway - Only check timeout if sway is running
334334
- output: pgrep sway >/dev/null && grep "timeout" ~/.config/sway/config 2>/dev/null
335335
includes: "timeout [9][1-9][0-9][0-9]|timeout [1-9][0-9]{4,}"
336336
remediation:
337337
- Configure swayidle timeout to 15 minutes (900 seconds) or less
338338
- "Add to Sway config: 'exec swayidle -w timeout 900 \"swaylock -f\"'"
339-
# i3 Window Manager - Only check timeout if i3 is running
340-
- output: pgrep i3 >/dev/null && (grep "xautolock.*-time" ~/.config/i3/config 2>/dev/null || grep "xautolock.*-time" ~/.i3/config 2>/dev/null)
341-
includes: "-time [1-9][6-9]|-time [2-9][0-9]|-time [1-9][0-9]{2,}"
339+
# i3 Window Manager - Check if xautolock is running with proper timeout
340+
- output: pgrep i3 >/dev/null && pgrep -fl "xautolock.*-time"
341+
includes: "-time (1[6-9]|[2-9][0-9]|[1-9][0-9]{2,})"
342342
remediation:
343343
- Configure xautolock timeout to 15 minutes or less
344344
- "Add to i3 config: 'exec --no-startup-id xautolock -time 15 -locker \"i3lock -c 000000\"'"
345-
# Openbox - Only check timeout if openbox is running
346-
- output: pgrep openbox >/dev/null && grep "xautolock.*-time" ~/.config/openbox/autostart 2>/dev/null
347-
includes: "-time [1-9][6-9]|-time [2-9][0-9]|-time [1-9][0-9]{2,}"
345+
# Openbox - Check if xautolock is running with proper timeout
346+
- output: pgrep openbox >/dev/null && pgrep -fl "xautolock.*-time"
347+
includes: "-time (1[6-9]|[2-9][0-9]|[1-9][0-9]{2,})"
348348
remediation:
349349
- Configure xautolock timeout to 15 minutes or less
350350
- "Add to ~/.config/openbox/autostart: 'xautolock -time 15 -locker \"i3lock -c 000000\" &'"

cmd/agent/main.go

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,18 +1017,29 @@ func (*Agent) displayFailedChecks(results map[string]CheckResult, finalOrder []s
10171017
// Show evidence - command and output for failed checks
10181018
if len(result.Outputs) > 0 {
10191019
printLine(" 💻 Evidence:")
1020-
for _, output := range result.Outputs {
1020+
failedCount := 0
1021+
for i, output := range result.Outputs {
10211022
// Skip outputs that didn't fail
10221023
if !output.Failed {
10231024
continue
10241025
}
1026+
failedCount++
1027+
1028+
// If multiple commands were checked, number them
1029+
if len(result.Outputs) > 1 {
1030+
printLine(" [Command %d of %d - FAILED]", i+1, len(result.Outputs))
1031+
}
10251032

10261033
// Show command or file that was checked
10271034
if output.Command != "" {
10281035
printLine(" Command: %s", output.Command)
10291036
} else if output.File != "" {
10301037
printLine(" File: %s", output.File)
10311038
}
1039+
// Show why it failed
1040+
if output.FailReason != "" {
1041+
printLine(" Failure: %s", output.FailReason)
1042+
}
10321043

10331044
// Show relevant output (truncated for readability)
10341045
if output.Stdout != "" {
@@ -1045,6 +1056,16 @@ func (*Agent) displayFailedChecks(results map[string]CheckResult, finalOrder []s
10451056
if output.Stderr != "" && output.Stderr != output.FailReason {
10461057
printLine(" Error: %s", output.Stderr)
10471058
}
1059+
1060+
// Add spacing between multiple failed commands
1061+
if failedCount < len(result.Outputs) && len(result.Outputs) > 1 {
1062+
for j := i + 1; j < len(result.Outputs); j++ {
1063+
if result.Outputs[j].Failed {
1064+
printLine("")
1065+
break
1066+
}
1067+
}
1068+
}
10481069
}
10491070
}
10501071

@@ -1098,7 +1119,18 @@ func (*Agent) displayAllChecks(results map[string]CheckResult, checkOrder []stri
10981119
printLine("───────────────────────────────────────────────────────────────")
10991120

11001121
// Show all command outputs
1101-
for _, output := range result.Outputs {
1122+
for i, output := range result.Outputs {
1123+
// Show command number if multiple
1124+
if len(result.Outputs) > 1 {
1125+
status := "OK"
1126+
if output.Failed {
1127+
status = "FAILED"
1128+
} else if output.Skipped || output.FileMissing {
1129+
status = "SKIPPED"
1130+
}
1131+
printLine("[Command %d of %d - %s]", i+1, len(result.Outputs), status)
1132+
}
1133+
11021134
if output.Command != "" {
11031135
printLine("Command: %s", output.Command)
11041136
} else if output.File != "" {
@@ -1137,9 +1169,12 @@ func (*Agent) displayAllChecks(results map[string]CheckResult, checkOrder []stri
11371169
}
11381170
}
11391171

1140-
if output.Failed {
1172+
switch {
1173+
case output.Failed:
11411174
printLine("Status: FAILED - %s", output.FailReason)
1142-
} else {
1175+
case output.Skipped, output.FileMissing:
1176+
printLine("Status: SKIPPED")
1177+
default:
11431178
printLine("Status: OK")
11441179
}
11451180
printLine("")

0 commit comments

Comments
 (0)