Skip to content

Commit 14e3d4f

Browse files
authored
Update main.cr
1 parent f23dcde commit 14e3d4f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

HackerOS-Updater/main.cr

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,15 @@ def show_gui_menu
123123
puts "[L]og out - Log out from current session"
124124
puts "[T]erminal - Open a new Alacritty terminal"
125125
puts "[A]utomatic Updates - Enable automatic updates on boot"
126-
print "Enter your choice: "
127-
choice = gets.try(&.chomp.upcase)
126+
print "Enter your choice (press key without Enter): "
127+
choice = ""
128+
STDIN.raw do |io|
129+
byte = io.read_byte
130+
if byte
131+
choice = byte.chr.to_s.upcase
132+
puts choice # Echo the choice
133+
end
134+
end
128135
case choice
129136
when "Q"
130137
exit(0)
@@ -133,8 +140,8 @@ def show_gui_menu
133140
when "S"
134141
run_command("sudo shutdown -h now")
135142
when "L"
136-
# Assuming a desktop environment like GNOME or KDE; adjust if needed
137-
run_command("gnome-session-quit --logout --no-prompt") # or qdbus org.kde.ksmserver /KSMServer logout 0 0 0 for KDE
143+
# For KDE
144+
run_command("qdbus org.kde.ksmserver /KSMServer logout 0 0 0")
138145
when "T"
139146
Process.new("alacritty", input: Process::Redirect::Close, output: Process::Redirect::Close, error: Process::Redirect::Close)
140147
when "A"

0 commit comments

Comments
 (0)