I just found this page and grabbed the script for my GeekTool setup. I've never messed with Ruby before, so I thought I'd try a few tweaks. JSON support is now apparently built into Ruby, and even though the output of tmutil status is a plist, MacOS has a utility that can convert plist output to JSON. This also shortens the code a little, and removes the need for matches and regexes.
#!/usr/bin/rubyrequire'json'plist=JSON.parse(%x{tmutil status | sed '1d' | plutil -convert json - -o -})ALPHABET=%w{ a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y }ifplist["Running"]=1unlessplist["Percent"].nil?printALPHABET[((plist["percent"].to_f*100)/2).to_i]elseprint""endend
Comments
I just found this page and grabbed the script for my GeekTool setup. I've never messed with Ruby before, so I thought I'd try a few tweaks. JSON support is now apparently built into Ruby, and even though the output of
tmutil statusis a plist, MacOS has a utility that can convert plist output to JSON. This also shortens the code a little, and removes the need for matches and regexes.export
Brilliant work :)
export