Last active
August 29, 2015 14:03
-
-
Save jjam3774/c1ebb9c2bc7ec90930a1 to your computer and use it in GitHub Desktop.
Using Zenity with Ruby to show the use of the progress bar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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