Last active
August 4, 2024 23:22
-
-
Save khurshid-alam/ad97338a295b6b507b03a09020f9dd57 to your computer and use it in GitHub Desktop.
//This is javascript action performed by BetterTouchTool when you middle click on any file.
// Basically what it does is, to take hover_element_data & extracting file ref url, //then converting it POSIX url which then passed to shell command "qlmanager -p". // MAke sure to set it to "Trigger on mouse up" & include "Maximum hold time". //This is …
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
//This is javascript action performed by BetterTouchTool when you middle click on any file. | |
// Basically what it does is, to take hover_element_data & extracting file ref url, | |
//then converting it POSIX url which then passed to shell command "qlmanager -p". | |
// MAke sure to set it to "Trigger on mouse up" & include "Maximum hold time". | |
//This is useful if you set double middle click action with minimum hold time. | |
//Here maximum hold time needs to be < minimum hold time of that double middle click action. | |
// To support more files install https://github.com/sbarex/SourceCodeSyntaxHighlight. | |
(async()=>{ | |
AS=s=>(runAppleScript(s)) | |
PA=n=>{trigger_action({json:JSON.stringify({BTTPredefinedActionType:n})})} | |
a=await get_string_variable("hovered_element_details") | |
v=i=>(a.split('AX'+i+': "')[1].split('"')[0]) | |
F=v('Role') | |
// Extract the application name from the URL | |
let refURL = decodeURIComponent(v('URL')).slice(7) | |
if(refURL !== null){ | |
// Use AppleScript to handle the logic for minimizing/unminimizing | |
await AS(` | |
use framework "Foundation" | |
use scripting additions | |
set refURL to "${refURL}" | |
#display dialog refURL | |
set theURL to (current application's class "NSURL"'s fileURLWithPath:refURL) | |
set filePathURL to theURL's filePathURL() | |
set filePath to filePathURL's |path|() as text | |
set fPath to quoted form of POSIX path of filePath | |
set cmdStr to "qlmanage -p " & fPath | |
do shell script cmdStr | |
`); | |
} | |
//returnToBTT(f); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment