Compare commits

...

2 Commits

Author SHA1 Message Date
143830ce27
Improve hammerspoon workspace management 2025-03-20 11:12:28 +01:00
a12585068a
Update veracode aws cli 2025-03-20 11:11:46 +01:00
2 changed files with 289 additions and 50 deletions

View File

@ -1,10 +1,9 @@
return (function() return (function()
local application = hs.application
local grid = hs.grid local grid = hs.grid
local screen = hs.screen local screen = hs.screen
local spaces = hs.spaces local spaces = hs.spaces
local timer = hs.timer local timer = hs.timer
local wf = hs.window.filter local window = hs.window
spoon = { spoon = {
name = "C3C Workspace"; name = "C3C Workspace";
@ -33,8 +32,7 @@ return (function()
fullscreen = true, fullscreen = true,
}, },
["zoom.us"] = { ["zoom.us"] = {
desktop = 2, screen = "B5A65BB6-E73E-4C3D-977C-33C86798AA5A",
screen = "D3142823-261D-46EF-B9C2-5181C7FE2CA5",
fullscreen = true, fullscreen = true,
}, },
["Microsoft Outlook"] = { ["Microsoft Outlook"] = {
@ -65,45 +63,30 @@ return (function()
local currentSpaces = spaces.allSpaces() local currentSpaces = spaces.allSpaces()
local foundWindows = {} for _, v in pairs(window.list()) do
local def = appScreenMap[v.kCGWindowOwnerName]
for appName, def in pairs(appScreenMap) do local win = window.get(v.kCGWindowNumber)
local scr = screens[def.screen] if def ~= nil and win ~= nil then
if scr ~= nil then if def.desktop ~= nil and currentSpaces[def.screen] ~= nil then
local app = application.get(appName) print(v.kCGWindowOwnerName .. " moving window into an index " .. def.desktop .. " which is space " .. currentSpaces[def.screen][def.desktop])
if app then
local appFilter = wf.new(appName)
if appFilter then
-- TODO: Really bad performance
foundWindows[appName] = appFilter:getWindows()
end
end
end
end
for appName, windows in pairs(foundWindows) do
local def = appScreenMap[appName]
local scr = screens[def.screen]
for _, win in pairs(windows) do
if currentSpaces[def.screen] ~= nil then
print(appName .. " moving window into an index " .. def.desktop .. " which is space " .. currentSpaces[def.screen][def.desktop])
spaces.moveWindowToSpace(win, currentSpaces[def.screen][def.desktop]) spaces.moveWindowToSpace(win, currentSpaces[def.screen][def.desktop])
end end
print(appName .. " scheduling timer to move window into a screen") local scr = screens[def.screen]
timer.doAfter(1, function() if scr ~= nil then
print(appName .. " moving window into a screen " .. def.screen) timer.doAfter(1, function()
print(v.kCGWindowOwnerName .. " moving window into a screen " .. def.screen)
win:moveToScreen(scr) win:moveToScreen(scr)
if def.fullscreen then if def.fullscreen then
timer.doAfter(1, function() timer.doAfter(1, function()
print(appName .. " fullscreening window") print(v.kCGWindowOwnerName .. " fullscreening window")
fullscreen(win) fullscreen(win)
end) end)
end end
end) end)
end
end end
end end
end end

View File

@ -222,6 +222,188 @@ let
role = "EngineerAdmin"; role = "EngineerAdmin";
}; };
}; };
old-world = {
"932961976631" = {
name = "Veracode Laputa";
role = "EngineerAdmin";
};
"747166839737" = {
name = "Alternator Prod";
role = "EngineerAdmin";
};
"849762296401" = {
name = "aws-cloudloop";
role = "EngineerAdmin";
};
"555828001259" = {
name = "aws-devops";
role = "EngineerAdmin";
};
"095180515219" = {
name = "aws-disco-dev";
role = "EngineerAdmin";
};
"602400992919" = {
name = "aws-disco-prod";
role = "EngineerAdmin";
};
"671440995558" = {
name = "aws-mpt";
role = "EngineerAdmin";
};
"390809507444" = {
name = "aws-research";
role = "EngineerAdmin";
};
"547681985753" = {
name = "aws-static-dev";
role = "EngineerAdmin";
};
"576836758243" = {
name = "aws-static-prod";
role = "EngineerAdmin";
};
"272739225222" = {
name = "Greenlight Dev";
role = "EngineerAdmin";
};
"187309115203" = {
name = "Greenlight Prod";
role = "EngineerAdmin";
};
"312566581319" = {
name = "mvsa-prod";
role = "EngineerAdmin";
};
"528304698271" = {
name = "ops1";
role = "EngineerAdmin";
};
"178484873978" = {
name = "ops2";
role = "EngineerAdmin";
};
"036935693235" = {
name = "platform-integrations-dev";
role = "EngineerAdmin";
};
"101042440253" = {
name = "platform-integrations-prod";
role = "EngineerAdmin";
};
"769404944768" = {
name = "Veracode GovCloud Parent Staging";
role = "EngineerAdmin";
};
"227458413628" = {
name = "veracode-asc-ilt";
role = "EngineerAdmin";
};
"637659597440" = {
name = "veracode-dataservices-dev";
role = "EngineerAdmin";
};
"360252896736" = {
name = "veracode-dataservices-production";
role = "EngineerAdmin";
};
"634743813634" = {
name = "veracode-elearning-nonprod";
role = "EngineerAdmin";
};
"231131777030" = {
name = "veracode-gov-parent-nonproduction";
role = "EngineerAdmin";
};
"391700338873" = {
name = "veracode-gov-parent-production";
role = "EngineerAdmin";
};
"083679226615" = {
name = "veracode-hackathon";
role = "EngineerAdmin";
};
"228885042232" = {
name = "veracode-info-sec";
role = "EngineerAdmin";
};
"653330403905" = {
name = "veracode-mpt-mffc";
role = "EngineerAdmin";
};
"566201213358" = {
name = "veracode-nonproduction";
role = "EngineerAdmin";
};
"518031149952" = {
name = "veracode-production";
role = "EngineerAdmin";
};
"966752150300" = {
name = "veracode-qaoncloud-nonproduction";
role = "EngineerAdmin";
};
"221433242586" = {
name = "veracode-solutions-architect";
role = "EngineerAdmin";
};
"576647558819" = {
name = "VeraRadio";
role = "EngineerAdmin";
};
};
longbow = {
"520315734741" = {
name = "Audit";
role = "AWS-Engineer-Admin";
};
"853528449373" = {
name = "demo";
role = "AWS-Engineer-Admin";
};
"058887878640" = {
name = "Dev";
role = "AWS-Engineer-Admin";
};
"539590419140" = {
name = "Hans Gruber";
role = "AWS-Engineer-Admin";
};
"048352314288" = {
name = "Log archive";
role = "AWS-Engineer-Admin";
};
"066179854877" = {
name = "Production";
role = "AWS-Engineer-Admin";
};
"388353868666" = {
name = "SaaS Seller Account";
role = "AWS-Engineer-Admin";
};
"057168112839" = {
name = "Sandbox";
role = "AWS-Engineer-Admin";
};
"704459292453" = {
name = "Shared Services";
role = "AWS-Engineer-Admin";
};
"108911762463" = {
name = "Staging";
role = "AWS-Engineer-Admin";
};
"252894127310" = {
name = "TalonX";
role = "AWS-Engineer-Admin";
};
"932480454180" = {
name = "Test Customer";
role = "AWS-Engineer-Admin";
};
};
}; };
in in
{ {
@ -240,16 +422,26 @@ in
sso_region = eu-central-1 sso_region = eu-central-1
sso_registration_scopes = sso:account:access sso_registration_scopes = sso:account:access
[sso-session veracode-old-world]
sso_start_url = https://d-90679ac9ea.awsapps.com/start
sso_region = us-east-1
sso_registration_scopes = sso:account:access
[sso-session veracode-longbow]
sso_start_url = https://d-90677f445e.awsapps.com/start
sso_region = eu-central-1
sso_registration_scopes = sso:account:access
${builtins.concatStringsSep "\n" ( ${builtins.concatStringsSep "\n" (
lib.mapAttrsToList (id: account: '' lib.mapAttrsToList (id: account: ''
[profile ${account.name}] [profile ${builtins.replaceStrings [ " " ] [ "" ] account.name}]
sso_account_id = ${id} sso_account_id = ${id}
sso_role_name = ${account.role} sso_role_name = ${account.role}
sso_session = veracode-us sso_session = veracode-us
region = us-east-1 region = us-east-1
output = json output = json
[profile us-${account.name}] [profile us-${builtins.replaceStrings [ " " ] [ "" ] account.name}]
sso_account_id = ${id} sso_account_id = ${id}
sso_role_name = ${account.role} sso_role_name = ${account.role}
sso_session = veracode-us sso_session = veracode-us
@ -260,16 +452,21 @@ in
${builtins.concatStringsSep "\n" ( ${builtins.concatStringsSep "\n" (
lib.mapAttrsToList (id: account: '' lib.mapAttrsToList (id: account: ''
${if lib.any (usAccount: usAccount.name == account.name) (lib.attrValues accounts.us) then "" else '' ${
[profile ${account.name}] if lib.any (usAccount: usAccount.name == account.name) (lib.attrValues accounts.us) then
sso_account_id = ${id} ""
sso_role_name = ${account.role} else
sso_session = veracode-eu ''
region = eu-central-1 [profile ${builtins.replaceStrings [ " " ] [ "" ] account.name}]
output = json sso_account_id = ${id}
''} sso_role_name = ${account.role}
sso_session = veracode-eu
region = eu-central-1
output = json
''
}
[profile eu-${account.name}] [profile eu-${builtins.replaceStrings [ " " ] [ "" ] account.name}]
sso_account_id = ${id} sso_account_id = ${id}
sso_role_name = ${account.role} sso_role_name = ${account.role}
sso_session = veracode-eu sso_session = veracode-eu
@ -277,6 +474,64 @@ in
output = json output = json
'') accounts.eu '') accounts.eu
)} )}
${builtins.concatStringsSep "\n" (
lib.mapAttrsToList (id: account: ''
${
if
lib.any (otherAccount: otherAccount.name == account.name) (
lib.attrValues (accounts.us // accounts.eu)
)
then
""
else
''
[profile ${builtins.replaceStrings [ " " ] [ "" ] account.name}]
sso_account_id = ${id}
sso_role_name = ${account.role}
sso_session = veracode-old-world
region = eu-central-1
output = json
''
}
[profile old-world-${builtins.replaceStrings [ " " ] [ "" ] account.name}]
sso_account_id = ${id}
sso_role_name = ${account.role}
sso_session = veracode-old-world
region = eu-central-1
output = json
'') accounts.old-world
)}
${builtins.concatStringsSep "\n" (
lib.mapAttrsToList (id: account: ''
${
if
lib.any (otherAccount: otherAccount.name == account.name) (
lib.attrValues (accounts.us // accounts.eu // accounts.old-world)
)
then
""
else
''
[profile ${builtins.replaceStrings [ " " ] [ "" ] account.name}]
sso_account_id = ${id}
sso_role_name = ${account.role}
sso_session = veracode-longbow
region = eu-central-1
output = json
''
}
[profile longbow-${builtins.replaceStrings [ " " ] [ "" ] account.name}]
sso_account_id = ${id}
sso_role_name = ${account.role}
sso_session = veracode-longbow
region = eu-central-1
output = json
'') accounts.longbow
)}
''; '';
}; };
@ -304,8 +559,9 @@ in
veracode-login = ''${pkgs.writeShellScript "veracode-login" '' veracode-login = ''${pkgs.writeShellScript "veracode-login" ''
for region in us eu; do for region in us eu; do
aws sso login --profile $region-shared-services aws sso login --profile $region-shared-services &
done done
aws sso login --profile old-world-aws-devops &
''}''; ''}'';
}; };
} }