mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
19 lines
378 B
Ruby
19 lines
378 B
Ruby
![]() |
require "delegate"
|
||
|
require "etc"
|
||
|
|
||
|
require "system_command"
|
||
|
|
||
|
class User < DelegateClass(String)
|
||
|
def gui?
|
||
|
out, _, status = system_command "who"
|
||
|
return false unless status.success?
|
||
|
out.lines
|
||
|
.map(&:split)
|
||
|
.any? { |user, type,| user == self && type == "console" }
|
||
|
end
|
||
|
|
||
|
def self.current
|
||
|
@current ||= new(Etc.getpwuid(Process.euid).name)
|
||
|
end
|
||
|
end
|