mirror of
https://github.com/munki/munki.git
synced 2026-05-14 16:28:58 -05:00
Add currentGUIUsers() function
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// SignalHandler.swift
|
||||
// munki
|
||||
//
|
||||
// Created by Greg Neagle on 9/4/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// UNIXProcessInfo.swift
|
||||
// munki
|
||||
//
|
||||
// Created by Greg Neagle on 9/4/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@@ -36,6 +36,21 @@ func getConsoleUser() -> String {
|
||||
return SCDynamicStoreCopyConsoleUser(nil, nil, nil) as? String ?? ""
|
||||
}
|
||||
|
||||
func currentGUIUsers() -> [String] {
|
||||
// Gets a list of GUI users by parsing the output of /usr/bin/who
|
||||
var guiUsers = [String]()
|
||||
let result = runCLI("/usr/bin/who")
|
||||
for line in result.output.components(separatedBy: .newlines) {
|
||||
let parts = line.components(separatedBy: .whitespaces).filter {
|
||||
!$0.isEmpty
|
||||
}
|
||||
if parts.count > 1, parts[1] == "console" {
|
||||
guiUsers.append(parts[0])
|
||||
}
|
||||
}
|
||||
return guiUsers
|
||||
}
|
||||
|
||||
func getIdleSeconds() -> Int {
|
||||
// Returns the number of seconds since the last mouse
|
||||
// or keyboard event.
|
||||
|
||||
Reference in New Issue
Block a user