gSwitch icon indicating copy to clipboard operation
gSwitch copied to clipboard

Feature Request: switching based on power source

Open mosemizrahi opened this issue 4 years ago • 8 comments

Hello,

I want to use Dynamic Switching when I'm on battery, and Discrete Only when I'm charging my laptop. I'd like it if gSwitch had a feature that let me do this automatically. In theory, I could run the line "sudo pmset -c gpuswitch 1 && sudo pmset -b gpuswitch 2" in terminal to get what I want, but that doesn't work consistently.

The bash script below implements what I ask for in a "hacky" way. I'm currently using a different script that works similarly using the app BetterTouchTool.

#!/bin/bash
OLDSOURCE=""
while true
do
	CURSOURCE=`pmset -g batt | head -n 1 | cut -d \' -f2`
	if [ "$OLDSOURCE" != "$CURSOURCE" ]
	then
		OLDSOURCE=$CURSOURCE
		killall gSwitch
		if [ "$CURSOURCE" == "AC Power" ]
		then
			open -a /Applications/gSwitch.app/Contents/MacOS/gSwitch --args --discrete
		else
			open -a /Applications/gSwitch.app/Contents/MacOS/gSwitch --args --dynamic
		fi
	fi
	sleep 5
done

mosemizrahi avatar Sep 12 '20 15:09 mosemizrahi

I have considered this before, and unfortunately Apple does not provide a very good API in swift to know when the computer has switched to a different power source. I will leave the issue open if anyone wants to open a PR for this though.

CodySchrank avatar Sep 29 '20 01:09 CodySchrank

I don't know how much this will help, but i hope it may be useful. The Turbo Boost Switcher Pro program has an option, which when switching to the battery turns off Turbo Boost for the Intel processor. Can try to contact the author and find out how he did it? Screenshot 2020-10-01 at 18 32 21

zzonderr avatar Oct 01 '20 15:10 zzonderr

Looks like this might be easier than I thought when I looked this up a few years ago.

Yea I can probably add this in.

ref

CodySchrank avatar Oct 01 '20 16:10 CodySchrank

Would be nice to see because right now the default dynamic switching behavior is reversed for me (discrete on battery, and integrated on power for some reason derp), this tells me that mac internally tried to switch based on power source.

pencilcheck avatar Oct 01 '20 20:10 pencilcheck

Having that would be great. I have a 16" 2019 MBP and I can feel it's a little sluggish on Safari when on integrated.

robertocaldas avatar Nov 02 '20 21:11 robertocaldas

Just to chime in, this would be an awesome feature. I use discrete when plugged in for the same reason as @robertocaldas.

JeffFlowerday avatar Jan 13 '21 16:01 JeffFlowerday

Please! I'm already paying for Turbo Boost to disable extra CPU power (that I don't really need), would love to pay for automatic switching in here - to increase battery time and a cooler laptop :)

Off-topic: it's a wonderful new world - you pay to get less power, but for a longer time... :)

alexander-potemkin avatar Feb 13 '21 12:02 alexander-potemkin

This app is awesome, the idea is awesome and it's real awesome in application. But it will be a leap more awesome if this feature is added. OMG! I'd love to have this. My MBP 16 would drain really fast with discreet GPU when on battery. Please! 🙏

natjsbelza avatar Jun 15 '21 12:06 natjsbelza