-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
copy %programdata%\Lenovo\ImController\Plugins\ThinkBatteryPlugin\x86\Lenovo.Modern.Portable.Battery.dll Lenovo.Modern.Portable.Battery.dll | ||
copy %programdata%\Lenovo\ImController\Plugins\ThinkBatteryPlugin\x86\Plugins.Battery.Think.Native.dll Plugins.Battery.Think.Native.dll |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Lenovo.Modern.Portable.Battery; | ||
using Native; | ||
using System; | ||
|
||
namespace ThinkBattery | ||
{ | ||
class Program | ||
{ | ||
|
||
static void Main(string[] args) | ||
{ | ||
|
||
var batInterface = new BatteryInterface(); | ||
var chargeStatus = batInterface.QueryBattery(1).SmartBatteryStatus.ChargeStatus.GetValue(); | ||
var bat = new ChargeThreshold | ||
{ | ||
IsEnabled = true, | ||
SlotNumber = 1, | ||
StartValue = 0, | ||
StopValue = 1 | ||
}; | ||
if (chargeStatus == "NoActivity") { | ||
bat.StopValue = 0; | ||
} | ||
if (args.Length == 1 && args[0] == "on") | ||
{ | ||
bat.StopValue = 1; | ||
} else if (args.Length == 1 && args[0] == "off") { | ||
bat.StopValue = 0; | ||
} | ||
batInterface.SetChargeThreshold(bat); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
# FakeSlice | ||
Discharge USB-C Power Banks before internal battery on newer ThinkPads. | ||
Discharge USB-C Power Banks instead of charging internal battery on newer ThinkPads, allowing them to function as a swappable "Slice Battery". | ||
|
||
## Dependencies | ||
|
||
This application requires Lenovo Vantage to be installed, but doesn't require you to have it running. More specifically, the System Interface Package that comes bundled with Lenovo Vantage is required. You will also need two specific DLLs that come with the application. Since these files are proprietary code, they cannot be included. However, the included `CopyDLLs.bat` script should copy the dependencies from their default installation location to the directory it is ran from. | ||
|
||
## Build | ||
|
||
Just throw `FakeSlice.cs` into your favorite C# compiler, target .NET Framework 4.5, and add the two required references - `Plugins.Battery.Think.Native.dll` & `Lenovo.Modern.Portable.Battery.dll`, then compile as Windows Application. | ||
|
||
## Run | ||
|
||
The included release binary will toggle your setting when launched without any commandline arguments. Running the application with the argument `on` will turn the FakeSlice "on" - which will disable charging and run off your Power Bank. Running the application with the argument `off` will turn the FakeSlice "off" and charge the internal battery. This should allow you to use FakeSlice in your scripts with ease, and without any arguments FakeSlice works great when bound to a hotkey (ike `Fn + F12`) using Lenovo Vantage. | ||
|
||
## To-Do | ||
|
||
Fakeslice currently only supports single battery ThinkPads. Support for Power Bridge enabled systems should be coming in a few days, which will allow you to disable internal battery charging. The current version will only disable charging the battery internally marked as the primary. |