-
-
Save dgfitch/179125 to your computer and use it in GitHub Desktop.
This file contains 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 | |
$LOAD_PATH << "/home/dan/.ratpoison" | |
begin | |
require 'ratpoison' | |
frame = Ratpoison.current_frame | |
width = frame.width | |
height = frame.height | |
title = Ratpoison.current_window.title | |
current_host = title.sub(/rdesktop - /, "").strip | |
rescue Exception => ex | |
puts "Ratpoison error: #{ex}" | |
width = 1600 | |
height = 1200 | |
end | |
hosts = { | |
"wrk31773-v6" => ['-d WISLEG -u dfitch'], | |
"wrk002v" => ['-d WISLEG -u svc_folio'], | |
"wrk007v" => ['-d WISLEG -u svc_folio'], | |
"wrk31047" => ['-d WISLEG -u svc_folio'], | |
"svr021" => ['-d WISLEG -u dfitcha'], | |
"svr038v" => ['-d WISLEG -u dfitcha'], | |
"svr044v" => ['-d WISLEG -u dfitcha'], | |
"test-runner" => ['-d WISLEG -u sra', '10.191.129.81'], | |
"test-dev" => ['-d WISLEG -u sra', '10.191.129.89'], | |
"test-room" => ['-d WISLEG -u sra', '10.191.129.13'], | |
} | |
if ARGV[0] then | |
o = ARGV[0] | |
else | |
command = "ratmenu " + | |
hosts.keys.sort.map { |p| "'#{p}' 'echo #{p}'" }.join(" ") | |
o = `#{command}`.chomp | |
end | |
exit if !o or o == "" | |
name = o | |
if o == "resize" | |
o = current_host | |
name = current_host | |
puts "current host: " + current_host | |
Ratpoison.close_window | |
sleep 1 | |
end | |
host = hosts[o] | |
if host | |
options = host[0] || '-d WISLEG -u dfitcha' | |
ip = host[1] || name | |
else | |
options = '-d WISLEG -u dfitcha' | |
ip = name | |
end | |
command = "rdesktop -a 32 -K -z -y -g #{width}x#{height} #{options} #{ip}" | |
#command = "rdesktop -a 32 -x 0x80 -K -g #{width}x#{height} #{options} #{ip}" | |
cred = | |
case options | |
when /dfitcha/: "~/.credentialsa" | |
when /dfitch/: "~/.credentials" | |
when /svc_folio/: "~/.credentialsf" | |
when /sra/: "~/.credentialss" | |
end | |
puts command | |
if cred then | |
password_pipe = "cat #{cred} | tail -1 | awk '{sub(/password=/,\"\");print}' | " | |
exec password_pipe + command + " -p -" | |
else | |
exec command | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment