├── .github └── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_suggestion.yml ├── LICENSE ├── README.md └── Workflow ├── icon.png ├── images ├── about │ └── lpm.png ├── icon_adapter_off.png ├── icon_adapter_on.png ├── icon_battery_off.png └── icon_battery_on.png └── info.plist /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: File a bug report 3 | body: 4 | - type: input 5 | attributes: 6 | label: Workflow version 7 | description: Open the Workflow in Alfred Preferences and find it at the top, near the description 8 | validations: 9 | required: true 10 | - type: input 11 | attributes: 12 | label: Alfred version 13 | description: In the top left corner of Alfred Preferences → General 14 | validations: 15 | required: true 16 | - type: input 17 | attributes: 18 | label: macOS version 19 | description: Click  on the menubar → About This Mac 20 | validations: 21 | required: true 22 | - type: textarea 23 | attributes: 24 | label: Debugger output 25 | description: Perform the failing action with [the debugger](https://www.alfredapp.com/help/workflows/advanced/debugger/) open 26 | render: alfred_debugger 27 | validations: 28 | required: true 29 | - type: textarea 30 | attributes: 31 | label: More details 32 | description: Explain what you did, what happened, and what you expected to happen 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_suggestion.yml: -------------------------------------------------------------------------------- 1 | name: Feature Suggestion 2 | description: Suggest a new feature 3 | body: 4 | - type: textarea 5 | attributes: 6 | label: Feature details 7 | description: Explain the feature idea 8 | validations: 9 | required: true 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2021, Running with Crayons Ltd 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # icon Low Power Mode Alfred Workflow 2 | 3 | Toggle Low Power Mode for Battery or Power Adapter 4 | 5 | [⤓ Install on the Alfred Gallery](https://alfred.app/workflows/alfredapp/low-power-mode) 6 | 7 | ## Usage 8 | 9 | Toggle Low Power Mode for your battery or power adapter via the `lpm` keyword. 10 | 11 | ![Alfred results for lpm](Workflow/images/about/lpm.png) 12 | -------------------------------------------------------------------------------- /Workflow/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfredapp/low-power-mode-workflow/48a7cee5867a96500582f0c6b3aed8099c60a83a/Workflow/icon.png -------------------------------------------------------------------------------- /Workflow/images/about/lpm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfredapp/low-power-mode-workflow/48a7cee5867a96500582f0c6b3aed8099c60a83a/Workflow/images/about/lpm.png -------------------------------------------------------------------------------- /Workflow/images/icon_adapter_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfredapp/low-power-mode-workflow/48a7cee5867a96500582f0c6b3aed8099c60a83a/Workflow/images/icon_adapter_off.png -------------------------------------------------------------------------------- /Workflow/images/icon_adapter_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfredapp/low-power-mode-workflow/48a7cee5867a96500582f0c6b3aed8099c60a83a/Workflow/images/icon_adapter_on.png -------------------------------------------------------------------------------- /Workflow/images/icon_battery_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfredapp/low-power-mode-workflow/48a7cee5867a96500582f0c6b3aed8099c60a83a/Workflow/images/icon_battery_off.png -------------------------------------------------------------------------------- /Workflow/images/icon_battery_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alfredapp/low-power-mode-workflow/48a7cee5867a96500582f0c6b3aed8099c60a83a/Workflow/images/icon_battery_on.png -------------------------------------------------------------------------------- /Workflow/info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleid 6 | com.alfredapp.vitor.lowpowermode 7 | connections 8 | 9 | 09F16EEE-6DBF-4559-87E0-EBCF59F92293 10 | 11 | 5F671FDE-E06C-42F6-A4A0-EB735D77DDB3 12 | 13 | 14 | destinationuid 15 | 09F16EEE-6DBF-4559-87E0-EBCF59F92293 16 | modifiers 17 | 0 18 | modifiersubtext 19 | 20 | vitoclose 21 | 22 | 23 | 24 | 25 | createdby 26 | Vítor Galvão 27 | description 28 | Toggle Low Power Mode for Battery or Power Adapter 29 | disabled 30 | 31 | name 32 | Low Power Mode 33 | objects 34 | 35 | 36 | config 37 | 38 | concurrently 39 | 40 | escaping 41 | 68 42 | script 43 | on run argv 44 | do shell script "sudo /usr/bin/pmset " & item 1 of argv with administrator privileges 45 | end run 46 | scriptargtype 47 | 1 48 | scriptfile 49 | 50 | type 51 | 6 52 | 53 | type 54 | alfred.workflow.action.script 55 | uid 56 | 09F16EEE-6DBF-4559-87E0-EBCF59F92293 57 | version 58 | 2 59 | 60 | 61 | config 62 | 63 | alfredfiltersresults 64 | 65 | alfredfiltersresultsmatchmode 66 | 0 67 | argumenttreatemptyqueryasnil 68 | 69 | argumenttrimmode 70 | 0 71 | argumenttype 72 | 1 73 | escaping 74 | 102 75 | keyword 76 | {var:status_keyword} 77 | queuedelaycustom 78 | 3 79 | queuedelayimmediatelyinitially 80 | 81 | queuedelaymode 82 | 0 83 | queuemode 84 | 1 85 | runningsubtext 86 | Querying Low Power Mode status… 87 | script 88 | function runCommand(...arguments) { 89 | const task = $.NSTask.alloc.init 90 | const stdout = $.NSPipe.pipe 91 | 92 | task.executableURL = $.NSURL.fileURLWithPath(arguments[0]) 93 | task.arguments = arguments.slice(1) 94 | task.standardOutput = stdout 95 | task.launchAndReturnError(false) 96 | 97 | const dataOut = stdout.fileHandleForReading.readDataToEndOfFileAndReturnError(false) 98 | const stringOut = $.NSString.alloc.initWithDataEncoding(dataOut, $.NSUTF8StringEncoding).js 99 | 100 | return stringOut 101 | } 102 | 103 | const power = runCommand("/usr/bin/pmset", "-g", "custom") 104 | const batteryMatch = power.match(/(Battery) Power:.*?powermode\s*(\d)\n/s) 105 | const adapterMatch = power.match(/(AC) Power:.*?powermode\s*(\d)\n/s) 106 | const batteryName = batteryMatch[1] 107 | const adapterName = adapterMatch[1] 108 | const batteryLowPowerOn = batteryMatch[2] === "1" 109 | const adapterLowPowerOn = adapterMatch[2] === "1" 110 | const batteryLowPowerState = batteryLowPowerOn ? "On" : "Off" 111 | const adapterLowPowerState = adapterLowPowerOn ? "On" : "Off" 112 | const batteryOppositeState = batteryLowPowerOn ? "off" : "on" 113 | const adapterOppositeState = adapterLowPowerOn ? "off" : "on" 114 | const batteryIcon = batteryLowPowerOn ? "images/icon_battery_on.png" : "images/icon_battery_off.png" 115 | const adapterIcon = adapterLowPowerOn ? "images/icon_adapter_on.png" : "images/icon_adapter_off.png" 116 | 117 | const batteryItem = { 118 | title: batteryName + "’s Low Power Mode is " + batteryLowPowerState, 119 | subtitle: "Action to turn it " + batteryOppositeState, 120 | arg: batteryLowPowerOn ? "-b lowpowermode 0" : "-b lowpowermode 1", 121 | icon: { path: batteryIcon } 122 | } 123 | 124 | const adapterItem = { 125 | title: adapterName + "’s Low Power Mode is " + adapterLowPowerState, 126 | subtitle: "Action to turn it " + adapterOppositeState, 127 | arg: adapterLowPowerOn ? "-c lowpowermode 0" : "-c lowpowermode 1", 128 | icon: { path: adapterIcon } 129 | } 130 | 131 | JSON.stringify({ items: [batteryItem, adapterItem] }) 132 | scriptargtype 133 | 1 134 | scriptfile 135 | 136 | skipuniversalaction 137 | 138 | subtext 139 | 140 | title 141 | Toggle Low Power Mode 142 | type 143 | 7 144 | withspace 145 | 146 | 147 | type 148 | alfred.workflow.input.scriptfilter 149 | uid 150 | 5F671FDE-E06C-42F6-A4A0-EB735D77DDB3 151 | version 152 | 3 153 | 154 | 155 | readme 156 | ## Usage 157 | 158 | Toggle Low Power Mode for your battery or power adapter via the `lpm` keyword. 159 | 160 | ![Alfred results for lpm](images/about/lpm.png) 161 | uidata 162 | 163 | 09F16EEE-6DBF-4559-87E0-EBCF59F92293 164 | 165 | xpos 166 | 255 167 | ypos 168 | 40 169 | 170 | 5F671FDE-E06C-42F6-A4A0-EB735D77DDB3 171 | 172 | note 173 | Interactive toggle 174 | xpos 175 | 45 176 | ypos 177 | 40 178 | 179 | 180 | userconfigurationconfig 181 | 182 | 183 | config 184 | 185 | default 186 | lpm 187 | placeholder 188 | 189 | required 190 | 191 | trim 192 | 193 | 194 | description 195 | 196 | label 197 | Status Keyword 198 | type 199 | textfield 200 | variable 201 | status_keyword 202 | 203 | 204 | version 205 | 2024.3 206 | webaddress 207 | https://github.com/alfredapp/low-power-mode-workflow/ 208 | 209 | 210 | --------------------------------------------------------------------------------