Skip to content

Instantly share code, notes, and snippets.

@fiedl
Last active February 17, 2020 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiedl/05b952649b2fd1a2149974cfbd772ef6 to your computer and use it in GitHub Desktop.
Save fiedl/05b952649b2fd1a2149974cfbd772ef6 to your computer and use it in GitHub Desktop.
Before updating to Catalina, export spark scripts

Before updating to macOS Catalina, which drops support for 32-bit apps, I'm exporting my spark scripts. I'm not sure whether spark will be available as 64-bit version. https://github.com/Jean-Daniel/Spark

do shell script "source /Users/fiedl/.zsh/oh-my-zsh-customization/plugins/fiedl/bin/lcars"
# Cmd+Option+L
tell application "System Events" to start current screen saver
try
tell application "Finder" to set the this_folder ¬
to (folder of the front window) as alias
on error -- no open folder windows
set the this_folder to path to desktop folder as alias
end try
set thefilename to "Neue Datei.md"
-- text returned of (display dialog "Create file named:" default answer "filename.txt")
set thefullpath to POSIX path of this_folder & thefilename
do shell script "touch \"" & thefullpath & "\""
# F6
# https://forum.keyboardmaestro.com/t/applescript-click-dock-item-and-trigger-a-menu-item/6773
tell application "System Events"
tell application process "Dock"
tell list 1
tell UI element "ScanSnap Manager"
perform action "AXShowMenu"
tell menu "ScanSnap Manager"
tell menu item "Duplex-Scan"
perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
end tell
# F13
# https://forum.keyboardmaestro.com/t/applescript-click-dock-item-and-trigger-a-menu-item/6773
tell application "System Events"
tell application process "Dock"
tell list 1
tell UI element "ScanSnap Manager"
perform action "AXShowMenu"
tell menu "ScanSnap Manager"
tell menu item "Simplex Scan"
perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
end tell
set activeApp to (path to frontmost application as Unicode text)
tell application activeApp
# get current window width.
# the width will stay the same. we just recalculate the height
# of the window to match the 16:9 aspect ratio.
set window_bounds to the bounds of the first window
set x1 to item 1 of the window_bounds
set y1 to item 2 of the window_bounds
set x2 to item 3 of the window_bounds
set y2 to item 4 of the window_bounds
set window_width to (x2 - x1)
# calculate the new height.
set new_window_height to 9.0 / 16.0 * window_width
# set the window height.
set new_y2 to (new_window_height + y1)
set item 4 of the window_bounds to the new_y2
set the bounds of the first window to the window_bounds
#{x, y, window_width, new_window_height}
#display dialog "width: " & window_width
#display dialog "new height: " & new_window_height
end tell
set activeApp to (path to frontmost application as Unicode text)
-- Screen Resolution
tell application "Finder"
set screenResolution to bounds of window of desktop
end tell
set screenWidth to item 3 of screenResolution
set screenHeight to item 4 of screenResolution
if (screenWidth > 2500) then
set numberOfPresets to 3
else
set numberOfPresets to 2
end if
if (screenWidth > 2560) then
-- dual monitor. just use the large one.
set screenWidth to 2560
set numberOfPresets to 3
end if
-- position preset counter
property positionPreset : 0
set positionPreset to positionPreset + 1
if positionPreset > numberOfPresets then
set positionPreset to 1
end if
tell application activeApp
-- Window Position
set current_position to the bounds of the first window
set current_xposition to item 1 of current_position
activate
set goldenRatio to 0.618
--set win to the first window
set win to the first window whose visible is true
-- External Display Display: 2560
if screenWidth = 2560 then
-- Use 1/3 1/3 1/3 configuration.
if positionPreset is 2 then
set the bounds of win to {1 / 3 * screenWidth, 0, 2 / 3 * screenWidth, screenHeight}
else if positionPreset is 3 then
set the bounds of win to {2 / 3 * screenWidth, 0, 3 / 3 * screenWidth, screenHeight}
else if positionPreset is 1 then
set the bounds of win to {0 / 3 * screenWidth, 0, 1 / 3 * screenWidth, screenHeight}
end if
-- Retina 15 inch display
else
if positionPreset is 1 then
set the bounds of win to {goldenRatio * screenWidth, 0, screenWidth, screenHeight}
else if positionPreset is 2 then
set the bounds of win to {0, 0, goldenRatio * screenWidth, screenHeight}
end if
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment