Last active
February 23, 2017 12:17
-
-
Save yarons/063c8a6cc2596e45083cf5dbd403ffbc to your computer and use it in GitHub Desktop.
Battery percentage notifier
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
#!/bin/bash | |
adb shell dumpsys battery | grep level | sed "s@.*: @@" | |
#### Since it's a oneliner I would recommend adding it to the ~/.bashrc or ~/.bash_profile this way: | |
alias batt='adb shell dumpsys battery | grep level | sed "s@.*: @@"' | |
#### If you have many Android deviced connected to your computer you can specify which device to focus on, this way: | |
# First run: adb devices | |
# The ouptut should look like this: | |
# List of devices attached | |
# 47e0abb1 device | |
# 45e0abb2 device | |
# | |
# The hex string at the beginning is the device identifier, change the line to that one: | |
alias batt='adb -s 47e0abb1 shell dumpsys battery | grep level | sed "s@.*: @@"' | |
### There is also a Mac workflow file attached, make sure that line 62 is matching your environment in terms of adb | |
# binary location and device id. |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>AMApplicationBuild</key> | |
<string>419</string> | |
<key>AMApplicationVersion</key> | |
<string>2.6</string> | |
<key>AMDocumentVersion</key> | |
<string>2</string> | |
<key>actions</key> | |
<array> | |
<dict> | |
<key>action</key> | |
<dict> | |
<key>AMAccepts</key> | |
<dict> | |
<key>Container</key> | |
<string>List</string> | |
<key>Optional</key> | |
<true/> | |
<key>Types</key> | |
<array> | |
<string>com.apple.cocoa.string</string> | |
</array> | |
</dict> | |
<key>AMActionVersion</key> | |
<string>2.0.3</string> | |
<key>AMApplication</key> | |
<array> | |
<string>Automator</string> | |
</array> | |
<key>AMParameterProperties</key> | |
<dict> | |
<key>COMMAND_STRING</key> | |
<dict/> | |
<key>CheckedForUserDefaultShell</key> | |
<dict/> | |
<key>inputMethod</key> | |
<dict/> | |
<key>shell</key> | |
<dict/> | |
<key>source</key> | |
<dict/> | |
</dict> | |
<key>AMProvides</key> | |
<dict> | |
<key>Container</key> | |
<string>List</string> | |
<key>Types</key> | |
<array> | |
<string>com.apple.cocoa.string</string> | |
</array> | |
</dict> | |
<key>ActionBundlePath</key> | |
<string>/System/Library/Automator/Run Shell Script.action</string> | |
<key>ActionName</key> | |
<string>Run Shell Script</string> | |
<key>ActionParameters</key> | |
<dict> | |
<key>COMMAND_STRING</key> | |
<string>/Users/yaron/.nexustools/adb -s 47e0abb1 shell dumpsys battery | awk -F':' '/level/ {print $2}'</string> | |
<key>CheckedForUserDefaultShell</key> | |
<true/> | |
<key>inputMethod</key> | |
<integer>0</integer> | |
<key>shell</key> | |
<string>/bin/bash</string> | |
<key>source</key> | |
<string></string> | |
</dict> | |
<key>BundleIdentifier</key> | |
<string>com.apple.RunShellScript</string> | |
<key>CFBundleVersion</key> | |
<string>2.0.3</string> | |
<key>CanShowSelectedItemsWhenRun</key> | |
<false/> | |
<key>CanShowWhenRun</key> | |
<true/> | |
<key>Category</key> | |
<array> | |
<string>AMCategoryUtilities</string> | |
</array> | |
<key>Class Name</key> | |
<string>RunShellScriptAction</string> | |
<key>InputUUID</key> | |
<string>306B6CC5-CDD2-4E27-A354-2D8CCF2B1267</string> | |
<key>Keywords</key> | |
<array> | |
<string>Shell</string> | |
<string>Script</string> | |
<string>Command</string> | |
<string>Run</string> | |
<string>Unix</string> | |
</array> | |
<key>OutputUUID</key> | |
<string>36C91715-9794-4130-AD91-4B5CF4DCC550</string> | |
<key>UUID</key> | |
<string>71B43969-EA06-47BD-9908-A2A4D5138D1B</string> | |
<key>UnlocalizedApplications</key> | |
<array> | |
<string>Automator</string> | |
</array> | |
<key>arguments</key> | |
<dict> | |
<key>0</key> | |
<dict> | |
<key>default value</key> | |
<integer>0</integer> | |
<key>name</key> | |
<string>inputMethod</string> | |
<key>required</key> | |
<string>0</string> | |
<key>type</key> | |
<string>0</string> | |
<key>uuid</key> | |
<string>0</string> | |
</dict> | |
<key>1</key> | |
<dict> | |
<key>default value</key> | |
<string></string> | |
<key>name</key> | |
<string>source</string> | |
<key>required</key> | |
<string>0</string> | |
<key>type</key> | |
<string>0</string> | |
<key>uuid</key> | |
<string>1</string> | |
</dict> | |
<key>2</key> | |
<dict> | |
<key>default value</key> | |
<false/> | |
<key>name</key> | |
<string>CheckedForUserDefaultShell</string> | |
<key>required</key> | |
<string>0</string> | |
<key>type</key> | |
<string>0</string> | |
<key>uuid</key> | |
<string>2</string> | |
</dict> | |
<key>3</key> | |
<dict> | |
<key>default value</key> | |
<string></string> | |
<key>name</key> | |
<string>COMMAND_STRING</string> | |
<key>required</key> | |
<string>0</string> | |
<key>type</key> | |
<string>0</string> | |
<key>uuid</key> | |
<string>3</string> | |
</dict> | |
<key>4</key> | |
<dict> | |
<key>default value</key> | |
<string>/bin/sh</string> | |
<key>name</key> | |
<string>shell</string> | |
<key>required</key> | |
<string>0</string> | |
<key>type</key> | |
<string>0</string> | |
<key>uuid</key> | |
<string>4</string> | |
</dict> | |
</dict> | |
<key>isViewVisible</key> | |
<true/> | |
<key>location</key> | |
<string>309.000000:253.000000</string> | |
<key>nibPath</key> | |
<string>/System/Library/Automator/Run Shell Script.action/Contents/Resources/English.lproj/main.nib</string> | |
</dict> | |
<key>isViewVisible</key> | |
<true/> | |
</dict> | |
<dict> | |
<key>action</key> | |
<dict> | |
<key>AMAccepts</key> | |
<dict> | |
<key>Container</key> | |
<string>List</string> | |
<key>Optional</key> | |
<false/> | |
<key>Types</key> | |
<array> | |
<string>*</string> | |
</array> | |
</dict> | |
<key>AMActionVersion</key> | |
<string>v.1.0.2</string> | |
<key>AMApplication</key> | |
<array> | |
<string>Automator</string> | |
</array> | |
<key>AMParameterProperties</key> | |
<dict> | |
<key>variableUUID</key> | |
<dict> | |
<key>isPathPopUp</key> | |
<false/> | |
<key>selectedVariableUUID</key> | |
<string>70D9E93C-7AFB-45BE-AD54-AFDAD9EA5EF2</string> | |
</dict> | |
</dict> | |
<key>AMProvides</key> | |
<dict> | |
<key>Container</key> | |
<string>List</string> | |
<key>Types</key> | |
<array> | |
<string>*</string> | |
</array> | |
</dict> | |
<key>AMRequiredResources</key> | |
<array/> | |
<key>ActionBundlePath</key> | |
<string>/System/Library/Automator/Set Value of Variable.action</string> | |
<key>ActionName</key> | |
<string>Set Value of Variable</string> | |
<key>ActionParameters</key> | |
<dict> | |
<key>variableUUID</key> | |
<string>70D9E93C-7AFB-45BE-AD54-AFDAD9EA5EF2</string> | |
</dict> | |
<key>BundleIdentifier</key> | |
<string>com.apple.Automator.Set_Value_of_Variable</string> | |
<key>CFBundleVersion</key> | |
<string>1.0.2</string> | |
<key>CanShowSelectedItemsWhenRun</key> | |
<true/> | |
<key>CanShowWhenRun</key> | |
<true/> | |
<key>Category</key> | |
<array> | |
<string>AMCategoryUtilities</string> | |
</array> | |
<key>Class Name</key> | |
<string>Set_Value_of_Variable</string> | |
<key>InputUUID</key> | |
<string>51C616DA-439F-48D0-BB5B-7AA85099DE7F</string> | |
<key>Keywords</key> | |
<array> | |
<string>variable</string> | |
<string>binding</string> | |
<string>input</string> | |
<string>output</string> | |
<string>storage</string> | |
</array> | |
<key>OutputUUID</key> | |
<string>4E628F1D-D20D-4861-954D-0A7D21E25858</string> | |
<key>UUID</key> | |
<string>51333612-521E-4FDE-B2BD-45EBE4B7614F</string> | |
<key>UnlocalizedApplications</key> | |
<array> | |
<string>Automator</string> | |
</array> | |
<key>arguments</key> | |
<dict> | |
<key>0</key> | |
<dict> | |
<key>default value</key> | |
<string></string> | |
<key>name</key> | |
<string>variableUUID</string> | |
<key>required</key> | |
<string>0</string> | |
<key>type</key> | |
<string>0</string> | |
<key>uuid</key> | |
<string>0</string> | |
</dict> | |
</dict> | |
<key>isViewVisible</key> | |
<true/> | |
<key>location</key> | |
<string>309.000000:359.000000</string> | |
<key>nibPath</key> | |
<string>/System/Library/Automator/Set Value of Variable.action/Contents/Resources/Base.lproj/main.nib</string> | |
</dict> | |
<key>isViewVisible</key> | |
<true/> | |
</dict> | |
<dict> | |
<key>action</key> | |
<dict> | |
<key>AMAccepts</key> | |
<dict> | |
<key>Container</key> | |
<string>List</string> | |
<key>Optional</key> | |
<true/> | |
<key>Types</key> | |
<array/> | |
</dict> | |
<key>AMActionVersion</key> | |
<string>v.1.0</string> | |
<key>AMApplication</key> | |
<array> | |
<string>Automator</string> | |
</array> | |
<key>AMParameterProperties</key> | |
<dict> | |
<key>message</key> | |
<dict> | |
<key>tokenizedValue</key> | |
<array> | |
<string>$(70D9E93C-7AFB-45BE-AD54-AFDAD9EA5EF2)</string> | |
<string>%</string> | |
</array> | |
</dict> | |
<key>subtitle</key> | |
<dict> | |
<key>tokenizedValue</key> | |
<array/> | |
</dict> | |
<key>title</key> | |
<dict> | |
<key>tokenizedValue</key> | |
<array> | |
<string>Your current battery level is</string> | |
</array> | |
</dict> | |
</dict> | |
<key>AMProvides</key> | |
<dict> | |
<key>Container</key> | |
<string>List</string> | |
<key>Types</key> | |
<array/> | |
</dict> | |
<key>ActionBundlePath</key> | |
<string>/System/Library/Automator/Display Notification.action</string> | |
<key>ActionName</key> | |
<string>Display Notification</string> | |
<key>ActionParameters</key> | |
<dict> | |
<key>message</key> | |
<string>$(70D9E93C-7AFB-45BE-AD54-AFDAD9EA5EF2)%</string> | |
<key>subtitle</key> | |
<string></string> | |
<key>title</key> | |
<string>Your current battery level is</string> | |
</dict> | |
<key>BundleIdentifier</key> | |
<string>com.apple.Automator.Display-Notification</string> | |
<key>CFBundleVersion</key> | |
<string>1.0</string> | |
<key>CanShowSelectedItemsWhenRun</key> | |
<true/> | |
<key>CanShowWhenRun</key> | |
<false/> | |
<key>Category</key> | |
<array> | |
<string>AMCategoryUtilities</string> | |
</array> | |
<key>Class Name</key> | |
<string>AMDisplayNotificationAction</string> | |
<key>InputUUID</key> | |
<string>76E67168-C941-4BA1-84D3-F111BC017A7F</string> | |
<key>Keywords</key> | |
<array/> | |
<key>OutputUUID</key> | |
<string>DFFF5C76-CD7C-42A2-BCAB-B152A54DEBED</string> | |
<key>UUID</key> | |
<string>185F7593-16A3-44AF-A227-1E8F99BEC091</string> | |
<key>UnlocalizedApplications</key> | |
<array> | |
<string>Automator</string> | |
</array> | |
<key>arguments</key> | |
<dict> | |
<key>0</key> | |
<dict> | |
<key>default value</key> | |
<string></string> | |
<key>name</key> | |
<string>subtitle</string> | |
<key>required</key> | |
<string>0</string> | |
<key>type</key> | |
<string>0</string> | |
<key>uuid</key> | |
<string>0</string> | |
</dict> | |
<key>1</key> | |
<dict> | |
<key>default value</key> | |
<string></string> | |
<key>name</key> | |
<string>title</string> | |
<key>required</key> | |
<string>0</string> | |
<key>type</key> | |
<string>0</string> | |
<key>uuid</key> | |
<string>1</string> | |
</dict> | |
<key>2</key> | |
<dict> | |
<key>default value</key> | |
<string></string> | |
<key>name</key> | |
<string>message</string> | |
<key>required</key> | |
<string>0</string> | |
<key>type</key> | |
<string>0</string> | |
<key>uuid</key> | |
<string>2</string> | |
</dict> | |
</dict> | |
<key>isViewVisible</key> | |
<true/> | |
<key>location</key> | |
<string>309.000000:549.000000</string> | |
<key>nibPath</key> | |
<string>/System/Library/Automator/Display Notification.action/Contents/Resources/Base.lproj/main.nib</string> | |
</dict> | |
<key>isViewVisible</key> | |
<true/> | |
</dict> | |
</array> | |
<key>connectors</key> | |
<dict> | |
<key>6BBA099F-8534-4C6B-8A22-CE76D851A459</key> | |
<dict> | |
<key>from</key> | |
<string>71B43969-EA06-47BD-9908-A2A4D5138D1B - 71B43969-EA06-47BD-9908-A2A4D5138D1B</string> | |
<key>to</key> | |
<string>51333612-521E-4FDE-B2BD-45EBE4B7614F - 51333612-521E-4FDE-B2BD-45EBE4B7614F</string> | |
</dict> | |
<key>E23B8ECE-9A7E-4D01-A4B3-16817C09B76E</key> | |
<dict> | |
<key>from</key> | |
<string>51333612-521E-4FDE-B2BD-45EBE4B7614F - 51333612-521E-4FDE-B2BD-45EBE4B7614F</string> | |
<key>to</key> | |
<string>185F7593-16A3-44AF-A227-1E8F99BEC091 - 185F7593-16A3-44AF-A227-1E8F99BEC091</string> | |
</dict> | |
</dict> | |
<key>variables</key> | |
<array> | |
<dict> | |
<key>UUID</key> | |
<string>70D9E93C-7AFB-45BE-AD54-AFDAD9EA5EF2</string> | |
<key>identifier</key> | |
<string>com.apple.Automator.Variable.Storage</string> | |
<key>name</key> | |
<string>Level</string> | |
</dict> | |
</array> | |
<key>workflowMetaData</key> | |
<dict> | |
<key>workflowTypeIdentifier</key> | |
<string>com.apple.Automator.application</string> | |
</dict> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment