Last active
August 17, 2021 12:53
-
-
Save mofirouz/cbcfc1aa08561d2b8ad82363359bafd2 to your computer and use it in GitHub Desktop.
BetterTouchTool Battery Percentage
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
do shell script "pmset -g batt | grep InternalBattery | column -t" | |
set x to the result | |
set state to word 7 of x | |
set remaining to the word 10 of x | |
if state is "discharging" then | |
return 1 | |
else | |
return 2 | |
end if |
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
do shell script "pmset -g batt | grep InternalBattery | column -t" | |
set x to the result | |
set percentage to word 6 of x | |
set state to word 7 of x | |
set t1 to word 8 of x | |
set t2 to word 9 of x | |
set remaining to the word 10 of x | |
if remaining contains "remaining" then | |
if state is "discharging" then | |
return percentage & "% | " & t1 & ":" & t2 & " remaining" | |
else if state is "charging" then | |
return percentage & "% | " & t1 & ":" & t2 & " charging" | |
else | |
return percentage & "% | Fully charged" | |
end if | |
else | |
return percentage & "% | Calculating..." | |
end if |
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
{ | |
"BTTPresetName" : "bettertouchtools.btt_9CEA6015-256C-41EE-B409-BD97C82307AF", | |
"BTTPresetUUID" : "01F3ED09-E8FC-4E4C-87CB-0EBAEDA25EDC", | |
"BTTPresetContent" : [ | |
{ | |
"BTTAppBundleIdentifier" : "BT.G", | |
"BTTAppName" : "Global", | |
"BTTAppSpecificSettings" : { | |
}, | |
"BTTTriggers" : [ | |
{ | |
"BTTTriggerType" : 102, | |
"BTTTriggerTypeDescription" : "3 Finger Swipe Up", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 198, | |
"BTTPredefinedActionName" : "Volume Up (Small Step)", | |
"BTTEnabled" : 1, | |
"BTTRequiredModifierKeys" : 524288, | |
"BTTOrder" : 4 | |
}, | |
{ | |
"BTTTriggerType" : 107, | |
"BTTTriggerTypeDescription" : "4 Finger Swipe Down", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 5, | |
"BTTPredefinedActionName" : "Mission Control", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 7 | |
}, | |
{ | |
"BTTTriggerType" : 103, | |
"BTTTriggerTypeDescription" : "3 Finger Swipe Down", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 199, | |
"BTTPredefinedActionName" : "Volume Down (Small Step)", | |
"BTTEnabled" : 1, | |
"BTTRequiredModifierKeys" : 524288, | |
"BTTOrder" : 5 | |
}, | |
{ | |
"BTTTriggerType" : 104, | |
"BTTTriggerTypeDescription" : "3 Finger Tap", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 1, | |
"BTTPredefinedActionName" : "Middle Click", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 0 | |
}, | |
{ | |
"BTTTriggerType" : 170, | |
"BTTTriggerTypeDescription" : "3 Finger FORCE Click", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 23, | |
"BTTPredefinedActionName" : "Play\/Pause", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 1 | |
}, | |
{ | |
"BTTTriggerType" : 103, | |
"BTTTriggerTypeDescription" : "3 Finger Swipe Down", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 25, | |
"BTTPredefinedActionName" : "Volume Down", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 3 | |
}, | |
{ | |
"BTTTriggerType" : 102, | |
"BTTTriggerTypeDescription" : "3 Finger Swipe Up", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 24, | |
"BTTPredefinedActionName" : "Volume Up", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 2 | |
}, | |
{ | |
"BTTTriggerType" : 184, | |
"BTTTriggerTypeDescription" : "Corner FORCE Click Top Left", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 26, | |
"BTTPredefinedActionName" : "Previous", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 12 | |
}, | |
{ | |
"BTTTriggerType" : 187, | |
"BTTTriggerTypeDescription" : "Corner FORCE Click Bottom Right", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 202, | |
"BTTPredefinedActionName" : "Start Screen Saver", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 13 | |
}, | |
{ | |
"BTTTriggerType" : 110, | |
"BTTTriggerTypeDescription" : "4 Finger Tap", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTShortcutToSend" : "55,13", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 6 | |
}, | |
{ | |
"BTTTriggerType" : 624, | |
"BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut", | |
"BTTPredefinedActionType" : 188, | |
"BTTPredefinedActionName" : "Toggle BetterTouchTool Touch Bar", | |
"BTTEnabled" : 1, | |
"BTTShortcutKeyCode" : -1, | |
"BTTShortcutModifierKeys" : -1, | |
"BTTOrder" : 0, | |
"BTTKeySequence" : { | |
"BTTPauseBetween" : 0.3, | |
"BTTKeyCount" : 2, | |
"BTTKeySequenceDownKeys" : [ | |
{ | |
"BTTKEYCode" : 61, | |
"BTTKEYDown" : 1, | |
"BTTKEYOrderRelevant" : 1, | |
"BTTKEYRequired" : 1, | |
"BTTKEYTime" : 5.243456e+08 | |
} | |
], | |
"BTTKeySequenceMixedKeys" : [ | |
{ | |
"BTTKEYCode" : 61, | |
"BTTKEYDown" : 1, | |
"BTTKEYOrderRelevant" : 1, | |
"BTTKEYRequired" : 1, | |
"BTTKEYTime" : 5.243456e+08 | |
}, | |
{ | |
"BTTKEYCode" : 61, | |
"BTTKEYTime" : 5.243456e+08 | |
} | |
], | |
"BTTKeySequenceUpKeys" : [ | |
{ | |
"BTTKEYCode" : 61, | |
"BTTKEYTime" : 5.243456e+08 | |
} | |
] | |
} | |
}, | |
{ | |
"BTTWidgetName" : "iTunes", | |
"BTTTriggerType" : 639, | |
"BTTTriggerTypeDescription" : "Apple Script Widget", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchBar", | |
"BTTPredefinedActionType" : 27, | |
"BTTPredefinedActionName" : "Next", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 2, | |
"BTTTriggerConfig" : { | |
"BTTTouchBarItemPlacement" : 2, | |
"BTTTouchBarItemPadding" : 0, | |
"BTTTouchBarFreeSpaceAfterButton" : "5.000000", | |
"BTTTouchBarButtonColor" : "58.650001, 58.650001, 58.650001, 255.000000", | |
"BTTTouchBarAlwaysShowButton" : "0", | |
"BTTTouchBarAppleScriptString" : "-- This script can be used in conjunction with Better Touch Tool to display the currently playing track on the MacBook Pro TouchBar\r-- More info here: https:\/\/lucatnt.com\/2017\/02\/display-the-currently-playing-track-in-itunesspotify-on-the-touch-bar\r\rif application \"iTunes\" is running then\r\ttell application \"iTunes\"\r\t\tif player state is playing then\r\t\t\treturn (get artist of current track) & \" - \" & (get name of current track)\r\t\telse\r\t\t\treturn \"\"\r\t\tend if\r\tend tell\relse\r\treturn \"\"\rend if", | |
"BTTTouchBarAlternateBackgroundColor" : "109.650002, 109.650002, 109.650002, 255.000000", | |
"BTTTouchBarScriptUpdateInterval" : 3.00885 | |
} | |
}, | |
{ | |
"BTTWidgetName" : "Battery", | |
"BTTTriggerType" : 639, | |
"BTTTriggerTypeDescription" : "Apple Script Widget", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchBar", | |
"BTTShortcutToSend" : "55,10", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 1, | |
"BTTTriggerConfig" : { | |
"BTTTouchBarItemPlacement" : 1, | |
"BTTTouchBarItemPadding" : 0, | |
"BTTTouchBarFreeSpaceAfterButton" : "5.000000", | |
"BTTTouchBarButtonColor" : "58.650001, 58.650001, 58.650001, 255.000000", | |
"BTTTouchBarAlwaysShowButton" : "0", | |
"BTTTouchBarAppleScriptString" : "do shell script \"pmset -g batt | grep InternalBattery | column -t\"\rset x to the result\rset percentage to word 6 of x\rset state to word 7 of x\rset t1 to word 8 of x\rset t2 to word 9 of x\rset remaining to the word 10 of x\rif remaining contains \"remaining\" then\r\tif state is \"discharging\" then\r\t\t-- remaining\r\t\treturn \"Discharging: \" & percentage & \"% | \" & t1 & \":\" & t2\r\telse if state is \"charging\" then\r\t\t-- charging\r\t\treturn \"Charging: \" & percentage & \"% | \" & t1 & \":\" & t2\r\telse\r\t\t-- fully charged\r\t\treturn \"Charged: \" & percentage & \"%\"\r\tend if\relse\r\t-- calculating...\r\treturn percentage & \"%\"\rend if", | |
"BTTTouchBarAlternateBackgroundColor" : "44.817455, 44.816114, 44.816870, 255.000000", | |
"BTTTouchBarScriptUpdateInterval" : 5 | |
} | |
}, | |
{ | |
"BTTTriggerType" : 101, | |
"BTTTriggerTypeDescription" : "3 Finger Swipe Right", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 77, | |
"BTTPredefinedActionName" : "3F Swipe Left (Page Back)", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 9 | |
}, | |
{ | |
"BTTWidgetName" : "Battery Icon", | |
"BTTTriggerType" : 639, | |
"BTTTriggerTypeDescription" : "Apple Script Widget", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchBar", | |
"BTTShortcutToSend" : "55,10", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 0, | |
"BTTTriggerConfig" : { | |
"BTTTouchBarItemPlacement" : 1, | |
"BTTTouchBarItemPadding" : 0, | |
"BTTTouchBarFreeSpaceAfterButton" : "5.000000", | |
"BTTTouchBarButtonColor" : "44.817455, 44.816114, 44.816870, 255.000000", | |
"BTTTouchBarAlwaysShowButton" : "0", | |
"BTTTouchBarAppleScriptString" : "do shell script \"pmset -g batt | grep InternalBattery | column -t\"\rset x to the result\rset state to word 7 of x\rset remaining to the word 10 of x\rif state is \"discharging\" then\r\treturn 1\relse\r\treturn 2\rend if", | |
"BTTTouchBarColorRegex" : "2", | |
"BTTTouchBarAlternateBackgroundColor" : "170.929688, 101.928850, 0.000000, 255.000000", | |
"BTTTouchBarOnlyShowIcon" : 1, | |
"BTTTouchBarScriptUpdateInterval" : 5 | |
} | |
}, | |
{ | |
"BTTTriggerType" : 108, | |
"BTTTriggerTypeDescription" : "4 Finger Swipe Up", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 45, | |
"BTTPredefinedActionName" : "Show Desktop", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 8 | |
}, | |
{ | |
"BTTTriggerType" : 100, | |
"BTTTriggerTypeDescription" : "3 Finger Swipe Left", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 78, | |
"BTTPredefinedActionName" : "3F Swipe Right (Page Forward)", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 10 | |
}, | |
{ | |
"BTTTriggerType" : 186, | |
"BTTTriggerTypeDescription" : "Corner FORCE Click Bottom Left", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 128, | |
"BTTPredefinedActionName" : "Send Shortcut to Specific App", | |
"BTTShortcutApp" : "\/System\/Library\/CoreServices\/Finder.app", | |
"BTTShortcutSwitchToAppFirst" : "1", | |
"BTTShortcutAppUnderCursor" : "com.apple.finder", | |
"BTTShortcutToSend" : "55,45", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 14 | |
}, | |
{ | |
"BTTWidgetWidth" : "E hh:mm a", | |
"BTTTriggerType" : 633, | |
"BTTTriggerTypeDescription" : "Date \/ Time Widget", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchBar", | |
"BTTPredefinedActionType" : 122, | |
"BTTPredefinedActionName" : "Show Notification Center", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 3, | |
"BTTTriggerConfig" : { | |
"BTTTouchBarItemPlacement" : 2, | |
"BTTTouchBarItemPadding" : 0, | |
"BTTTouchBarFreeSpaceAfterButton" : "0.000000", | |
"BTTTouchBarButtonColor" : "58.650001, 58.650001, 58.650001, 255.000000", | |
"BTTTouchBarAlwaysShowButton" : "0", | |
"BTTTouchBarAlternateBackgroundColor" : "0.000000, 0.000000, 0.000000, 0.000000" | |
} | |
}, | |
{ | |
"BTTTriggerType" : 185, | |
"BTTTriggerTypeDescription" : "Corner FORCE Click Top Right", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTPredefinedActionType" : 27, | |
"BTTPredefinedActionName" : "Next", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 11 | |
} | |
] | |
}, | |
{ | |
"BTTAppBundleIdentifier" : "com.apple.iTunes", | |
"BTTAppName" : "iTunes", | |
"BTTTriggers" : [ | |
{ | |
"BTTTriggerType" : 182, | |
"BTTTriggerTypeDescription" : "Corner Click Top Left", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTShortcutToSend" : "58,56,55,1", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 0 | |
}, | |
{ | |
"BTTTouchBarButtonName" : "Shuffle", | |
"BTTTriggerType" : 629, | |
"BTTTriggerClass" : "BTTTriggerTypeTouchBar", | |
"BTTShortcutToSend" : "58,55,1", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 0, | |
"BTTTriggerConfig" : { | |
"BTTTouchBarItemPadding" : 20, | |
"BTTTouchBarFreeSpaceAfterButton" : "5.000000", | |
"BTTTouchBarButtonColor" : "44.817455, 44.816114, 44.816870, 255.000000", | |
"BTTTouchBarAlwaysShowButton" : "0", | |
"BTTTouchBarAlternateBackgroundColor" : "0.000000, 0.000000, 0.000000, 0.000000", | |
"BTTTouchBarOnlyShowIcon" : 1 | |
} | |
}, | |
{ | |
"BTTTouchBarButtonName" : "Shuffle Off", | |
"BTTTriggerType" : 629, | |
"BTTTriggerClass" : "BTTTriggerTypeTouchBar", | |
"BTTShortcutToSend" : "58,56,55,1", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 1, | |
"BTTTriggerConfig" : { | |
"BTTTouchBarItemPadding" : 20, | |
"BTTTouchBarFreeSpaceAfterButton" : "5.000000", | |
"BTTTouchBarButtonColor" : "45.137603, 44.517423, 44.531752, 255.000000", | |
"BTTTouchBarAlwaysShowButton" : "0", | |
"BTTTouchBarAlternateBackgroundColor" : "0.000000, 0.000000, 0.000000, 0.000000", | |
"BTTTouchBarOnlyShowIcon" : 1 | |
} | |
}, | |
{ | |
"BTTTriggerType" : 183, | |
"BTTTriggerTypeDescription" : "Corner Click Top Right", | |
"BTTTriggerClass" : "BTTTriggerTypeTouchpadAll", | |
"BTTShortcutToSend" : "58,55,1", | |
"BTTEnabled" : 1, | |
"BTTOrder" : 1 | |
} | |
] | |
} | |
], | |
"BTTPresetSnapAreas" : [ | |
] | |
} |
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
-- This script can be used in conjunction with Better Touch Tool to display the currently playing track on the MacBook Pro TouchBar | |
-- More info here: https://lucatnt.com/2017/02/display-the-currently-playing-track-in-itunesspotify-on-the-touch-bar | |
if application "iTunes" is running then | |
tell application "iTunes" | |
if player state is playing then | |
return (get artist of current track) & " - " & (get name of current track) | |
else | |
return "" | |
end if | |
end tell | |
else | |
return "" | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment