Skip to content

Instantly share code, notes, and snippets.

@jjam3774
Last active August 29, 2015 14:03
Show Gist options
  • Save jjam3774/c1ebb9c2bc7ec90930a1 to your computer and use it in GitHub Desktop.
Save jjam3774/c1ebb9c2bc7ec90930a1 to your computer and use it in GitHub Desktop.
Using Zenity with Ruby to show the use of the progress bar
#!/usr/bin/ruby
def service_agent
e = IO.popen('zenity --height=250 \
--list \
--checklist \
--column "restart" \
--column "service" \
TRUE mysql TRUE apache2 FALSE postfix FALSE puppet'
).each{|i|
choice = i.split('|')
choice.each{ |s| block_given? ? (yield s) : (`zenity \
--error \
--text="No Block Given"`) }
}
end
service_agent{|service|
IO.popen("service #{service.chomp} restart | zenity \
--progress \
--pulsate \
--auto-close \
--text=\"Restarting #{service.chomp}\""
).each{|po| puts po}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment